Commit b4d9d42a by Piotr Mitros

Better testability

parent c6444920
...@@ -61,16 +61,18 @@ class DoneXBlock(XBlock): ...@@ -61,16 +61,18 @@ class DoneXBlock(XBlock):
with one boolean field: `done`. This will save this in the with one boolean field: `done`. This will save this in the
XBlock field, and then issue an appropriate grade. XBlock field, and then issue an appropriate grade.
""" """
self.done = data['done'] if 'done' in data:
if data['done']: self.done = data['done']
grade = 1 if data['done']:
else: grade = 1
grade = 0 else:
grade = 0
self.runtime.publish(self, 'grade', {'value': grade, 'max_value': 1}) grade_event = {'value': grade, 'max_value': 1}
# Above should emit a similar event. Once it does, we should be self.runtime.publish(self, 'grade', grade_event)
# able to eliminate this # This should move to self.runtime.publish, once that pipeline
tracker.emit("edx.done.toggle", {'done': self.done}) # is finished for XBlocks.
tracker.emit("edx.done.toggle", {'done': self.done})
return {'state': self.done} return {'state': self.done}
def student_view(self, context=None): # pylint: disable=unused-argument def student_view(self, context=None): # pylint: disable=unused-argument
......
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