Commit d5c3b58d by Vik Paruchuri

Change reset and next problem code

parent 406d6c0c
......@@ -176,12 +176,35 @@ class CombinedOpenEndedModule(XModule):
def update_task_states_ajax(self,return_html):
changed=self.update_task_states()
if changed:
return_html=self.get_html()
#return_html=self.get_html()
pass
return return_html
def handle_ajax(self, dispatch, get):
return_html = self.current_task.handle_ajax(dispatch,get, self.system)
return self.update_task_states_ajax(return_html)
"""
This is called by courseware.module_render, to handle an AJAX call.
"get" is request.POST.
Returns a json dictionary:
{ 'progress_changed' : True/False,
'progress': 'none'/'in_progress'/'done',
<other request-specific values here > }
"""
handlers = {
'next_problem': self.next_problem,
'reset': self.reset,
}
if dispatch not in handlers:
return_html = self.current_task.handle_ajax(dispatch,get, self.system)
return self.update_task_states_ajax(return_html)
def next_problem(self):
pass
def reset(self):
pass
def get_instance_state(self):
"""
......
......@@ -8,7 +8,7 @@ class @CombinedOpenEnded
@reset_button = @$('.reset-button')
@reset_button.click @reset
@combined_open_ended= @$('.combined-open-ended')
# valid states: 'initial', 'assessing', 'request_hint', 'done'
# valid states: 'initial', 'assessing', 'post_assessment', 'done'
# Where to put the rubric once we load it
@el = $(element).find('section.open-ended-child')
......@@ -46,7 +46,7 @@ class @CombinedOpenEnded
@answer_area.attr("disabled", true)
@submit_button.prop('value', 'Submit assessment')
@submit_button.click @save_assessment
else if @child_state == 'request_hint'
else if @child_state == 'post_assessment'
@answer_area.attr("disabled", true)
@submit_button.prop('value', 'Submit hint')
@submit_button.click @save_hint
......@@ -88,7 +88,7 @@ class @CombinedOpenEnded
if response.success
@child_state = response.state
if @child_state == 'request_hint'
if @child_state == 'post_assessment'
@hint_wrapper.html(response.hint_html)
@find_hint_elements()
else if @child_state == 'done'
......@@ -104,7 +104,7 @@ class @CombinedOpenEnded
save_hint: (event) =>
event.preventDefault()
if @child_state == 'request_hint'
if @child_state == 'post_assessment'
data = {'hint' : @hint_area.val()}
$.postWithPrefix "#{@ajax_url}/save_hint", data, (response) =>
......@@ -135,4 +135,22 @@ class @CombinedOpenEnded
else
@errors_area.html(response.error)
else
@errors_area.html('Problem state got out of sync. Try reloading the page.')
next_problem (event) =>
event.preventDefault()
@errors_area.html('Problem state got out of sync. Try reloading the page.')
if @child_state == 'done'
$.postWithPrefix "#{@ajax_url}/next_problem", {}, (response) =>
if response.success
@answer_area.val('')
@rubric_wrapper.html('')
@hint_wrapper.html('')
@message_wrapper.html('')
@child_state = 'initial'
@rebind()
@reset_button.hide()
else
@errors_area.html(response.error)
else
@errors_area.html('Problem state got out of sync. Try reloading the page.')
\ No newline at end of file
......@@ -58,7 +58,7 @@ class SelfAssessmentModule():
# states
INITIAL = 'initial'
ASSESSING = 'assessing'
REQUEST_HINT = 'request_hint'
REQUEST_HINT = 'post_assessment'
DONE = 'done'
def __init__(self, system, location, definition, descriptor,
......
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