Commit 254eae03 by Vik Paruchuri

Add in support for passing problem type to javascript

parent 3a6c660b
......@@ -25,6 +25,7 @@ class @CombinedOpenEnded
@message_wrapper = @$('.message-wrapper')
@submit_button = @$('.submit-button')
@child_state = @el.data('state')
@child_type = @el.data('child-type')
@open_ended_child= @$('.open-ended-child')
......@@ -54,7 +55,7 @@ class @CombinedOpenEnded
@submit_button.click @save_assessment
else if @child_state == 'post_assessment'
@answer_area.attr("disabled", true)
@submit_button.prop('value', 'Submit hint')
@submit_button.prop('value', 'Submit post-assessment')
@submit_button.click @save_hint
else if @child_state == 'done'
@answer_area.attr("disabled", true)
......@@ -74,7 +75,8 @@ class @CombinedOpenEnded
@assessment = @$('select.assessment')
find_hint_elements: ->
@hint_area = @$('textarea.hint')
@hint_area = @$('textarea.post_assessment')
@hint_box = @$('')
save_answer: (event) =>
event.preventDefault()
......@@ -118,7 +120,7 @@ class @CombinedOpenEnded
if @child_state == 'post_assessment'
data = {'hint' : @hint_area.val()}
$.postWithPrefix "#{@ajax_url}/save_hint", data, (response) =>
$.postWithPrefix "#{@ajax_url}/save_post_assessment", data, (response) =>
if response.success
@message_wrapper.html(response.message_html)
@child_state = 'done'
......@@ -164,4 +166,33 @@ class @CombinedOpenEnded
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
@errors_area.html('Problem state got out of sync. Try reloading the page.')
message_post: =>
Logger.log 'message_post', @answers
fd = new FormData()
feedback = @$('section.evaluation textarea.feedback-on-feedback')[0].value
submission_id = $('div.external-grader-message div.submission_id')[0].innerHTML
grader_id = $('div.external-grader-message div.grader_id')[0].innerHTML
score = $(".evaluation-scoring input:radio[name='evaluation-score']:checked").val()
fd.append('feedback', feedback)
fd.append('submission_id', submission_id)
fd.append('grader_id', grader_id)
if(!score)
@gentle_alert "You need to pick a rating before you can submit."
return
else
fd.append('score', score)
settings =
type: "POST"
data: fd
processData: false
contentType: false
success: (response) =>
@gentle_alert response.message
@$('section.evaluation').slideToggle()
$.ajaxWithPrefix("#{@url}/message_post", settings)
\ No newline at end of file
......@@ -485,7 +485,7 @@ class OpenEndedModule():
'problem_reset': self.reset_problem,
'save_answer': self.save_answer,
'score_update': self.update_score,
'message_post' : self.message_post,
'save_post_assessment' : self.message_post,
}
if dispatch not in handlers:
......@@ -624,6 +624,7 @@ class OpenEndedModule():
'hidden' : '',
'id' : 'open_ended',
'msg' : self.latest_feedback(),
'child_type' : 'openended',
}
html = system.render_template('open_ended.html', context)
......
......@@ -235,6 +235,7 @@ class SelfAssessmentModule():
'initial_message': self.get_message_html(),
'state': self.state,
'allow_reset': self._allow_reset(),
'child_type' : 'selfassessment',
}
html = system.render_template('self_assessment_prompt.html', context)
......@@ -281,7 +282,7 @@ class SelfAssessmentModule():
handlers = {
'save_answer': self.save_answer,
'save_assessment': self.save_assessment,
'save_hint': self.save_hint,
'save_post_assessment': self.save_hint,
'reset': self.reset,
}
......
<section id="openended_${id}" class="open-ended-child" data-state="${state}">
<section id="openended_${id}" class="open-ended-child" data-state="${state}" data-child-type="${child_type}">
<div class="error"></div>
<div class="prompt">
......@@ -35,7 +35,7 @@
% endif
<div class="external-grader-message">
${msg|n}
% if state == 'done':
% if state == 'post_assessment':
<div class="collapsible evaluation-response">
<header>
<a href="#">Respond to Feedback</a>
......@@ -53,9 +53,6 @@
</div>
<p>Additional comments:</p>
<textarea rows="${rows}" cols="${cols}" name="feedback_${id}" class="feedback-on-feedback" id="feedback_${id}"></textarea>
<div class="submit-message-container">
<input name="submit-message" class="submit-message" type="button" value="Submit your message"/>
</div>
</section>
</div>
% endif
......
......@@ -2,6 +2,6 @@
<div class="hint-prompt">
${hint_prompt}
</div>
<textarea name="hint" class="hint" cols="70" rows="5"
<textarea name="post_assessment" class="post_assessment" cols="70" rows="5"
${'readonly="true"' if read_only else ''}>${hint}</textarea>
</div>
<section id="self_assessment_${id}" class="open-ended-child" data-ajax-url="${ajax_url}"
data-id="${id}" data-state="${state}" data-allow_reset="${allow_reset}">
data-id="${id}" data-state="${state}" data-allow_reset="${allow_reset}" data-child-type="${child_type}">
<div class="error"></div>
<div class="prompt">
${prompt}
......
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