From 07638440ac93d63893ea2d0b3a67f799bfeb1596 Mon Sep 17 00:00:00 2001 From: Brian Wilson Date: Thu, 31 Jan 2013 18:33:22 -0500 Subject: [PATCH] rename testcenter_exam to timed_exam, and read duration from metadata (policy.json) --- lms/djangoapps/courseware/views.py | 17 ++++++++++++----- lms/templates/courseware/testcenter_exam.html | 3 ++- lms/urls.py | 6 +++--- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/lms/djangoapps/courseware/views.py b/lms/djangoapps/courseware/views.py index c7838156cb..1ac7cebd4b 100644 --- a/lms/djangoapps/courseware/views.py +++ b/lms/djangoapps/courseware/views.py @@ -301,7 +301,7 @@ def index(request, course_id, chapter=None, section=None, @login_required @ensure_csrf_cookie @cache_control(no_cache=True, no_store=True, must_revalidate=True) -def testcenter_exam(request, course_id, chapter, section): +def timed_exam(request, course_id, chapter, section): """ Displays only associated content. If course, chapter, and section are all specified, renders the page, or returns an error if they @@ -387,20 +387,27 @@ def testcenter_exam(request, course_id, chapter, section): # they don't have access to. raise Http404 - # Save where we are in the chapter + # Save where we are in the chapter NOT! # instance_module = get_instance_module(course_id, request.user, chapter_module, student_module_cache) # save_child_position(chapter_module, section, instance_module) context['content'] = section_module.get_html() - # figure out when the exam should end. Going forward, this is determined by getting a "normal" + # figure out when the timed exam should end. Going forward, this is determined by getting a "normal" # duration from the test, then doing some math to modify the duration based on accommodations, # and then use that value as the end. Once we have calculated this, it should be sticky -- we # use the same value for future requests, unless it's a tester. + + # get value for duration from the section's metadata: + if 'duration' not in section_descriptor.metadata: + raise Http404 + + # for now, assume that the duration is set as an integer value, indicating the number of seconds: + duration = int(section_descriptor.metadata.get('duration')) - # Let's try 600s for now... - context['end_date'] = (time() + 600) * 1000 + # This value should be UTC time as number of milliseconds since epoch. + context['end_date'] = (time() + duration) * 1000 result = render_to_response('courseware/testcenter_exam.html', context) except Exception as e: diff --git a/lms/templates/courseware/testcenter_exam.html b/lms/templates/courseware/testcenter_exam.html index 66adfefcff..638778f7cd 100644 --- a/lms/templates/courseware/testcenter_exam.html +++ b/lms/templates/courseware/testcenter_exam.html @@ -67,7 +67,8 @@ return ( num < 10 ? "0" : "" ) + num; } - // set the end time when the template is rendered + // set the end time when the template is rendered. + // This value should be UTC time as number of milliseconds since epoch. var endTime = new Date(${end_date}); var currentTime = new Date(); var remaining_secs = Math.floor((endTime - currentTime)/1000); diff --git a/lms/urls.py b/lms/urls.py index 2c5db07d00..021079333a 100644 --- a/lms/urls.py +++ b/lms/urls.py @@ -217,9 +217,9 @@ if settings.COURSEWARE_ENABLED: url(r'^courses/(?P[^/]+/[^/]+/[^/]+)/about$', 'courseware.views.course_about', name="about_course"), - # testcenter exam: - url(r'^courses/(?P[^/]+/[^/]+/[^/]+)/testcenter_exam/(?P[^/]*)/(?P
[^/]*)/$', - 'courseware.views.testcenter_exam', name="testcenter_exam"), + # timed exam: + url(r'^courses/(?P[^/]+/[^/]+/[^/]+)/timed_exam/(?P[^/]*)/(?P
[^/]*)/$', + 'courseware.views.timed_exam', name="timed_exam"), #Inside the course url(r'^courses/(?P[^/]+/[^/]+/[^/]+)/$',