Commit 27dcf96e by dragonfi

Add completed flag to only publish the grade once

parent f0215eec
......@@ -10,7 +10,7 @@ import copy
import urllib
from xblock.core import XBlock
from xblock.fields import Scope, String, Dict, Float
from xblock.fields import Scope, String, Dict, Float, Boolean
from xblock.fragment import Fragment
from .utils import render_template, load_resource
......@@ -62,6 +62,12 @@ class DragAndDropBlock(XBlock):
default={}
)
completed = Boolean(
help="The student has completed the problem at least once",
scope=Scope.user_state,
default=False
)
has_score = True
def student_view(self, context):
......@@ -173,6 +179,9 @@ class DragAndDropBlock(XBlock):
if self._is_finished():
final_feedback = self.data['feedback']['finish']
# only publish the grade once
if not self.completed:
self.completed = True
try:
self.runtime.publish(self, 'grade', {
'value': len(self.item_state) / float(tot_items) * self.weight,
......
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