From d00e2b747766669420edbb5dfb3f53d2ef081c6c Mon Sep 17 00:00:00 2001 From: Ben McMorran Date: Mon, 30 Jun 2014 15:33:10 -0400 Subject: [PATCH 1/8] Uses ModuleStoreEnum in is_xblock_visible_to_students --- cms/djangoapps/contentstore/utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cms/djangoapps/contentstore/utils.py b/cms/djangoapps/contentstore/utils.py index 8f29ad9e5b..ffdce78592 100644 --- a/cms/djangoapps/contentstore/utils.py +++ b/cms/djangoapps/contentstore/utils.py @@ -12,7 +12,7 @@ from django.core.urlresolvers import reverse from xmodule.contentstore.content import StaticContent from xmodule.contentstore.django import contentstore -from xmodule.modulestore import REVISION_OPTION_PUBLISHED_ONLY +from xmodule.modulestore import ModuleStoreEnum from xmodule.modulestore.django import modulestore from xmodule.modulestore.mixed import store_bulk_write_operations_on_course from xmodule.modulestore.exceptions import ItemNotFoundError @@ -139,7 +139,7 @@ def is_xblock_visible_to_students(xblock): """ try: - published = modulestore().get_item(xblock.location, revision=REVISION_OPTION_PUBLISHED_ONLY) + published = modulestore().get_item(xblock.location, revision=ModuleStoreEnum.RevisionOption.published_only) # If there's no published version then the xblock is clearly not visible except ItemNotFoundError: return False From d118fb8cb24472b94bbe5e678939bef1b63c4164 Mon Sep 17 00:00:00 2001 From: Clinton Blackburn Date: Thu, 12 Jun 2014 14:20:17 -0400 Subject: [PATCH 2/8] Get active student count from new analytics data API Disabled by default. --- .../instructor/views/instructor_dashboard.py | 22 +++++++++++++++++++ lms/envs/aws.py | 4 ++++ lms/envs/dev.py | 4 ++++ lms/envs/devstack.py | 10 +++++++++ .../sass/course/instructor/_instructor_2.scss | 9 ++++++++ .../instructor_dashboard_2/analytics.html | 18 +++++++++++++++ requirements/edx/github.txt | 1 + 7 files changed, 68 insertions(+) diff --git a/lms/djangoapps/instructor/views/instructor_dashboard.py b/lms/djangoapps/instructor/views/instructor_dashboard.py index 939c1e03dc..930f8304f6 100644 --- a/lms/djangoapps/instructor/views/instructor_dashboard.py +++ b/lms/djangoapps/instructor/views/instructor_dashboard.py @@ -27,6 +27,9 @@ 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.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 @@ -245,6 +248,25 @@ def _section_analytics(course_key, access): 'get_distribution_url': reverse('get_distribution', kwargs={'course_id': course_key.to_deprecated_string()}), 'proxy_legacy_analytics_url': reverse('proxy_legacy_analytics', kwargs={'course_id': course_key.to_deprecated_string()}), } + + 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) + return section_data diff --git a/lms/envs/aws.py b/lms/envs/aws.py index 25369651b3..bd5ee9e0e8 100644 --- a/lms/envs/aws.py +++ b/lms/envs/aws.py @@ -343,6 +343,10 @@ if 'DATADOG_API' in AUTH_TOKENS: ANALYTICS_SERVER_URL = ENV_TOKENS.get("ANALYTICS_SERVER_URL") ANALYTICS_API_KEY = AUTH_TOKENS.get("ANALYTICS_API_KEY", "") +# Analytics data source +ANALYTICS_DATA_URL = ENV_TOKENS.get("ANALYTICS_DATA_URL") +ANALYTICS_DATA_TOKEN = AUTH_TOKENS.get("ANALYTICS_DATA_TOKEN", "") + # Zendesk ZENDESK_USER = AUTH_TOKENS.get("ZENDESK_USER") ZENDESK_API_KEY = AUTH_TOKENS.get("ZENDESK_API_KEY") diff --git a/lms/envs/dev.py b/lms/envs/dev.py index e1c68d92e4..999f046271 100644 --- a/lms/envs/dev.py +++ b/lms/envs/dev.py @@ -264,6 +264,10 @@ PIPELINE_SASS_ARGUMENTS = '--debug-info --require {proj_dir}/static/sass/bourbon ANALYTICS_SERVER_URL = "http://127.0.0.1:9000/" ANALYTICS_API_KEY = "" +ANALYTICS_DATA_URL = "http://127.0.0.1:8080" +ANALYTICS_DATA_TOKEN = "" +FEATURES['ENABLE_ANALYTICS_ACTIVE_COUNT'] = True + ##### segment-io ###### # If there's an environment variable set, grab it and turn on Segment.io diff --git a/lms/envs/devstack.py b/lms/envs/devstack.py index 7d7aabfe0d..a89de22001 100644 --- a/lms/envs/devstack.py +++ b/lms/envs/devstack.py @@ -32,6 +32,16 @@ FEATURES['ENABLE_INSTRUCTOR_EMAIL'] = True # Enable email for all Studio cou FEATURES['REQUIRE_COURSE_EMAIL_AUTH'] = False # Give all courses email (don't require django-admin perms) +########################## ANALYTICS TESTING ######################## + +ANALYTICS_SERVER_URL = "http://127.0.0.1:9000/" +ANALYTICS_API_KEY = "" + +ANALYTICS_DATA_URL = "http://127.0.0.1:8080" +ANALYTICS_DATA_TOKEN = "" +FEATURES['ENABLE_ANALYTICS_ACTIVE_COUNT'] = True + + ################################ DEBUG TOOLBAR ################################ INSTALLED_APPS += ('debug_toolbar',) diff --git a/lms/static/sass/course/instructor/_instructor_2.scss b/lms/static/sass/course/instructor/_instructor_2.scss index 96959814f0..d1c3964d93 100644 --- a/lms/static/sass/course/instructor/_instructor_2.scss +++ b/lms/static/sass/course/instructor/_instructor_2.scss @@ -766,3 +766,12 @@ section.instructor-dashboard-content-2 { input[name="subject"] { width:600px; } + +.enrollment-wrapper { + margin-bottom: $baseline * 2; + + .count { + color: green; + font-weight: bold; + } +} diff --git a/lms/templates/instructor/instructor_dashboard_2/analytics.html b/lms/templates/instructor/instructor_dashboard_2/analytics.html index b06b2c7501..44fae53dcb 100644 --- a/lms/templates/instructor/instructor_dashboard_2/analytics.html +++ b/lms/templates/instructor/instructor_dashboard_2/analytics.html @@ -15,6 +15,18 @@ +%if settings.FEATURES.get('ENABLE_ANALYTICS_ACTIVE_COUNT'): +
+

${_("Active Students")}

+ ${_("The count of students who interacted at least once by opening pages, playing videos, posting in discussions, submitting problems, or completing other activities. The date range includes all activities from midnight on the start date (inclusive) though midnight on the end date (exclusive).")} +

+ ${ section_data['active_student_count'] } + for the week of (${ section_data['active_student_count_start'] } - ${ section_data['active_student_count_end'] }) +
+%endif + +
+ %if settings.FEATURES['ENABLE_INSTRUCTOR_ANALYTICS']: