Commit 1931c1bf by Diana Huang

Add new learner analytics djangoapp with a single view.

parent 75701b48
......@@ -2349,6 +2349,7 @@ INSTALLED_APPS = [
'openedx.features.course_search',
'openedx.features.enterprise_support.apps.EnterpriseSupportConfig',
'openedx.features.learner_profile',
'openedx.features.learner_analytics',
'experiments',
......
......@@ -679,6 +679,14 @@ urlpatterns += [
r'^u/',
include('openedx.features.learner_profile.urls'),
),
# Learner analytics dashboard
url(
r'^courses/{}/learner_analytics/'.format(
settings.COURSE_ID_PATTERN,
),
include('openedx.features.learner_analytics.urls'),
),
]
if settings.FEATURES['ENABLE_TEAMS']:
......
## mako
<%! main_css = "style-main-v2" %>
<%page expression_filter="h"/>
<%inherit file="../main.html" />
<%namespace name='static' file='../static_content.html'/>
<%def name="online_help_token()"><% return "courseware" %></%def>
<%def name="course_name()">
<% return _("{course_number} Courseware").format(course_number=course.display_number_with_default) %>
</%def>
<%!
import json
from django.utils.translation import ugettext as _
from django.template.defaultfilters import escapejs
from django_comment_client.permissions import has_permission
from openedx.core.djangolib.js_utils import dump_js_escaped_json, js_escaped_string
from openedx.core.djangolib.markup import HTML
from openedx.features.course_experience import course_home_page_title
%>
<%block name="bodyclass">course</%block>
<%block name="pagetitle">${course_name()}</%block>
<%include file="../courseware/course_navigation.html" args="active_page='courseware'" />
<%block name="head_extra">
</%block>
<%block name="footer_extra">
</%block>
<%block name="content">
<div class="course-view page-content-container" id="course-container">
<header class="page-header has-secondary">
## Breadcrumb navigation
<div class="page-header-main">
<nav aria-label="${_('Learner Analytics')}" class="sr-is-focusable" tabindex="-1">
<div class="has-breadcrumbs">
<div class="breadcrumbs">
<span class="nav-item">
<a href="${course_url}">${course_home_page_title(course)}</a>
</span>
<span class="icon fa fa-angle-right" aria-hidden="true"></span>
<span class="nav-item">${_('Learner Analytics')}</span>
</div>
</div>
</nav>
</div>
</header>
<div class="page-content">
</div>
</div>
</%block>
<%namespace name='static' file='../static_content.html'/>
from django.test import TestCase
# Create your tests here.
"""
Url setup for learner analytics
"""
from django.conf.urls import url
from views import LearnerAnalyticsView
urlpatterns = [
url(
r'^$',
LearnerAnalyticsView.as_view(),
name='openedx.learner_analytics.dashboard',
),
]
"""
Learner analytics dashboard views
"""
from django.contrib.auth.decorators import login_required
from django.template.context_processors import csrf
from django.core.urlresolvers import reverse
from django.shortcuts import render_to_response
from django.template.loader import render_to_string
from django.utils.decorators import method_decorator
from django.utils.translation import ugettext as _
from django.views.decorators.cache import cache_control
from django.views.decorators.csrf import ensure_csrf_cookie
from django.views.generic import View
from opaque_keys.edx.keys import CourseKey
from courseware.courses import get_course_with_access
from openedx.core.djangoapps.plugin_api.views import EdxFragmentView
from openedx.features.course_experience import default_course_url_name
from util.views import ensure_valid_course_key
class LearnerAnalyticsView(View):
@method_decorator(login_required)
@method_decorator(ensure_csrf_cookie)
@method_decorator(cache_control(no_cache=True, no_store=True, must_revalidate=True))
@method_decorator(ensure_valid_course_key)
def get(self, request, course_id):
"""
Displays the user's bookmarks for the specified course.
Arguments:
request: HTTP request
course_id (unicode): course id
"""
course_key = CourseKey.from_string(course_id)
course = get_course_with_access(request.user, 'load', course_key, check_if_enrolled=True)
course_url_name = default_course_url_name(course.id)
course_url = reverse(course_url_name, kwargs={'course_id': unicode(course.id)})
# Render the course bookmarks page
context = {
'csrf': csrf(request)['csrf_token'],
'course': course,
'course_url': course_url,
'disable_courseware_js': True,
'uses_pattern_library': True,
}
return render_to_response('learner_analytics/dashboard.html', context)
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