Commit 4599ffbb by Chandrakant Gopalan

OC-2959 freeform and MCQ submitted values are a json and not an array

parent 681cbda7
......@@ -223,7 +223,7 @@ class AnswerBlock(SubmittingXBlockMixin, AnswerMixin, QuestionMixin, StudioEdita
The parent block is handling a student submission, including a new answer for this
block. Update accordingly.
"""
self.student_input = submission[0]['value'].strip()
self.student_input = submission['value'].strip()
self.save()
if sub_api:
......
......@@ -125,8 +125,8 @@ class MCQBlock(SubmittingXBlockMixin, StudentViewUserStateMixin, QuestionnaireAb
def submit(self, submission):
log.debug(u'Received MCQ submission: "%s"', submission)
result = self.calculate_results(submission)
self.student_choice = submission
result = self.calculate_results(submission['value'])
self.student_choice = submission['value']
log.debug(u'MCQ submission result: %s', result)
return result
......
......@@ -15,7 +15,13 @@ function AnswerBlock(runtime, element) {
},
submit: function() {
return $(':input', element).serializeArray();
var freeform_answer = $(':input', element);
if(freeform_answer.length) {
return {"value": freeform_answer.val()};
} else {
return null;
}
},
handleReview: function(result) {
......
......@@ -107,7 +107,7 @@ function MCQBlock(runtime, element) {
var checkedRadio = $('input[type=radio]:checked', element);
if(checkedRadio.length) {
return checkedRadio.val();
return {"value": checkedRadio.val()};
} else {
return null;
}
......
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