Commit ceb7b631 by Filippo Valsorda

Add grading to the mentoring XBlock

parent 544ccade
......@@ -104,6 +104,7 @@ class AnswerBlock(LightChild):
return {
'student_input': self.student_input,
'completed': self.completed,
'score': 1 if self.completed else 0,
}
@property
......
......@@ -81,6 +81,7 @@ class MCQBlock(QuestionnaireAbstractBlock):
'submission': submission,
'completed': completed,
'tips': tips,
'score': 1 if completed else 0,
}
log.debug(u'MCQ submission result: %s', result)
return result
......
......@@ -69,6 +69,7 @@ class MentoringBlock(XBlockWithLightChildren):
display_submit = Boolean(help="Allow to submit current block?", default=True, scope=Scope.content)
xml_content = String(help="XML content", default='', scope=Scope.content)
icon_class = 'problem'
has_score = True
def student_view(self, context):
fragment, named_children = self.get_children_fragment(context, view_name='mentoring_view',
......@@ -136,6 +137,12 @@ class MentoringBlock(XBlockWithLightChildren):
elif completed and self.next_step == self.url_name:
self.next_step = self.followed_by
score = sum(r[1]['score'] for r in submit_results) / float(len(submit_results))
self.runtime.publish(self, 'grade', {
'value': score,
'max_value': 1,
})
self.completed = bool(completed)
return {
'submitResults': submit_results,
......
......@@ -103,7 +103,8 @@ class MRQBlock(QuestionnaireAbstractBlock):
'choices': results,
'message': self.message,
'max_attempts': self.max_attempts,
'num_attempts': self.num_attempts
'num_attempts': self.num_attempts,
'score': sum(1.0 for r in results if r['completed']) / len(results),
}
log.debug(u'MRQ submissions result: %s', result)
......
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