diff --git a/lms/djangoapps/instructor/views.py b/lms/djangoapps/instructor/views.py index 5c743561a9..5da0209ace 100644 --- a/lms/djangoapps/instructor/views.py +++ b/lms/djangoapps/instructor/views.py @@ -7,6 +7,8 @@ import os import urllib import datetime from datetime import datetime, timedelta +import json +from collections import OrderedDict from django.conf import settings from django.contrib.auth.models import User, Group @@ -272,11 +274,10 @@ def instructor_dashboard(request, course_id): #---------------------------------------- # analytics - analytics_json = None + attempted_problems = None students_enrolled_json = None students_active_json = None daily_activity_json = None - students_daily_activity_json = None students_per_problem_correct_json = None overall_grade_distribution = None dropoff_per_day = None @@ -287,29 +288,32 @@ def instructor_dashboard(request, course_id): to_day = datetime.today().date() from_day = to_day - timedelta(days=7) + # WARNING: do not use req.json because the preloaded json doesn't preserve the order of the original record + # number of students enrolled in this course req = requests.get(settings.ANALYTICS_SERVER_URL + "get_analytics?aname=StudentsEnrolled&course_id=%s" % course_id) - students_enrolled_json = req.json + students_enrolled_json = json.loads(req.content, object_pairs_hook=OrderedDict) # number of students active in the past 7 days (including current day), i.e. with at least one activity for the period req = requests.get(settings.ANALYTICS_SERVER_URL + "get_analytics?aname=StudentsActive&course_id=%s&from=%s" % (course_id,from_day)) - students_active_json = req.json + students_active_json = json.loads(req.content, object_pairs_hook=OrderedDict) # number of students per problem who have problem graded correct req = requests.get(settings.ANALYTICS_SERVER_URL + "get_analytics?aname=StudentsPerProblemCorrect&course_id=%s&from=%s" % (course_id,from_day)) - students_per_problem_correct_json = req.json + students_per_problem_correct_json = json.loads(req.content, object_pairs_hook=OrderedDict) - # grade distribution for the course + # grade distribution for the course +++ this is not the desired distribution +++ req = requests.get(settings.ANALYTICS_SERVER_URL + "get_analytics?aname=OverallGradeDistribution&course_id=%s" % (course_id,)) - overall_grade_distribution = req.json + overall_grade_distribution = json.loads(req.content, object_pairs_hook=OrderedDict) # number of students distribution drop off per day req = requests.get(settings.ANALYTICS_SERVER_URL + "get_analytics?aname=StudentsDropoffPerDay&course_id=%s&from=%s" % (course_id,from_day)) - dropoff_per_day = req.json + dropoff_per_day = json.loads(req.content, object_pairs_hook=OrderedDict) + + # number of students per problem who attempted this problem at least once + req = requests.get(settings.ANALYTICS_SERVER_URL + "get_analytics?aname=StudentsAttemptedProblems&course_id=%s" % course_id) + attempted_problems = json.loads(req.content, object_pairs_hook=OrderedDict) - # the following is ++incorrect++ use of studentmodule table - req = requests.get(settings.ANALYTICS_SERVER_URL + "get_analytics?aname=StudentsDailyActivity&course_id=%s&from=%s" % (course_id,from_day)) - students_daily_activity_json = req.json # number of students active in the past 7 days (including current day) --- online version! experimental to_day = datetime.today().date() @@ -317,9 +321,6 @@ def instructor_dashboard(request, course_id): req = requests.get(settings.ANALYTICS_SERVER_URL + "get_analytics?aname=DailyActivityAnalyzer&course_id=%s&from=%s&to=%s" % (course_id,from_day, to_day)) daily_activity_json = req.json - req = requests.get(settings.ANALYTICS_SERVER_URL + "get_analytics?aname=StudentsPerHomework&course_id=%s" % course_id) - analytics_json = req.json - #---------------------------------------- # context for rendering context = {'course': course, @@ -334,14 +335,13 @@ def instructor_dashboard(request, course_id): 'plots': plots, # psychometrics 'course_errors': modulestore().get_item_errors(course.location), 'djangopid' : os.getpid(), - 'analytics_json' : analytics_json, 'students_enrolled_json' : students_enrolled_json, 'students_active_json' : students_active_json, 'daily_activity_json' : daily_activity_json, - 'students_daily_activity_json' : students_daily_activity_json, 'students_per_problem_correct_json' : students_per_problem_correct_json, 'overall_grade_distribution' : overall_grade_distribution, 'dropoff_per_day' : dropoff_per_day, + 'attempted_problems' : attempted_problems, } return render_to_response('courseware/instructor_dashboard.html', context) diff --git a/lms/templates/courseware/instructor_dashboard.html b/lms/templates/courseware/instructor_dashboard.html index b06eb43944..e347ab2c60 100644 --- a/lms/templates/courseware/instructor_dashboard.html +++ b/lms/templates/courseware/instructor_dashboard.html @@ -177,10 +177,10 @@ function goto( mode) %if modeflag.get('Analytics'):
- Number of students enrolled: ${students_enrolled_json['data']['nb_students_enrolled']} + Number of students enrolled: ${students_enrolled_json['data']['value']}
- Number of active students for the past 7 days: ${students_active_json['data']['nb_students_active']} + Number of active students for the past 7 days: ${students_active_json['data']['value']}
@@ -233,7 +233,7 @@ function goto( mode)
| Module | Number of students |
|---|---|
| ${k} | ${v} |
-
| Day | Number of students |
|---|---|
| ${k} | ${v} | -