Commit f131b867 by Vik Paruchuri

Handle multiple chained submissions

parent f3ca5f45
...@@ -115,8 +115,7 @@ class CombinedOpenEndedModule(XModule): ...@@ -115,8 +115,7 @@ class CombinedOpenEndedModule(XModule):
elif current_task_state is None and self.current_task_number>0: elif current_task_state is None and self.current_task_number>0:
last_response, last_score=self.get_last_response(self.current_task_number-1) last_response, last_score=self.get_last_response(self.current_task_number-1)
current_task_state = ('{"state": "assessing", "version": 1, "max_score": ' + str(self._max_score) + ', ' + current_task_state = ('{"state": "assessing", "version": 1, "max_score": ' + str(self._max_score) + ', ' +
'"attempts": 0, "history": [{"answer": "' + str(last_response) + '"}]}') '"attempts": 0, "created": True, "history": [{"answer": "' + str(last_response) + '"}]}')
{"state": "done", "version": 1, "max_score": 1, "attempts": 1, "history": [{"answer": "gdgddg", "score": 0, "hint": "dfdfdf"}]}
self.current_task=self_assessment_module.SelfAssessmentModule(self.system, self.location, self.current_task_parsed_xml, self.current_task_descriptor, instance_state=current_task_state) self.current_task=self_assessment_module.SelfAssessmentModule(self.system, self.location, self.current_task_parsed_xml, self.current_task_descriptor, instance_state=current_task_state)
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
...@@ -131,9 +130,8 @@ class CombinedOpenEndedModule(XModule): ...@@ -131,9 +130,8 @@ class CombinedOpenEndedModule(XModule):
self.state=self.ASSESSING self.state=self.ASSESSING
elif current_task_state is None and self.current_task_number>0: elif current_task_state is None and self.current_task_number>0:
last_response, last_score=self.get_last_response(self.current_task_number-1) last_response, last_score=self.get_last_response(self.current_task_number-1)
current_task_state = ('{"state": "initial", "version": 1, "max_score": ' + str(self._max_score) + ', ' + current_task_state = ('{"state": "assessing", "version": 1, "max_score": ' + str(self._max_score) + ', ' +
'"attempts": 0, "history": [{"answer": "' + str(last_response) + '"}]}') '"attempts": 0, "created": True, "history": [{"answer": "' + str(last_response) + '"}]}')
{"state": "done", "version": 1, "max_score": 1, "attempts": 1, "history": [{"answer": "gdgddg", "score": 0, "hint": "dfdfdf"}]}
self.current_task=open_ended_module.OpenEndedModule(self.system, self.location, self.current_task_parsed_xml, self.current_task_descriptor, instance_state=current_task_state) self.current_task=open_ended_module.OpenEndedModule(self.system, self.location, self.current_task_parsed_xml, self.current_task_descriptor, instance_state=current_task_state)
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
......
...@@ -116,6 +116,14 @@ class OpenEndedModule(): ...@@ -116,6 +116,14 @@ class OpenEndedModule():
self.state = instance_state.get('state', 'initial') self.state = instance_state.get('state', 'initial')
self.created = instance_state.get('created', False)
if self.created and self.state == self.ASSESSING:
self.created=False
self.get_score(self.latest_answer(), system)
self.created=False
self.attempts = instance_state.get('attempts', 0) self.attempts = instance_state.get('attempts', 0)
self.max_attempts = int(instance_state.get('attempts', MAX_ATTEMPTS)) self.max_attempts = int(instance_state.get('attempts', MAX_ATTEMPTS))
...@@ -532,11 +540,7 @@ class OpenEndedModule(): ...@@ -532,11 +540,7 @@ class OpenEndedModule():
return self.out_of_sync_error(get) return self.out_of_sync_error(get)
# add new history element with answer and empty score and hint. # add new history element with answer and empty score and hint.
if(len(self.history)>0):
if(len(self.history[-1].keys())>1):
self.new_history_entry(get['student_answer']) self.new_history_entry(get['student_answer'])
else:
get['student_answer']=self.latest_answer()
self.get_score(get['student_answer'], system) self.get_score(get['student_answer'], system)
self.change_state(self.ASSESSING) self.change_state(self.ASSESSING)
...@@ -583,6 +587,7 @@ class OpenEndedModule(): ...@@ -583,6 +587,7 @@ class OpenEndedModule():
'state': self.state, 'state': self.state,
'max_score': self._max_score, 'max_score': self._max_score,
'attempts': self.attempts, 'attempts': self.attempts,
'created' : self.created,
} }
return json.dumps(state) return json.dumps(state)
......
...@@ -107,6 +107,8 @@ class SelfAssessmentModule(): ...@@ -107,6 +107,8 @@ class SelfAssessmentModule():
# 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.history = instance_state.get('history', [])
self.created = instance_state.get('created', False)
self.state = instance_state.get('state', 'initial') self.state = instance_state.get('state', 'initial')
self.attempts = instance_state.get('attempts', 0) self.attempts = instance_state.get('attempts', 0)
...@@ -489,6 +491,7 @@ class SelfAssessmentModule(): ...@@ -489,6 +491,7 @@ class SelfAssessmentModule():
'state': self.state, 'state': self.state,
'max_score': self._max_score, 'max_score': self._max_score,
'attempts': self.attempts, 'attempts': self.attempts,
'created' : self.created,
} }
return json.dumps(state) return json.dumps(state)
......
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