Commit f549076f by Diana Huang

Initial data put onto the page.

parent 06eeeeec
...@@ -46,6 +46,7 @@ from openedx.features.course_experience import course_home_page_title ...@@ -46,6 +46,7 @@ from openedx.features.course_experience import course_home_page_title
</span> </span>
<span class="icon fa fa-angle-right" aria-hidden="true"></span> <span class="icon fa fa-angle-right" aria-hidden="true"></span>
<span class="nav-item">${_('Learner Analytics')}</span> <span class="nav-item">${_('Learner Analytics')}</span>
</div> </div>
</div> </div>
</nav> </nav>
...@@ -61,6 +62,8 @@ from openedx.features.course_experience import course_home_page_title ...@@ -61,6 +62,8 @@ from openedx.features.course_experience import course_home_page_title
} }
)} )}
</div> </div>
<p>${assignment_grades}</p>
<p>${assignment_schedule}</p>
</div> </div>
</div> </div>
</%block> </%block>
......
""" """
Learner analytics dashboard views Learner analytics dashboard views
""" """
import json
from django.contrib.auth.decorators import login_required from django.contrib.auth.decorators import login_required
from django.template.context_processors import csrf from django.template.context_processors import csrf
...@@ -8,15 +9,17 @@ from django.core.urlresolvers import reverse ...@@ -8,15 +9,17 @@ from django.core.urlresolvers import reverse
from django.shortcuts import render_to_response from django.shortcuts import render_to_response
from django.template.loader import render_to_string from django.template.loader import render_to_string
from django.utils.decorators import method_decorator 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.cache import cache_control
from django.views.decorators.csrf import ensure_csrf_cookie from django.views.decorators.csrf import ensure_csrf_cookie
from django.views.generic import View from django.views.generic import View
from opaque_keys.edx.keys import CourseKey from opaque_keys.edx.keys import CourseKey
from courseware.courses import get_course_with_access from lms.djangoapps.course_api.blocks.api import get_blocks
from lms.djangoapps.courseware.courses import get_course_with_access
from lms.djangoapps.grades.course_grade_factory import CourseGradeFactory
from openedx.core.djangoapps.plugin_api.views import EdxFragmentView from openedx.core.djangoapps.plugin_api.views import EdxFragmentView
from openedx.features.course_experience import default_course_url_name from openedx.features.course_experience import default_course_url_name
from xmodule.modulestore.django import modulestore
from util.views import ensure_valid_course_key from util.views import ensure_valid_course_key
...@@ -46,5 +49,39 @@ class LearnerAnalyticsView(View): ...@@ -46,5 +49,39 @@ class LearnerAnalyticsView(View):
'course_url': course_url, 'course_url': course_url,
'disable_courseware_js': True, 'disable_courseware_js': True,
'uses_pattern_library': True, 'uses_pattern_library': True,
'grading_policy': course.grading_policy,
'assignment_grades': self.get_grade_data(request.user, course_key),
'assignment_schedule': self.get_schedule(request, course_key)
} }
return render_to_response('learner_analytics/dashboard.html', context) return render_to_response('learner_analytics/dashboard.html', context)
def get_grade_data(self, user, course_key):
"""
Collects and formats the grade data to be piped to the front end.
Args:
user: User
course_key: CourseKey
"""
course_grade = CourseGradeFactory().read(user, course_key=course_key)
return course_grade.subsection_grades
def get_schedule(self, request, course_key):
"""
Get the schedule of graded assignments in the course.
Args:
request: HttpRequest
course_key: CourseKey
"""
course_usage_key = modulestore().make_course_usage_key(course_key)
all_blocks = get_blocks(
request,
course_usage_key,
user=request.user,
nav_depth=3,
requested_fields=['display_name', 'due', 'graded', 'format'],
block_types_filter=['sequential']
)
return all_blocks
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