Commit 9261a3e6 by Carlos Andrés Rocha

Merge pull request #4234 from rocha/rocha/analytics-active-count

Get active student count from new analytics data API
parents 5d37ea83 36cfe7ab
......@@ -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
......
......@@ -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")
......
......@@ -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
......
......@@ -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',)
......
......@@ -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;
}
}
......@@ -15,6 +15,18 @@
</div>
</script>
%if settings.FEATURES.get('ENABLE_ANALYTICS_ACTIVE_COUNT'):
<div class="enrollment-wrapper" style="margin-bottom: 40px;">
<h2>${_("Active Students")}</h2>
<span class="tip">${_("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).")}</span>
<br/><br/>
<span style="color: green;"><b>${ section_data['active_student_count'] }</b></span>
for the week of (${ section_data['active_student_count_start'] } - ${ section_data['active_student_count_end'] })
</div>
%endif
<hr>
%if settings.FEATURES['ENABLE_INSTRUCTOR_ANALYTICS']:
<script type="text/template" id="grade-distributions-widget-template">
<div class="grade-distributions-widget">
......@@ -42,18 +54,24 @@
</div>
%endif
<hr>
<div class="profile-distribution-widget-container"
data-title="${_("Year of Birth")}"
data-feature="year_of_birth"
data-endpoint="${ section_data['get_distribution_url'] }"
></div>
<hr>
<div class="profile-distribution-widget-container"
data-title="${_("Gender Distribution")}"
data-feature="gender"
data-endpoint="${ section_data['get_distribution_url'] }"
></div>
<hr>
<div class="profile-distribution-widget-container"
data-title="${_("Level of Education")}"
data-feature="level_of_education"
......
......@@ -23,6 +23,7 @@
-e git+https://github.com/edx/js-test-tool.git@v0.1.5#egg=js_test_tool
-e git+https://github.com/edx/django-waffle.git@823a102e48#egg=django-waffle
-e git+https://github.com/edx/event-tracking.git@0.1.0#egg=event-tracking
-e git+https://github.com/edx/edx-analytics-api-client.git@0.1.0#egg=analytics-client
-e git+https://github.com/edx/bok-choy.git@82b4e82d79b9d4c6d087ebbfa26ea23235728e62#egg=bok_choy
-e git+https://github.com/edx-solutions/django-splash.git@9965a53c269666a30bb4e2b3f6037c138aef2a55#egg=django-splash
-e git+https://github.com/edx/acid-block.git@459aff7b63db8f2c5decd1755706c1a64fb4ebb1#egg=acid-xblock
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment