From d1fe2c3361d2d516a80eecc67df2bbfd6998860a Mon Sep 17 00:00:00 2001 From: JM Van Thong Date: Mon, 26 Nov 2012 18:18:18 -0500 Subject: [PATCH] Added analytics tab in instructor dashbaord, and call to the analytics back-end to display sample data. --- lms/djangoapps/instructor/views.py | 10 ++++++++++ lms/envs/common.py | 3 +++ lms/envs/dev.py | 7 +++++++ .../courseware/instructor_dashboard.html | 18 +++++++++++++++++- 4 files changed, 37 insertions(+), 1 deletion(-) diff --git a/lms/djangoapps/instructor/views.py b/lms/djangoapps/instructor/views.py index f985cc43a0..31faf8acb6 100644 --- a/lms/djangoapps/instructor/views.py +++ b/lms/djangoapps/instructor/views.py @@ -12,6 +12,7 @@ from django.http import HttpResponse from django_future.csrf import ensure_csrf_cookie from django.views.decorators.cache import cache_control from mitxmako.shortcuts import render_to_response +import requests from courseware import grades from courseware.access import has_access, get_access_group_name @@ -266,8 +267,16 @@ def instructor_dashboard(request, course_id): if idash_mode=='Psychometrics': problems = psychoanalyze.problems_with_psychometric_data(course_id) + #---------------------------------------- + # analytics + analytics_json = None + if idash_mode == 'Analytics': + req = requests.get(settings.ANALYTICS_SERVER_URL + "get_daily_activity?sid=2") + #analytics_html = req.text + analytics_json = req.json + #---------------------------------------- # context for rendering context = {'course': course, @@ -282,6 +291,7 @@ def instructor_dashboard(request, course_id): 'plots': plots, # psychometrics 'course_errors': modulestore().get_item_errors(course.location), 'djangopid' : os.getpid(), + 'analytics_json' : analytics_json, } return render_to_response('courseware/instructor_dashboard.html', context) diff --git a/lms/envs/common.py b/lms/envs/common.py index dd9013bcb3..5e22e70307 100644 --- a/lms/envs/common.py +++ b/lms/envs/common.py @@ -81,6 +81,9 @@ MITX_FEATURES = { 'AUTH_USE_OPENID': False, 'AUTH_USE_MIT_CERTIFICATES' : False, 'AUTH_USE_OPENID_PROVIDER': False, + + # analytics experiments + 'ENABLE_INSTRUCTOR_ANALYTICS' : False, } # Used for A/B testing diff --git a/lms/envs/dev.py b/lms/envs/dev.py index bf72284425..0db028866a 100644 --- a/lms/envs/dev.py +++ b/lms/envs/dev.py @@ -21,6 +21,8 @@ MITX_FEATURES['SUBDOMAIN_BRANDING'] = True MITX_FEATURES['FORCE_UNIVERSITY_DOMAIN'] = None # show all university courses if in dev (ie don't use HTTP_HOST) MITX_FEATURES['ENABLE_MANUAL_GIT_RELOAD'] = True MITX_FEATURES['ENABLE_PSYCHOMETRICS'] = False # real-time psychometrics (eg item response theory analysis in instructor dashboard) +MITX_FEATURES['ENABLE_INSTRUCTOR_ANALYTICS'] = True + WIKI_ENABLED = True @@ -177,3 +179,8 @@ PIPELINE_SASS_ARGUMENTS = '-r {proj_dir}/static/sass/bourbon/lib/bourbon.rb'.for MITX_FEATURES['ENABLE_PEARSON_HACK_TEST'] = True PEARSON_TEST_USER = "pearsontest" PEARSON_TEST_PASSWORD = "12345" + +########################## ANALYTICS TESTING ######################## + +ANALYTICS_SERVER_URL = "http://127.0.0.1:14141/" + diff --git a/lms/templates/courseware/instructor_dashboard.html b/lms/templates/courseware/instructor_dashboard.html index 74bc25fcbe..de619a6144 100644 --- a/lms/templates/courseware/instructor_dashboard.html +++ b/lms/templates/courseware/instructor_dashboard.html @@ -57,7 +57,11 @@ function goto( mode) Psychometrics | %endif Admin | - Forum Admin ] + Forum Admin + %if settings.MITX_FEATURES.get('ENABLE_INSTRUCTOR_ANALYTICS'): + | Analytics + %endif + ]
${djangopid}
@@ -165,6 +169,18 @@ function goto( mode) +##----------------------------------------------------------------------------- +%if modeflag.get('Analytics'): + + % for r in analytics_json: + + + + % endfor +
${r['day']}${r['student_count']}
+ +%endif + ##----------------------------------------------------------------------------- %if modeflag.get('Psychometrics') is None: