Commit 0ff439f2 by Xavier Antoviaque

Merge pull request #15 from dragonfi/reintroduce-user-id

Use scope_ids.user_id instead of runtime.user_id
parents 95664d4a 07cc0cbb
...@@ -194,7 +194,8 @@ class DragAndDropBlock(XBlock): ...@@ -194,7 +194,8 @@ class DragAndDropBlock(XBlock):
pass pass
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.runtime.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,
...@@ -224,11 +225,20 @@ class DragAndDropBlock(XBlock): ...@@ -224,11 +225,20 @@ class DragAndDropBlock(XBlock):
except KeyError as e: except KeyError as e:
return {'result': 'error', 'message': 'Missing event_type in JSON data'} return {'result': 'error', 'message': 'Missing event_type in JSON data'}
data['user_id'] = self.runtime.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