Commit 697e426c by Vik Paruchuri

Switch to passing through entire task state

parent 2924bd2f
...@@ -142,7 +142,7 @@ class CombinedOpenEndedModule(XModule): ...@@ -142,7 +142,7 @@ class CombinedOpenEndedModule(XModule):
self.child_descriptor = descriptors[version_index](self.system) self.child_descriptor = descriptors[version_index](self.system)
self.child_definition = descriptors[version_index].definition_from_xml(etree.fromstring(self.data), self.system) self.child_definition = descriptors[version_index].definition_from_xml(etree.fromstring(self.data), self.system)
self.child_module = modules[version_index](self.system, location, self.child_definition, self.child_descriptor, self.child_module = modules[version_index](self.system, location, self.child_definition, self.child_descriptor,
instance_state = instance_state, static_data= static_data) instance_state = instance_state, static_data= static_data, model_data=model_data)
def get_html(self): def get_html(self):
return self.child_module.get_html() return self.child_module.get_html()
...@@ -156,8 +156,8 @@ class CombinedOpenEndedModule(XModule): ...@@ -156,8 +156,8 @@ class CombinedOpenEndedModule(XModule):
def get_score(self): def get_score(self):
return self.child_module.get_score() return self.child_module.get_score()
def max_score(self): #def max_score(self):
return self.child_module.max_score() # return self.child_module.max_score()
def get_progress(self): def get_progress(self):
return self.child_module.get_progress() return self.child_module.get_progress()
......
...@@ -78,7 +78,7 @@ class CombinedOpenEndedV1Module(): ...@@ -78,7 +78,7 @@ class CombinedOpenEndedV1Module():
DONE = 'done' DONE = 'done'
def __init__(self, system, location, definition, descriptor, def __init__(self, system, location, definition, descriptor,
instance_state=None, shared_state=None, metadata = None, static_data = None, **kwargs): instance_state=None, shared_state=None, metadata = None, static_data = None, model_data=None,**kwargs):
""" """
Definition file should have one or many task blocks, a rubric block, and a prompt block: Definition file should have one or many task blocks, a rubric block, and a prompt block:
...@@ -115,8 +115,8 @@ class CombinedOpenEndedV1Module(): ...@@ -115,8 +115,8 @@ class CombinedOpenEndedV1Module():
""" """
self._model_data = model_data
self.instance_state = instance_state self.instance_state = instance_state
log.debug(instance_state)
self.display_name = instance_state.get('display_name', "Open Ended") self.display_name = instance_state.get('display_name', "Open Ended")
self.rewrite_content_links = static_data.get('rewrite_content_links',"") self.rewrite_content_links = static_data.get('rewrite_content_links',"")
...@@ -233,7 +233,9 @@ class CombinedOpenEndedV1Module(): ...@@ -233,7 +233,9 @@ class CombinedOpenEndedV1Module():
current_task_state = None current_task_state = None
if len(self.task_states) > self.current_task_number: if len(self.task_states) > self.current_task_number:
current_task_state = self.task_states[self.current_task_number] current_task_state = self.task_states[self.current_task_number]
model_data = self._model_data['task_states'][self.current_task_number]
log.debug(model_data)
self.current_task_xml = self.task_xml[self.current_task_number] self.current_task_xml = self.task_xml[self.current_task_number]
if self.current_task_number > 0: if self.current_task_number > 0:
...@@ -272,7 +274,7 @@ class CombinedOpenEndedV1Module(): ...@@ -272,7 +274,7 @@ class CombinedOpenEndedV1Module():
}) })
self.current_task = child_task_module(self.system, self.location, self.current_task = child_task_module(self.system, self.location,
self.current_task_parsed_xml, self.current_task_descriptor, self.static_data, self.current_task_parsed_xml, self.current_task_descriptor, self.static_data,
instance_state=current_task_state) instance_state=self.instance_state, model_data = self._model_data, task_number = self.current_task_number)
self.task_states.append(self.current_task.get_instance_state()) self.task_states.append(self.current_task.get_instance_state())
self.state = self.ASSESSING self.state = self.ASSESSING
else: else:
...@@ -280,7 +282,7 @@ class CombinedOpenEndedV1Module(): ...@@ -280,7 +282,7 @@ class CombinedOpenEndedV1Module():
current_task_state = self.overwrite_state(current_task_state) current_task_state = self.overwrite_state(current_task_state)
self.current_task = child_task_module(self.system, self.location, self.current_task = child_task_module(self.system, self.location,
self.current_task_parsed_xml, self.current_task_descriptor, self.static_data, self.current_task_parsed_xml, self.current_task_descriptor, self.static_data,
instance_state=current_task_state) instance_state=self.instance_state, model_data = self._model_data, task_number = self.current_task_number)
return True return True
...@@ -393,7 +395,7 @@ class CombinedOpenEndedV1Module(): ...@@ -393,7 +395,7 @@ class CombinedOpenEndedV1Module():
task_parsed_xml = task_descriptor.definition_from_xml(etree_xml, self.system) task_parsed_xml = task_descriptor.definition_from_xml(etree_xml, self.system)
task = children['modules'][task_type](self.system, self.location, task_parsed_xml, task_descriptor, task = children['modules'][task_type](self.system, self.location, task_parsed_xml, task_descriptor,
self.static_data, instance_state=task_state) self.static_data, instance_state=task_state, model_data = self._model_data)
last_response = task.latest_answer() last_response = task.latest_answer()
last_score = task.latest_score() last_score = task.latest_score()
last_post_assessment = task.latest_post_assessment(self.system) last_post_assessment = task.latest_post_assessment(self.system)
......
...@@ -96,7 +96,7 @@ class CombinedOpenEndedRubric(object): ...@@ -96,7 +96,7 @@ class CombinedOpenEndedRubric(object):
log.error(error_message) log.error(error_message)
raise RubricParsingError(error_message) raise RubricParsingError(error_message)
if total != max_score: if int(total) != int(max_score):
#This is a staff_facing_error #This is a staff_facing_error
error_msg = "The max score {0} for problem {1} does not match the total number of points in the rubric {2}. Contact the learning sciences group for assistance.".format( error_msg = "The max score {0} for problem {1} does not match the total number of points in the rubric {2}. Contact the learning sciences group for assistance.".format(
max_score, location, total) max_score, location, total)
......
...@@ -65,7 +65,7 @@ class OpenEndedChild(object): ...@@ -65,7 +65,7 @@ class OpenEndedChild(object):
} }
def __init__(self, system, location, definition, descriptor, static_data, def __init__(self, system, location, definition, descriptor, static_data,
instance_state=None, shared_state=None, **kwargs): instance_state=None, shared_state=None, model_data=None, task_number = None, **kwargs):
# Load instance state # Load instance state
if instance_state is not None: if instance_state is not None:
instance_state = json.loads(instance_state) instance_state = json.loads(instance_state)
...@@ -76,13 +76,19 @@ class OpenEndedChild(object): ...@@ -76,13 +76,19 @@ class OpenEndedChild(object):
# None for any element, and score and hint can be None for the last (current) # None for any element, and score and hint can be None for the last (current)
# element. # element.
# Scores are on scale from 0 to max_score # Scores are on scale from 0 to max_score
self.history = instance_state.get('history', []) self._model_data = model_data
task_state = {}
if task_number is not None:
self.task_number = task_number
if instance_state is not None:
task_state =
self.state = instance_state.get('state', self.INITIAL) instance_state['task_states'][task_number]['history']
instance_state['task_states'][task_number]['state']', self.INITIAL)
self.created = instance_state.get('created', False) self.created = task_state.get('created', False)
self.attempts = instance_state.get('attempts', 0) self.attempts = task_state.get('attempts', 0)
self.max_attempts = static_data['max_attempts'] self.max_attempts = static_data['max_attempts']
self.prompt = static_data['prompt'] self.prompt = static_data['prompt']
......
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