Commit 07638440 by Brian Wilson

rename testcenter_exam to timed_exam, and read duration from metadata (policy.json)

parent 9b3d7efb
...@@ -301,7 +301,7 @@ def index(request, course_id, chapter=None, section=None, ...@@ -301,7 +301,7 @@ def index(request, course_id, chapter=None, section=None,
@login_required @login_required
@ensure_csrf_cookie @ensure_csrf_cookie
@cache_control(no_cache=True, no_store=True, must_revalidate=True) @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, Displays only associated content. If course, chapter,
and section are all specified, renders the page, or returns an error if they 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): ...@@ -387,20 +387,27 @@ def testcenter_exam(request, course_id, chapter, section):
# they don't have access to. # they don't have access to.
raise Http404 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) # instance_module = get_instance_module(course_id, request.user, chapter_module, student_module_cache)
# save_child_position(chapter_module, section, instance_module) # save_child_position(chapter_module, section, instance_module)
context['content'] = section_module.get_html() 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, # 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 # 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. # 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... # This value should be UTC time as number of milliseconds since epoch.
context['end_date'] = (time() + 600) * 1000 context['end_date'] = (time() + duration) * 1000
result = render_to_response('courseware/testcenter_exam.html', context) result = render_to_response('courseware/testcenter_exam.html', context)
except Exception as e: except Exception as e:
......
...@@ -67,7 +67,8 @@ ...@@ -67,7 +67,8 @@
return ( num < 10 ? "0" : "" ) + num; 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 endTime = new Date(${end_date});
var currentTime = new Date(); var currentTime = new Date();
var remaining_secs = Math.floor((endTime - currentTime)/1000); var remaining_secs = Math.floor((endTime - currentTime)/1000);
......
...@@ -217,9 +217,9 @@ if settings.COURSEWARE_ENABLED: ...@@ -217,9 +217,9 @@ if settings.COURSEWARE_ENABLED:
url(r'^courses/(?P<course_id>[^/]+/[^/]+/[^/]+)/about$', url(r'^courses/(?P<course_id>[^/]+/[^/]+/[^/]+)/about$',
'courseware.views.course_about', name="about_course"), 'courseware.views.course_about', name="about_course"),
# testcenter exam: # timed exam:
url(r'^courses/(?P<course_id>[^/]+/[^/]+/[^/]+)/testcenter_exam/(?P<chapter>[^/]*)/(?P<section>[^/]*)/$', url(r'^courses/(?P<course_id>[^/]+/[^/]+/[^/]+)/timed_exam/(?P<chapter>[^/]*)/(?P<section>[^/]*)/$',
'courseware.views.testcenter_exam', name="testcenter_exam"), 'courseware.views.timed_exam', name="timed_exam"),
#Inside the course #Inside the course
url(r'^courses/(?P<course_id>[^/]+/[^/]+/[^/]+)/$', url(r'^courses/(?P<course_id>[^/]+/[^/]+/[^/]+)/$',
......
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