Commit 68fb5c97 by Victor Shnayder

bugfixes re: button state

parent 4922ab33
...@@ -4,7 +4,7 @@ class @SelfAssessment ...@@ -4,7 +4,7 @@ class @SelfAssessment
@id = @el.data('id') @id = @el.data('id')
@ajax_url = @el.data('ajax-url') @ajax_url = @el.data('ajax-url')
@state = @el.data('state') @state = @el.data('state')
allow_reset = @el.data('allow_reset') @allow_reset = @el.data('allow_reset')
# valid states: 'initial', 'assessing', 'request_hint', 'done' # valid states: 'initial', 'assessing', 'request_hint', 'done'
# Where to put the rubric once we load it # Where to put the rubric once we load it
...@@ -14,17 +14,13 @@ class @SelfAssessment ...@@ -14,17 +14,13 @@ class @SelfAssessment
@rubric_wrapper = @$('.rubric-wrapper') @rubric_wrapper = @$('.rubric-wrapper')
@hint_wrapper = @$('.hint-wrapper') @hint_wrapper = @$('.hint-wrapper')
@message_wrapper = @$('.message-wrapper') @message_wrapper = @$('.message-wrapper')
@check_button = @$('.submit-button') @submit_button = @$('.submit-button')
@reset_button = @$('.reset-button') @reset_button = @$('.reset-button')
@reset_button.click @reset @reset_button.click @reset
@find_assessment_elements() @find_assessment_elements()
@find_hint_elements() @find_hint_elements()
if allow_reset
@reset_button.show()
else
@reset_button.hide()
@rebind() @rebind()
...@@ -34,15 +30,25 @@ class @SelfAssessment ...@@ -34,15 +30,25 @@ class @SelfAssessment
rebind: () => rebind: () =>
# rebind to the appropriate function for the current state # rebind to the appropriate function for the current state
@check_button.unbind('click') @submit_button.unbind('click')
@submit_button.show()
@reset_button.hide()
if @state == 'initial' if @state == 'initial'
@check_button.click @save_answer @submit_button.prop('value', 'Submit')
@submit_button.click @save_answer
else if @state == 'assessing' else if @state == 'assessing'
@check_button.click @save_assessment @submit_button.prop('value', 'Submit assessment')
@submit_button.click @save_assessment
else if @state == 'request_hint' else if @state == 'request_hint'
@check_button.click @save_hint @submit_button.prop('value', 'Submit hint')
@submit_button.click @save_hint
else if @state == 'done' else if @state == 'done'
@check_button.hide() @submit_button.hide()
if @allow_reset
@reset_button.show()
else
@reset_button.hide()
find_assessment_elements: -> find_assessment_elements: ->
@assessment = @$('select.assessment') @assessment = @$('select.assessment')
...@@ -90,9 +96,8 @@ class @SelfAssessment ...@@ -90,9 +96,8 @@ class @SelfAssessment
if response.success if response.success
@message_wrapper.html(response.message_html) @message_wrapper.html(response.message_html)
@state = 'done' @state = 'done'
@allow_reset = response.allow_reset
@rebind() @rebind()
if response.allow_reset
@reset_button.show()
else else
@errors_area.html(response.message) @errors_area.html(response.message)
else else
......
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