Commit 22189661 by Piotr Mitros

Minor courseware cleanups. Pushing file system refs out

parent 8989605c
......@@ -79,13 +79,14 @@ html_skip = ["numericalresponse", "customresponse", "schematicresponse", "formul
# }
class LoncapaProblem(object):
def __init__(self, fileobject, id, state=None, seed=None):
def __init__(self, fileobject, id, state=None, seed=None, system=None):
## Initialize class variables from state
self.seed = None
self.student_answers = dict()
self.correct_map = dict()
self.done = False
self.problem_id = id
self.system = system
if seed != None:
self.seed = seed
......
......@@ -78,7 +78,7 @@ class MultipleChoiceResponse(GenericResponse):
TODO: handle direction and randomize
'''
def __init__(self, xml, context):
def __init__(self, xml, context, system=None):
self.xml = xml
self.correct_choices = xml.xpath('//*[@id=$id]//choice[@correct="true"]',
id=xml.get('id'))
......@@ -134,7 +134,7 @@ class TrueFalseResponse(MultipleChoiceResponse):
class NumericalResponse(GenericResponse):
def __init__(self, xml, context):
def __init__(self, xml, context, system=None):
self.xml = xml
self.correct_answer = contextualize_text(xml.get('answer'), context)
try:
......@@ -212,7 +212,7 @@ def sympy_check2():
</customresponse>
'''
def __init__(self, xml, context):
def __init__(self, xml, context, system=None):
self.xml = xml
## CRITICAL TODO: Should cover all entrytypes
## NOTE: xpath will look at root of XML tree, not just
......@@ -256,7 +256,7 @@ class ExternalResponse(GenericResponse):
Typically used by coding problems.
'''
def __init__(self, xml, context):
def __init__(self, xml, context, system=None):
self.xml = xml
self.answer_ids = xml.xpath('//*[@id=$id]//textbox/@id|//*[@id=$id]//textline/@id',
id=xml.get('id'))
......@@ -316,7 +316,7 @@ class StudentInputError(Exception):
#-----------------------------------------------------------------------------
class FormulaResponse(GenericResponse):
def __init__(self, xml, context):
def __init__(self, xml, context, system=None):
self.xml = xml
self.correct_answer = contextualize_text(xml.get('answer'), context)
self.samples = contextualize_text(xml.get('samples'), context)
......@@ -397,7 +397,7 @@ class FormulaResponse(GenericResponse):
#-----------------------------------------------------------------------------
class SchematicResponse(GenericResponse):
def __init__(self, xml, context):
def __init__(self, xml, context, system=None):
self.xml = xml
self.answer_ids = xml.xpath('//*[@id=$id]//schematic/@id',
id=xml.get('id'))
......@@ -442,7 +442,7 @@ class ImageResponse(GenericResponse):
</imageresponse>
"""
def __init__(self, xml, context):
def __init__(self, xml, context, system=None):
self.xml = xml
self.context = context
self.ielements = xml.findall('imageinput')
......
......@@ -193,7 +193,7 @@ class Module(XModule):
seed = 1
else:
seed = None
self.lcp=LoncapaProblem(self.filestore.open(self.filename), self.item_id, state, seed = seed)
self.lcp=LoncapaProblem(self.filestore.open(self.filename), self.item_id, state, seed = seed, system=self.system)
def handle_ajax(self, dispatch, get):
'''
......@@ -300,11 +300,11 @@ class Module(XModule):
lcp_id = self.lcp.problem_id
correct_map = self.lcp.grade_answers(answers)
except StudentInputError as inst:
self.lcp = LoncapaProblem(self.filestore.open(self.filename), id=lcp_id, state=old_state)
self.lcp = LoncapaProblem(self.filestore.open(self.filename), id=lcp_id, state=old_state, system=self.system)
traceback.print_exc()
return json.dumps({'success':inst.message})
except:
self.lcp = LoncapaProblem(self.filestore.open(self.filename), id=lcp_id, state=old_state)
self.lcp = LoncapaProblem(self.filestore.open(self.filename), id=lcp_id, state=old_state, system=self.system)
traceback.print_exc()
raise
return json.dumps({'success':'Unknown Error'})
......@@ -381,7 +381,7 @@ class Module(XModule):
self.lcp.questions=dict() # Detailed info about questions in problem instance. TODO: Should be by id and not lid.
self.lcp.seed=None
self.lcp=LoncapaProblem(self.filestore.open(self.filename), self.item_id, self.lcp.get_state())
self.lcp=LoncapaProblem(self.filestore.open(self.filename), self.item_id, self.lcp.get_state(), system=self.system)
event_info['new_state']=self.lcp.get_state()
self.tracker('reset_problem', event_info)
......
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