Commit f2123cc8 by dragonfi

Implement partial answers for mrq

parent de56b9ea
......@@ -115,8 +115,9 @@ class MentoringBlock(XBlockWithLightChildren, StepParentMixin):
score = sum(r[1]['score'] * r[1]['weight'] for r in self.student_results) / total_child_weight
correct = sum(1 for r in self.student_results if r[1]['completed'] is True)
incorrect = sum(1 for r in self.student_results if r[1]['completed'] is False)
partially_correct = sum(1 for r in self.student_results if r[1].get('partially_completed', False) is True)
return (score, int(round(score * 100)), correct, incorrect)
return (score, int(round(score * 100)), correct, incorrect, partially_correct)
def student_view(self, context):
fragment, named_children = self.get_children_fragment(
......@@ -247,7 +248,7 @@ class MentoringBlock(XBlockWithLightChildren, StepParentMixin):
for result in submit_results:
self.student_results.append(result)
(raw_score, score, correct, incorrect) = self.score
(raw_score, score, correct, incorrect, partially_correct) = self.score
self.runtime.publish(self, 'grade', {
'value': raw_score,
'max_value': 1,
......@@ -303,10 +304,11 @@ class MentoringBlock(XBlockWithLightChildren, StepParentMixin):
self.student_results.append([child.name, child_result])
child.save()
completed = child_result['completed']
partially_completed = child_result.get('partially_completed', False)
event_data = {}
(raw_score, score, correct, incorrect) = self.score
(raw_score, score, correct, incorrect, partially_correct) = self.score
if current_child == self.steps[-1]:
log.info(u'Last assessment step submitted: {}'.format(submissions))
if not self.max_attempts_reached:
......@@ -328,13 +330,15 @@ class MentoringBlock(XBlockWithLightChildren, StepParentMixin):
return {
'completed': completed,
'partially_completed': partially_completed,
'attempted': self.attempted,
'max_attempts': self.max_attempts,
'num_attempts': self.num_attempts,
'step': self.step,
'score': score,
'correct_answer': correct,
'incorrect_answer': incorrect
'incorrect_answer': incorrect,
'partially_correct_answer': partially_correct,
}
@XBlock.json_handler
......
......@@ -49,6 +49,7 @@ class MRQBlock(QuestionnaireAbstractBlock):
log.debug(u'Received MRQ submissions: "%s"', submissions)
completed = True
partially_completed = False
score = 0
results = []
......@@ -65,6 +66,7 @@ class MRQBlock(QuestionnaireAbstractBlock):
choice_completed = False
completed = completed and choice_completed
partially_completed = partially_completed or choice_completed
if choice_completed:
score += 1
......@@ -85,9 +87,13 @@ class MRQBlock(QuestionnaireAbstractBlock):
self.student_choices = submissions
if completed:
partially_completed = False
result = {
'submissions': submissions,
'completed': completed,
'partially_completed': partially_completed,
'choices': results,
'message': self.message,
'weight': self.weight,
......
......@@ -128,6 +128,7 @@ function MentoringAssessmentView(runtime, element, mentoring) {
$('.grade', element).data('score', result.score);
$('.grade', element).data('correct_answer', result.correct_answer);
$('.grade', element).data('incorrect_answer', result.incorrect_answer);
$('.grade', element).data('partially_correct_answer', result.partially_correct_answer);
$('.grade', element).data('max_attempts', result.max_attempts);
$('.grade', element).data('num_attempts', result.num_attempts);
$('.attempts', element).data('max_attempts', result.max_attempts);
......@@ -136,6 +137,9 @@ function MentoringAssessmentView(runtime, element, mentoring) {
if (result.completed) {
checkmark.addClass('checkmark-correct icon-ok fa-check');
}
else if (result.partially_completed) {
checkmark.addClass('checkmark-partially-correct icon-ok fa-check');
}
else {
checkmark.addClass('checkmark-incorrect icon-exclamation fa-exclamation');
}
......
......@@ -21,6 +21,7 @@
<div class="grade" data-score="{{ self.score.1 }}"
data-correct_answer="{{ self.score.2 }}"
data-incorrect_answer="{{ self.score.3 }}"
data-partially_correct_answer="{{ self.score.4 }}"
data-max_attempts="{{ self.max_attempts }}"
data-num_attempts="{{ self.num_attempts }}">
</div>
......
......@@ -10,7 +10,7 @@
<span class="assessment-checkmark icon-2x checkmark-correct icon-ok fa fa-check"></span>
<p>You answered <%= correct_answer %> questions correctly.</p>
<span class="assessment-checkmark icon-2x checkmark-partially-correct icon-ok fa fa-check"></span>
<p>You answered <%= correct_answer %> questions partially correct.</p>
<p>You answered <%= partially_correct_answer %> questions partially correct.</p>
<span class="assessment-checkmark icon-2x checkmark-incorrect icon-exclamation fa fa-exclamation"></span>
<p>You answered <%= incorrect_answer %> questions incorrectly.</p>
</script>
......@@ -17,11 +17,19 @@
<choice value="yes">Yes</choice>
<choice value="maybenot">Maybe not</choice>
<choice value="understand">I don't understand</choice>
<tip display="yes">Great!</tip>
<tip reject="maybenot">Ah, damn.</tip>
<tip reject="understand"><html><div id="test-custom-html">Really?</div></html></tip>
</mcq>
<mcq name="mcq_1_2" type="rating" low="Not good at all" high="Extremely good">
<question>How much do you rate this MCQ?</question>
<choice value="notwant">I don't want to rate it</choice>
<tip display="4,5">I love good grades.</tip>
<tip reject="1,2,3">Will do better next time...</tip>
<tip reject="notwant">Your loss!</tip>
</mcq>
<mrq name="mrq_1_1" type="choices">
......@@ -30,5 +38,9 @@
<choice value="beauty">Its beauty</choice>
<choice value="gracefulness">Its gracefulness</choice>
<choice value="bugs">Its bugs</choice>
<tip require="gracefulness">This MRQ is indeed very graceful</tip>
<tip require="elegance,beauty">This is something everyone has to like about this MRQ</tip>
<tip reject="bugs">Nah, there isn't any!</tip>
</mrq>
</mentoring>
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