Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
2518d8e9
Commit
2518d8e9
authored
Jul 03, 2014
by
Carlos Andrés Rocha
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4301 from rocha/display-na-on-instructor-dashboard
Don't show 500 errors if connection to data API fails
parents
c7f66715
5be08cc2
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
17 deletions
+33
-17
lms/djangoapps/instructor/views/instructor_dashboard.py
+33
-17
No files found.
lms/djangoapps/instructor/views/instructor_dashboard.py
View file @
2518d8e9
...
...
@@ -2,6 +2,8 @@
Instructor Dashboard Views
"""
import
logging
from
django.utils.translation
import
ugettext
as
_
from
django_future.csrf
import
ensure_csrf_cookie
from
django.views.decorators.cache
import
cache_control
...
...
@@ -27,12 +29,14 @@ from student.models import CourseEnrollment
from
bulk_email.models
import
CourseAuthorization
from
class_dashboard.dashboard_data
import
get_section_display_name
,
get_array_section_has_problem
from
analyticsclient.client
import
RestClient
from
analyticsclient.client
import
RestClient
,
ClientError
from
analyticsclient.course
import
Course
from
.tools
import
get_units_with_due_date
,
title_or_url
,
bulk_email_is_enabled_for_course
from
opaque_keys.edx.locations
import
SlashSeparatedCourseKey
log
=
logging
.
getLogger
(
__name__
)
@ensure_csrf_cookie
@cache_control
(
no_cache
=
True
,
no_store
=
True
,
must_revalidate
=
True
)
...
...
@@ -250,22 +254,7 @@ def _section_analytics(course_key, access):
}
if
settings
.
FEATURES
.
get
(
'ENABLE_ANALYTICS_ACTIVE_COUNT'
):
auth_token
=
settings
.
ANALYTICS_DATA_TOKEN
base_url
=
settings
.
ANALYTICS_DATA_URL
client
=
RestClient
(
base_url
=
base_url
,
auth_token
=
auth_token
)
course
=
Course
(
client
,
course_key
)
section_data
[
'active_student_count'
]
=
course
.
recent_active_user_count
[
'count'
]
def
format_date
(
value
):
return
value
.
split
(
'T'
)[
0
]
start
=
course
.
recent_active_user_count
[
'interval_start'
]
end
=
course
.
recent_active_user_count
[
'interval_end'
]
section_data
[
'active_student_count_start'
]
=
format_date
(
start
)
section_data
[
'active_student_count_end'
]
=
format_date
(
end
)
_update_active_students
(
course_key
,
section_data
)
return
section_data
...
...
@@ -284,3 +273,30 @@ def _section_metrics(course_key, access):
'post_metrics_data_csv_url'
:
reverse
(
'post_metrics_data_csv'
),
}
return
section_data
def
_update_active_students
(
course_key
,
section_data
):
auth_token
=
settings
.
ANALYTICS_DATA_TOKEN
base_url
=
settings
.
ANALYTICS_DATA_URL
section_data
[
'active_student_count'
]
=
'N/A'
section_data
[
'active_student_count_start'
]
=
'N/A'
section_data
[
'active_student_count_end'
]
=
'N/A'
try
:
client
=
RestClient
(
base_url
=
base_url
,
auth_token
=
auth_token
)
course
=
Course
(
client
,
course_key
)
section_data
[
'active_student_count'
]
=
course
.
recent_active_user_count
[
'count'
]
def
format_date
(
value
):
return
value
.
split
(
'T'
)[
0
]
start
=
course
.
recent_active_user_count
[
'interval_start'
]
end
=
course
.
recent_active_user_count
[
'interval_end'
]
section_data
[
'active_student_count_start'
]
=
format_date
(
start
)
section_data
[
'active_student_count_end'
]
=
format_date
(
end
)
except
(
ClientError
,
KeyError
)
as
e
:
log
.
exception
(
e
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment