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