From 1ae94ce6366f2dc00a7159a9e06d4578c262bf8d Mon Sep 17 00:00:00 2001 From: Vik Paruchuri Date: Tue, 8 Jan 2013 16:45:21 -0500 Subject: [PATCH] Hopefully allow for submission to be reset early --- .../xmodule/combined_open_ended_module.py | 33 +++++++++++++++---- .../js/src/combinedopenended/display.coffee | 11 ++++--- common/lib/xmodule/xmodule/openendedchild.py | 2 +- 3 files changed, 35 insertions(+), 11 deletions(-) diff --git a/common/lib/xmodule/xmodule/combined_open_ended_module.py b/common/lib/xmodule/xmodule/combined_open_ended_module.py index 0e9874ec4f..d31da49978 100644 --- a/common/lib/xmodule/xmodule/combined_open_ended_module.py +++ b/common/lib/xmodule/xmodule/combined_open_ended_module.py @@ -147,10 +147,11 @@ class CombinedOpenEndedModule(XModule): self.current_task_descriptor=children['descriptors'][current_task_type](self.system) etree_xml=etree.fromstring(self.current_task_xml) - min_score_to_attempt=int(etree_xml.attrib.get('min_score_to_attempt',0)) - max_score_to_attempt=int(etree_xml.attrib.get('min_score_to_attempt',self._max_score)) + if self.current_task_number>0: - last_response_data=self.get_last_response(self.current_task_number-1) + allow_reset=self.check_allow_reset() + if allow_reset: + return False self.current_task_parsed_xml=self.current_task_descriptor.definition_from_xml(etree_xml,self.system) if current_task_state is None and self.current_task_number==0: @@ -172,6 +173,17 @@ class CombinedOpenEndedModule(XModule): return True + def check_allow_reset(self): + allow_reset=False + if self.current_task_number>0: + last_response_data=self.get_last_response(self.current_task_number-1) + current_response_data=self.get_last_response(self.current_task_number) + + if current_response_data['min_score_to_attempt']>last_response_data['score'] or current_response_data['max_score_to_attempt'] if response.success @child_state = 'done' - @allow_reset = response.allow_reset @rebind() else @errors_area.html(response.error) diff --git a/common/lib/xmodule/xmodule/openendedchild.py b/common/lib/xmodule/xmodule/openendedchild.py index 4a81703919..304271c620 100644 --- a/common/lib/xmodule/xmodule/openendedchild.py +++ b/common/lib/xmodule/xmodule/openendedchild.py @@ -200,7 +200,7 @@ class OpenEndedChild(): def _allow_reset(self): """Can the module be reset?""" - return self.state == self.DONE and self.attempts < self.max_attempts + return (self.state == self.DONE and self.attempts < self.max_attempts) def max_score(self): """