Commit cb899cb7 by Xavier Antoviaque

Merge pull request #11 from FiloSottile/grading

Add grading capabilities to mentoring blocks
parents 544ccade ff373b3a
......@@ -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
......
......@@ -30,7 +30,7 @@ from lxml import etree
from StringIO import StringIO
from xblock.core import XBlock
from xblock.fields import Boolean, Scope, String
from xblock.fields import Boolean, Scope, String, Float
from xblock.fragment import Fragment
from .light_children import XBlockWithLightChildren
......@@ -68,7 +68,9 @@ class MentoringBlock(XBlockWithLightChildren):
default=False, scope=Scope.content)
display_submit = Boolean(help="Allow to submit current block?", default=True, scope=Scope.content)
xml_content = String(help="XML content", default='', scope=Scope.content)
weight = Float(help="Defines the maximum total grade of the block.", default=0, 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 +138,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