Commit 819de86c by Eugeny Kolpakov

Merge pull request #39 from open-craft/multiple_blocks_on_page

Support for multiple DnD blocks on the same page
parents 6c1d71ca 3419e2e6
...@@ -421,12 +421,12 @@ class DragAndDropBlock(XBlock): ...@@ -421,12 +421,12 @@ class DragAndDropBlock(XBlock):
return {'result': 'success'} return {'result': 'success'}
def _get_unique_id(self): def _get_unique_id(self):
usage_id = self.scope_ids.usage_id
try: try:
unique_id = self.location.name # pylint: disable=no-member return usage_id.name
except AttributeError: except AttributeError:
# workaround for xblock workbench # workaround for xblock workbench
unique_id = self.parent and self.parent.replace('.', '-') return usage_id
return unique_id
@staticmethod @staticmethod
def _is_correct_input(item, val): def _is_correct_input(item, val):
......
...@@ -160,9 +160,9 @@ function DragAndDropBlock(runtime, element, configuration) { ...@@ -160,9 +160,9 @@ function DragAndDropBlock(runtime, element, configuration) {
$root.find('.item-bank .option').not('[data-drag-disabled=true]').each(function() { $root.find('.item-bank .option').not('[data-drag-disabled=true]').each(function() {
try { try {
$(this).draggable({ $(this).draggable({
containment: '.xblock--drag-and-drop .drag-container', containment: $root.find('.xblock--drag-and-drop .drag-container'),
cursor: 'move', cursor: 'move',
stack: '.xblock--drag-and-drop .item-bank .option', stack: $root.find('.xblock--drag-and-drop .item-bank .option'),
revert: 'invalid', revert: 'invalid',
revertDuration: 150, revertDuration: 150,
start: function(evt, ui) { start: function(evt, ui) {
......
File mode changed from 100644 to 100755
...@@ -56,7 +56,7 @@ ...@@ -56,7 +56,7 @@
} }
], ],
"feedback": { "feedback": {
"start": "Other Intro Feed", "start": "Some Intro Feed",
"finish": "Other Final Feed" "finish": "Some Final Feed"
} }
} }
{
"zones": [
{
"index": 1,
"width": 200,
"title": "Zone 51",
"height": 100,
"y": "400",
"x": "200",
"id": "zone-51"
},
{
"index": 2,
"width": 200,
"title": "Zone 52",
"height": 100,
"y": "200",
"x": "100",
"id": "zone-52"
}
],
"items": [
{
"displayName": "Item 1",
"feedback": {
"incorrect": "Incorrect 1",
"correct": "Correct 1"
},
"zone": "Zone 51",
"backgroundImage": "",
"id": 10
},
{
"displayName": "Item 2",
"feedback": {
"incorrect": "Incorrect 2",
"correct": "Correct 2"
},
"zone": "Zone 52",
"backgroundImage": "",
"id": 20,
"inputOptions": {
"value": 100,
"margin": 5
}
},
{
"displayName": "X",
"feedback": {
"incorrect": "No Zone for this",
"correct": ""
},
"zone": "none",
"backgroundImage": "",
"id": 30
}
],
"feedback": {
"start": "Other Intro Feed",
"finish": "Other Final Feed"
}
}
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