Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
X
xblock-drag-and-drop-v2
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
xblock-drag-and-drop-v2
Commits
62f09669
Commit
62f09669
authored
Mar 04, 2016
by
Sven Marnach
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Expand static image URLs for item background images.
parent
c1a38e41
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
26 additions
and
9 deletions
+26
-9
drag_and_drop_v2/drag_and_drop_v2.py
+6
-0
drag_and_drop_v2/public/js/drag_and_drop.js
+2
-3
tests/unit/data/html/config_out.json
+4
-0
tests/unit/data/old/config_out.json
+4
-0
tests/unit/data/plain/config_out.json
+5
-1
tests/unit/data/plain/data.json
+1
-1
tests/unit/test_basics.py
+4
-4
No files found.
drag_and_drop_v2/drag_and_drop_v2.py
View file @
62f09669
...
@@ -152,6 +152,12 @@ class DragAndDropBlock(XBlock, XBlockWithSettingsMixin, ThemableXBlockMixin):
...
@@ -152,6 +152,12 @@ class DragAndDropBlock(XBlock, XBlockWithSettingsMixin, ThemableXBlockMixin):
del
item
[
'feedback'
]
del
item
[
'feedback'
]
del
item
[
'zone'
]
del
item
[
'zone'
]
item
[
'inputOptions'
]
=
'inputOptions'
in
item
item
[
'inputOptions'
]
=
'inputOptions'
in
item
# Fall back on "backgroundImage" to be backward-compatible.
image_url
=
item
.
get
(
'imageURL'
)
or
item
.
get
(
'backgroundImage'
)
if
image_url
:
item
[
'expandedImageURL'
]
=
self
.
_expand_static_url
(
image_url
)
else
:
item
[
'expandedImageURL'
]
=
''
return
items
return
items
return
{
return
{
...
...
drag_and_drop_v2/public/js/drag_and_drop.js
View file @
62f09669
...
@@ -857,7 +857,6 @@ function DragAndDropBlock(runtime, element, configuration) {
...
@@ -857,7 +857,6 @@ function DragAndDropBlock(runtime, element, configuration) {
input
.
class_name
=
item_user_state
.
correct_input
?
'correct'
:
'incorrect'
;
input
.
class_name
=
item_user_state
.
correct_input
?
'correct'
:
'incorrect'
;
}
}
}
}
var
imageURL
=
item
.
imageURL
||
item
.
backgroundImage
;
// Fall back on "backgroundImage" to be backward-compatible
var
grabbed
=
false
;
var
grabbed
=
false
;
if
(
item
.
grabbed
!==
undefined
)
{
if
(
item
.
grabbed
!==
undefined
)
{
grabbed
=
item
.
grabbed
;
grabbed
=
item
.
grabbed
;
...
@@ -870,9 +869,9 @@ function DragAndDropBlock(runtime, element, configuration) {
...
@@ -870,9 +869,9 @@ function DragAndDropBlock(runtime, element, configuration) {
xhr_active
:
(
item_user_state
&&
item_user_state
.
submitting_location
),
xhr_active
:
(
item_user_state
&&
item_user_state
.
submitting_location
),
input
:
input
,
input
:
input
,
displayName
:
item
.
displayName
,
displayName
:
item
.
displayName
,
imageURL
:
imageURL
,
imageURL
:
i
tem
.
expandedI
mageURL
,
imageDescription
:
item
.
imageDescription
,
imageDescription
:
item
.
imageDescription
,
has_image
:
!!
imageURL
,
has_image
:
!!
i
tem
.
expandedI
mageURL
,
grabbed
:
grabbed
,
grabbed
:
grabbed
,
widthPercent
:
item
.
widthPercent
,
// widthPercent may be undefined (auto width)
widthPercent
:
item
.
widthPercent
,
// widthPercent may be undefined (auto width)
imgNaturalWidth
:
item
.
imgNaturalWidth
,
imgNaturalWidth
:
item
.
imgNaturalWidth
,
...
...
tests/unit/data/html/config_out.json
View file @
62f09669
...
@@ -35,24 +35,28 @@
...
@@ -35,24 +35,28 @@
{
{
"displayName"
:
"<b>1</b>"
,
"displayName"
:
"<b>1</b>"
,
"imageURL"
:
""
,
"imageURL"
:
""
,
"expandedImageURL"
:
""
,
"id"
:
0
,
"id"
:
0
,
"inputOptions"
:
false
"inputOptions"
:
false
},
},
{
{
"displayName"
:
"<i>2</i>"
,
"displayName"
:
"<i>2</i>"
,
"imageURL"
:
""
,
"imageURL"
:
""
,
"expandedImageURL"
:
""
,
"id"
:
1
,
"id"
:
1
,
"inputOptions"
:
true
"inputOptions"
:
true
},
},
{
{
"displayName"
:
"X"
,
"displayName"
:
"X"
,
"imageURL"
:
""
,
"imageURL"
:
""
,
"expandedImageURL"
:
""
,
"id"
:
2
,
"id"
:
2
,
"inputOptions"
:
false
"inputOptions"
:
false
},
},
{
{
"displayName"
:
""
,
"displayName"
:
""
,
"imageURL"
:
"http://placehold.it/100x300"
,
"imageURL"
:
"http://placehold.it/100x300"
,
"expandedImageURL"
:
"http://placehold.it/100x300"
,
"id"
:
3
,
"id"
:
3
,
"inputOptions"
:
false
"inputOptions"
:
false
}
}
...
...
tests/unit/data/old/config_out.json
View file @
62f09669
...
@@ -35,6 +35,7 @@
...
@@ -35,6 +35,7 @@
{
{
"displayName"
:
"1"
,
"displayName"
:
"1"
,
"imageURL"
:
""
,
"imageURL"
:
""
,
"expandedImageURL"
:
""
,
"id"
:
0
,
"id"
:
0
,
"inputOptions"
:
false
,
"inputOptions"
:
false
,
"size"
:
{
"height"
:
"auto"
,
"width"
:
"190px"
}
"size"
:
{
"height"
:
"auto"
,
"width"
:
"190px"
}
...
@@ -42,6 +43,7 @@
...
@@ -42,6 +43,7 @@
{
{
"displayName"
:
"2"
,
"displayName"
:
"2"
,
"imageURL"
:
""
,
"imageURL"
:
""
,
"expandedImageURL"
:
""
,
"id"
:
1
,
"id"
:
1
,
"inputOptions"
:
true
,
"inputOptions"
:
true
,
"size"
:
{
"height"
:
"auto"
,
"width"
:
"190px"
}
"size"
:
{
"height"
:
"auto"
,
"width"
:
"190px"
}
...
@@ -49,6 +51,7 @@
...
@@ -49,6 +51,7 @@
{
{
"displayName"
:
"X"
,
"displayName"
:
"X"
,
"imageURL"
:
""
,
"imageURL"
:
""
,
"expandedImageURL"
:
""
,
"id"
:
2
,
"id"
:
2
,
"inputOptions"
:
false
,
"inputOptions"
:
false
,
"size"
:
{
"height"
:
"100px"
,
"width"
:
"100px"
}
"size"
:
{
"height"
:
"100px"
,
"width"
:
"100px"
}
...
@@ -56,6 +59,7 @@
...
@@ -56,6 +59,7 @@
{
{
"displayName"
:
""
,
"displayName"
:
""
,
"imageURL"
:
"http://i1.kym-cdn.com/entries/icons/square/000/006/151/tumblr_lltzgnHi5F1qzib3wo1_400.jpg"
,
"imageURL"
:
"http://i1.kym-cdn.com/entries/icons/square/000/006/151/tumblr_lltzgnHi5F1qzib3wo1_400.jpg"
,
"expandedImageURL"
:
"http://i1.kym-cdn.com/entries/icons/square/000/006/151/tumblr_lltzgnHi5F1qzib3wo1_400.jpg"
,
"id"
:
3
,
"id"
:
3
,
"inputOptions"
:
false
,
"inputOptions"
:
false
,
"size"
:
{
"height"
:
"auto"
,
"width"
:
"190px"
}
"size"
:
{
"height"
:
"auto"
,
"width"
:
"190px"
}
...
...
tests/unit/data/plain/config_out.json
View file @
62f09669
...
@@ -35,24 +35,28 @@
...
@@ -35,24 +35,28 @@
{
{
"displayName"
:
"1"
,
"displayName"
:
"1"
,
"imageURL"
:
""
,
"imageURL"
:
""
,
"expandedImageURL"
:
""
,
"id"
:
0
,
"id"
:
0
,
"inputOptions"
:
false
"inputOptions"
:
false
},
},
{
{
"displayName"
:
"2"
,
"displayName"
:
"2"
,
"imageURL"
:
""
,
"imageURL"
:
""
,
"expandedImageURL"
:
""
,
"id"
:
1
,
"id"
:
1
,
"inputOptions"
:
true
"inputOptions"
:
true
},
},
{
{
"displayName"
:
"X"
,
"displayName"
:
"X"
,
"imageURL"
:
""
,
"imageURL"
:
"/static/test_url_expansion"
,
"expandedImageURL"
:
"/course/test-course/assets/test_url_expansion"
,
"id"
:
2
,
"id"
:
2
,
"inputOptions"
:
false
"inputOptions"
:
false
},
},
{
{
"displayName"
:
""
,
"displayName"
:
""
,
"imageURL"
:
"http://placehold.it/200x100"
,
"imageURL"
:
"http://placehold.it/200x100"
,
"expandedImageURL"
:
"http://placehold.it/200x100"
,
"id"
:
3
,
"id"
:
3
,
"inputOptions"
:
false
"inputOptions"
:
false
}
}
...
...
tests/unit/data/plain/data.json
View file @
62f09669
...
@@ -51,7 +51,7 @@
...
@@ -51,7 +51,7 @@
"correct"
:
""
"correct"
:
""
},
},
"zone"
:
"none"
,
"zone"
:
"none"
,
"imageURL"
:
""
,
"imageURL"
:
"
/static/test_url_expansion
"
,
"id"
:
2
"id"
:
2
},
},
{
{
...
...
tests/unit/test_basics.py
View file @
62f09669
...
@@ -45,10 +45,10 @@ class BasicTests(TestCaseMixin, unittest.TestCase):
...
@@ -45,10 +45,10 @@ class BasicTests(TestCaseMixin, unittest.TestCase):
self
.
assertEqual
(
zones
,
DEFAULT_DATA
[
"zones"
])
self
.
assertEqual
(
zones
,
DEFAULT_DATA
[
"zones"
])
# Items should contain no answer data:
# Items should contain no answer data:
self
.
assertEqual
(
items
,
[
self
.
assertEqual
(
items
,
[
{
"id"
:
0
,
"displayName"
:
"Goes to the top"
,
"imageURL"
:
""
,
"inputOptions"
:
False
},
{
"id"
:
i
,
"displayName"
:
display_name
,
"imageURL"
:
""
,
"expandedImageURL"
:
""
,
"inputOptions"
:
False
}
{
"id"
:
1
,
"displayName"
:
"Goes to the middle"
,
"imageURL"
:
""
,
"inputOptions"
:
False
},
for
i
,
display_name
in
enumerate
(
{
"id"
:
2
,
"displayName"
:
"Goes to the bottom"
,
"imageURL"
:
""
,
"inputOptions"
:
False
},
[
"Goes to the top"
,
"Goes to the middle"
,
"Goes to the bottom"
,
"I don't belong anywhere"
]
{
"id"
:
3
,
"displayName"
:
"I don't belong anywhere"
,
"imageURL"
:
""
,
"inputOptions"
:
False
},
)
])
])
def
test_ajax_solve_and_reset
(
self
):
def
test_ajax_solve_and_reset
(
self
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment