Commit e7ea2664 by Calen Pennington

Merge pull request #43 from MITx/pmitros/same-values

Courseware can have same random seed in multiple problems for exam. 
parents 5bce758b 6c681429
...@@ -222,6 +222,8 @@ class Module(XModule): ...@@ -222,6 +222,8 @@ class Module(XModule):
self.weight=only_one(dom2.xpath('/problem/@weight')) self.weight=only_one(dom2.xpath('/problem/@weight'))
if self.rerandomize == 'never': if self.rerandomize == 'never':
seed = 1 seed = 1
elif self.rerandomize == "per_student" and hasattr(system, 'id'):
seed = system.id
else: else:
seed = None seed = None
try: try:
......
...@@ -31,7 +31,7 @@ class I4xSystem(object): ...@@ -31,7 +31,7 @@ class I4xSystem(object):
functionality. functionality.
''' '''
def __init__(self, ajax_url, track_function, render_function, def __init__(self, ajax_url, track_function, render_function,
render_template, filestore=None): render_template, request=None, filestore=None):
''' '''
Create a closure around the system environment. Create a closure around the system environment.
...@@ -46,6 +46,7 @@ class I4xSystem(object): ...@@ -46,6 +46,7 @@ class I4xSystem(object):
and 'type'. and 'type'.
render_template - a function that takes (template_file, context), and returns render_template - a function that takes (template_file, context), and returns
rendered html. rendered html.
request - the request in progress
filestore - A filestore ojbect. Defaults to an instance of OSFS based at filestore - A filestore ojbect. Defaults to an instance of OSFS based at
settings.DATA_DIR. settings.DATA_DIR.
''' '''
...@@ -62,6 +63,7 @@ class I4xSystem(object): ...@@ -62,6 +63,7 @@ class I4xSystem(object):
self.render_template = render_template self.render_template = render_template
self.exception404 = Http404 self.exception404 = Http404
self.DEBUG = settings.DEBUG self.DEBUG = settings.DEBUG
self.id = request.user.id if request is not None else 0
def get(self, attr): def get(self, attr):
''' provide uniform access to attributes (like etree).''' ''' provide uniform access to attributes (like etree).'''
...@@ -169,6 +171,7 @@ def get_module(user, request, module_xml, student_module_cache, position=None): ...@@ -169,6 +171,7 @@ def get_module(user, request, module_xml, student_module_cache, position=None):
render_function = render_function, render_function = render_function,
render_template = render_to_string, render_template = render_to_string,
ajax_url = ajax_url, ajax_url = ajax_url,
request = request,
filestore = OSFS(data_root), filestore = OSFS(data_root),
) )
# pass position specified in URL to module through I4xSystem # pass position specified in URL to module through I4xSystem
...@@ -300,6 +303,7 @@ def modx_dispatch(request, module=None, dispatch=None, id=None): ...@@ -300,6 +303,7 @@ def modx_dispatch(request, module=None, dispatch=None, id=None):
render_function = None, render_function = None,
render_template = render_to_string, render_template = render_to_string,
ajax_url = ajax_url, ajax_url = ajax_url,
request = request,
filestore = OSFS(data_root), filestore = OSFS(data_root),
) )
......
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