Commit 07cc0cbb by dragonfi

Add component_id to events

parent 44ca8222
...@@ -195,6 +195,7 @@ class DragAndDropBlock(XBlock): ...@@ -195,6 +195,7 @@ class DragAndDropBlock(XBlock):
self.runtime.publish(self, 'xblock.drag-and-drop-v2.item.dropped', { self.runtime.publish(self, 'xblock.drag-and-drop-v2.item.dropped', {
'user_id': self.scope_ids.user_id, 'user_id': self.scope_ids.user_id,
'component_id': self._get_unique_id(),
'item_id': item['id'], 'item_id': item['id'],
'location': attempt['zone'], 'location': attempt['zone'],
'is_correct': is_correct, 'is_correct': is_correct,
...@@ -225,10 +226,19 @@ class DragAndDropBlock(XBlock): ...@@ -225,10 +226,19 @@ class DragAndDropBlock(XBlock):
return {'result': 'error', 'message': 'Missing event_type in JSON data'} return {'result': 'error', 'message': 'Missing event_type in JSON data'}
data['user_id'] = self.scope_ids.user_id data['user_id'] = self.scope_ids.user_id
data['component_id'] = self._get_unique_id()
self.runtime.publish(self, event_type, data) self.runtime.publish(self, event_type, data)
return {'result':'success'} return {'result':'success'}
def _get_unique_id(self):
try:
unique_id = self.location.name
except AttributeError:
# workaround for xblock workbench
unique_id = self.parent.replace('.', '-')
return unique_id
@staticmethod @staticmethod
def workbench_scenarios(): def workbench_scenarios():
"""A canned scenario for display in the workbench.""" """A canned scenario for display in the workbench."""
......
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