Commit f54d4241 by Victor Shnayder

Merge pull request #1038 from MITx/vik/add_self_assessment

Vik/add self assessment
parents b378af87 3f95116a
...@@ -21,7 +21,6 @@ class @SelfAssessment ...@@ -21,7 +21,6 @@ class @SelfAssessment
@find_assessment_elements() @find_assessment_elements()
@find_hint_elements() @find_hint_elements()
@rebind() @rebind()
# locally scoped jquery. # locally scoped jquery.
...@@ -33,16 +32,22 @@ class @SelfAssessment ...@@ -33,16 +32,22 @@ class @SelfAssessment
@submit_button.unbind('click') @submit_button.unbind('click')
@submit_button.show() @submit_button.show()
@reset_button.hide() @reset_button.hide()
@hint_area.attr('disabled', false)
if @state == 'initial' if @state == 'initial'
@answer_area.attr("disabled", false)
@submit_button.prop('value', 'Submit') @submit_button.prop('value', 'Submit')
@submit_button.click @save_answer @submit_button.click @save_answer
else if @state == 'assessing' else if @state == 'assessing'
@answer_area.attr("disabled", true)
@submit_button.prop('value', 'Submit assessment') @submit_button.prop('value', 'Submit assessment')
@submit_button.click @save_assessment @submit_button.click @save_assessment
else if @state == 'request_hint' else if @state == 'request_hint'
@answer_area.attr("disabled", true)
@submit_button.prop('value', 'Submit hint') @submit_button.prop('value', 'Submit hint')
@submit_button.click @save_hint @submit_button.click @save_hint
else if @state == 'done' else if @state == 'done'
@answer_area.attr("disabled", true)
@hint_area.attr('disabled', true)
@submit_button.hide() @submit_button.hide()
if @allow_reset if @allow_reset
@reset_button.show() @reset_button.show()
...@@ -67,7 +72,7 @@ class @SelfAssessment ...@@ -67,7 +72,7 @@ class @SelfAssessment
@find_assessment_elements() @find_assessment_elements()
@rebind() @rebind()
else else
@errors_area.html(response.message) @errors_area.html(response.error)
else else
@errors_area.html('Problem state got out of sync. Try reloading the page.') @errors_area.html('Problem state got out of sync. Try reloading the page.')
...@@ -77,12 +82,18 @@ class @SelfAssessment ...@@ -77,12 +82,18 @@ class @SelfAssessment
data = {'assessment' : @assessment.find(':selected').text()} data = {'assessment' : @assessment.find(':selected').text()}
$.postWithPrefix "#{@ajax_url}/save_assessment", data, (response) => $.postWithPrefix "#{@ajax_url}/save_assessment", data, (response) =>
if response.success if response.success
@hint_wrapper.html(response.hint_html) @state = response.state
@state = 'request_hint'
@find_hint_elements() if @state == 'request_hint'
@hint_wrapper.html(response.hint_html)
@find_hint_elements()
else if @state == 'done'
@message_wrapper.html(response.message_html)
@allow_reset = response.allow_reset
@rebind() @rebind()
else else
@errors_area.html(response.message) @errors_area.html(response.error)
else else
@errors_area.html('Problem state got out of sync. Try reloading the page.') @errors_area.html('Problem state got out of sync. Try reloading the page.')
...@@ -99,7 +110,7 @@ class @SelfAssessment ...@@ -99,7 +110,7 @@ class @SelfAssessment
@allow_reset = response.allow_reset @allow_reset = response.allow_reset
@rebind() @rebind()
else else
@errors_area.html(response.message) @errors_area.html(response.error)
else else
@errors_area.html('Problem state got out of sync. Try reloading the page.') @errors_area.html('Problem state got out of sync. Try reloading the page.')
...@@ -109,6 +120,7 @@ class @SelfAssessment ...@@ -109,6 +120,7 @@ class @SelfAssessment
if @state == 'done' if @state == 'done'
$.postWithPrefix "#{@ajax_url}/reset", {}, (response) => $.postWithPrefix "#{@ajax_url}/reset", {}, (response) =>
if response.success if response.success
@answer_area.html('')
@rubric_wrapper.html('') @rubric_wrapper.html('')
@hint_wrapper.html('') @hint_wrapper.html('')
@message_wrapper.html('') @message_wrapper.html('')
...@@ -116,6 +128,6 @@ class @SelfAssessment ...@@ -116,6 +128,6 @@ class @SelfAssessment
@rebind() @rebind()
@reset_button.hide() @reset_button.hide()
else else
@errors_area.html(response.message) @errors_area.html(response.error)
else else
@errors_area.html('Problem state got out of sync. Try reloading the page.') @errors_area.html('Problem state got out of sync. Try reloading the page.')
...@@ -262,5 +262,9 @@ section.self-assessment { ...@@ -262,5 +262,9 @@ section.self-assessment {
margin-bottom: 5px; margin-bottom: 5px;
} }
.error {
font-size: 14px;
font-weight: bold;
}
} }
...@@ -6,8 +6,9 @@ ...@@ -6,8 +6,9 @@
% if not read_only: % if not read_only:
<select name="assessment" class="assessment"> <select name="assessment" class="assessment">
<option value="incorrect">Incorrect</option> %for i in xrange(0,max_score+1):
<option value="correct">Correct</option> <option value="${i}">${i}</option>
%endfor
</select> </select>
% endif % endif
......
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