diff --git a/common/lib/xmodule/xmodule/combined_open_ended_module.py b/common/lib/xmodule/xmodule/combined_open_ended_module.py index 58d0cd4560..a57bf965d0 100644 --- a/common/lib/xmodule/xmodule/combined_open_ended_module.py +++ b/common/lib/xmodule/xmodule/combined_open_ended_module.py @@ -131,6 +131,7 @@ class CombinedOpenEndedModule(XModule): 'items': [{'content' : task_html}], 'ajax_url': self.system.ajax_url, 'allow_reset': True, + 'state' : self.state, } html = self.system.render_template('combined_open_ended.html', context) @@ -201,12 +202,32 @@ class CombinedOpenEndedModule(XModule): return self.update_task_states_ajax(return_html) def next_problem(self): - pass + self.setup_next_task() + return {'success' : True} def reset(self): - pass + """ + If resetting is allowed, reset the state. - def get_instance_state(self): + Returns {'success': bool, 'error': msg} + (error only present if not success) + """ + if self.state != self.DONE: + return self.out_of_sync_error(get) + + if self.attempts > self.max_attempts: + return { + 'success': False, + 'error': 'Too many attempts.' + } + self.state=self.INITIAL + self.current_task_number=0 + self.setup_next_task() + self.current_task.reset(self.system) + return {'success': True} + + +def get_instance_state(self): """ Get the current score and state """ diff --git a/common/lib/xmodule/xmodule/js/src/combinedopenended/display.coffee b/common/lib/xmodule/xmodule/js/src/combinedopenended/display.coffee index 0e8cadd69f..eab904b0a4 100644 --- a/common/lib/xmodule/xmodule/js/src/combinedopenended/display.coffee +++ b/common/lib/xmodule/xmodule/js/src/combinedopenended/display.coffee @@ -59,6 +59,7 @@ class @CombinedOpenEnded @submit_button.hide() if !@state == 'done' @next_problem_button.show() + if @state == 'done' if @allow_reset @reset_button.show() else @@ -127,7 +128,7 @@ class @CombinedOpenEnded reset: (event) => event.preventDefault() @errors_area.html('Problem state got out of sync. Try reloading the page.') - if @child_state == 'done' + if @state == 'done' $.postWithPrefix "#{@ajax_url}/reset", {}, (response) => if response.success @answer_area.val('') @@ -142,7 +143,7 @@ class @CombinedOpenEnded else @errors_area.html('Problem state got out of sync. Try reloading the page.') - next_problem (event) => + next_problem: (event) => event.preventDefault() @errors_area.html('Problem state got out of sync. Try reloading the page.') if @child_state == 'done' diff --git a/common/lib/xmodule/xmodule/self_assessment_module.py b/common/lib/xmodule/xmodule/self_assessment_module.py index cba13c7e54..c1c568af2f 100644 --- a/common/lib/xmodule/xmodule/self_assessment_module.py +++ b/common/lib/xmodule/xmodule/self_assessment_module.py @@ -459,7 +459,7 @@ class SelfAssessmentModule(): 'allow_reset': self._allow_reset()} - def reset(self, get, system): + def reset(self, system): """ If resetting is allowed, reset the state. diff --git a/lms/templates/combined_open_ended.html b/lms/templates/combined_open_ended.html index 51afddcd15..a00d5b042f 100644 --- a/lms/templates/combined_open_ended.html +++ b/lms/templates/combined_open_ended.html @@ -1,4 +1,4 @@ -
+
% for item in items:
${item['content'] | n}