Use the publish() api from xblock.runtime.Runtime
This commit is contained in:
@@ -838,11 +838,14 @@ class CapaMixin(CapaFields):
|
||||
Publishes the student's current grade to the system as an event
|
||||
"""
|
||||
score = self.lcp.get_score()
|
||||
self.runtime.publish({
|
||||
'event_name': 'grade',
|
||||
'value': score['score'],
|
||||
'max_value': score['total'],
|
||||
})
|
||||
self.runtime.publish(
|
||||
self,
|
||||
{
|
||||
'event_name': 'grade',
|
||||
'value': score['score'],
|
||||
'max_value': score['total'],
|
||||
}
|
||||
)
|
||||
|
||||
return {'grade': score['score'], 'max_grade': score['total']}
|
||||
|
||||
|
||||
@@ -510,7 +510,8 @@ oauth_consumer_key="", oauth_signature="frVp4JuvT1mVXlxktiAUjQ7%2F1cw%3D"'}
|
||||
|
||||
if action == 'replaceResultRequest':
|
||||
self.system.publish(
|
||||
event={
|
||||
self,
|
||||
{
|
||||
'event_name': 'grade',
|
||||
'value': score * self.max_score(),
|
||||
'max_value': self.max_score(),
|
||||
|
||||
@@ -988,12 +988,15 @@ class DescriptorSystem(ConfigurableFragmentWrapper, Runtime): # pylint: disable
|
||||
# global function that the application can override.
|
||||
return descriptor_global_handler_url(block, handler_name, suffix, query, thirdparty)
|
||||
|
||||
def resources_url(self, resource):
|
||||
def resource_url(self, resource):
|
||||
raise NotImplementedError("edX Platform doesn't currently implement XBlock resource urls")
|
||||
|
||||
def local_resource_url(self, block, uri):
|
||||
raise NotImplementedError("edX Platform doesn't currently implement XBlock resource urls")
|
||||
|
||||
def publish(self, block, event):
|
||||
raise NotImplementedError("edX Platform doesn't currently implement XBlock publish")
|
||||
|
||||
|
||||
class XMLParsingSystem(DescriptorSystem):
|
||||
def __init__(self, process_xml, **kwargs):
|
||||
@@ -1101,10 +1104,8 @@ class ModuleSystem(ConfigurableFragmentWrapper, Runtime): # pylint: disable=abs
|
||||
self.course_id = course_id
|
||||
self.user_is_staff = user is not None and user.is_staff
|
||||
|
||||
if publish is None:
|
||||
publish = lambda e: None
|
||||
|
||||
self.publish = publish
|
||||
if publish:
|
||||
self.publish = publish
|
||||
|
||||
self.open_ended_grading_interface = open_ended_grading_interface
|
||||
self.s3_interface = s3_interface
|
||||
@@ -1143,12 +1144,15 @@ class ModuleSystem(ConfigurableFragmentWrapper, Runtime): # pylint: disable=abs
|
||||
def get_block(self, block_id):
|
||||
raise NotImplementedError("XModules must use get_module to load other modules")
|
||||
|
||||
def resources_url(self, resource):
|
||||
def resource_url(self, resource):
|
||||
raise NotImplementedError("edX Platform doesn't currently implement XBlock resource urls")
|
||||
|
||||
def local_resource_url(self, block, uri):
|
||||
raise NotImplementedError("edX Platform doesn't currently implement XBlock resource urls")
|
||||
|
||||
def publish(self, block, event):
|
||||
pass
|
||||
|
||||
|
||||
class DoNothingCache(object):
|
||||
"""A duck-compatible object to use in ModuleSystem when there's no cache."""
|
||||
|
||||
Reference in New Issue
Block a user