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
0eeb3981
Commit
0eeb3981
authored
Mar 05, 2016
by
Sven Marnach
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #63 from open-craft/smarnach/fix-item-images
Expand static image URLs for item background images.
parents
c1a38e41
62f09669
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 @
0eeb3981
...
...
@@ -152,6 +152,12 @@ class DragAndDropBlock(XBlock, XBlockWithSettingsMixin, ThemableXBlockMixin):
del
item
[
'feedback'
]
del
item
[
'zone'
]
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
{
...
...
drag_and_drop_v2/public/js/drag_and_drop.js
View file @
0eeb3981
...
...
@@ -857,7 +857,6 @@ function DragAndDropBlock(runtime, element, configuration) {
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
;
if
(
item
.
grabbed
!==
undefined
)
{
grabbed
=
item
.
grabbed
;
...
...
@@ -870,9 +869,9 @@ function DragAndDropBlock(runtime, element, configuration) {
xhr_active
:
(
item_user_state
&&
item_user_state
.
submitting_location
),
input
:
input
,
displayName
:
item
.
displayName
,
imageURL
:
imageURL
,
imageURL
:
i
tem
.
expandedI
mageURL
,
imageDescription
:
item
.
imageDescription
,
has_image
:
!!
imageURL
,
has_image
:
!!
i
tem
.
expandedI
mageURL
,
grabbed
:
grabbed
,
widthPercent
:
item
.
widthPercent
,
// widthPercent may be undefined (auto width)
imgNaturalWidth
:
item
.
imgNaturalWidth
,
...
...
tests/unit/data/html/config_out.json
View file @
0eeb3981
...
...
@@ -35,24 +35,28 @@
{
"displayName"
:
"<b>1</b>"
,
"imageURL"
:
""
,
"expandedImageURL"
:
""
,
"id"
:
0
,
"inputOptions"
:
false
},
{
"displayName"
:
"<i>2</i>"
,
"imageURL"
:
""
,
"expandedImageURL"
:
""
,
"id"
:
1
,
"inputOptions"
:
true
},
{
"displayName"
:
"X"
,
"imageURL"
:
""
,
"expandedImageURL"
:
""
,
"id"
:
2
,
"inputOptions"
:
false
},
{
"displayName"
:
""
,
"imageURL"
:
"http://placehold.it/100x300"
,
"expandedImageURL"
:
"http://placehold.it/100x300"
,
"id"
:
3
,
"inputOptions"
:
false
}
...
...
tests/unit/data/old/config_out.json
View file @
0eeb3981
...
...
@@ -35,6 +35,7 @@
{
"displayName"
:
"1"
,
"imageURL"
:
""
,
"expandedImageURL"
:
""
,
"id"
:
0
,
"inputOptions"
:
false
,
"size"
:
{
"height"
:
"auto"
,
"width"
:
"190px"
}
...
...
@@ -42,6 +43,7 @@
{
"displayName"
:
"2"
,
"imageURL"
:
""
,
"expandedImageURL"
:
""
,
"id"
:
1
,
"inputOptions"
:
true
,
"size"
:
{
"height"
:
"auto"
,
"width"
:
"190px"
}
...
...
@@ -49,6 +51,7 @@
{
"displayName"
:
"X"
,
"imageURL"
:
""
,
"expandedImageURL"
:
""
,
"id"
:
2
,
"inputOptions"
:
false
,
"size"
:
{
"height"
:
"100px"
,
"width"
:
"100px"
}
...
...
@@ -56,6 +59,7 @@
{
"displayName"
:
""
,
"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
,
"inputOptions"
:
false
,
"size"
:
{
"height"
:
"auto"
,
"width"
:
"190px"
}
...
...
tests/unit/data/plain/config_out.json
View file @
0eeb3981
...
...
@@ -35,24 +35,28 @@
{
"displayName"
:
"1"
,
"imageURL"
:
""
,
"expandedImageURL"
:
""
,
"id"
:
0
,
"inputOptions"
:
false
},
{
"displayName"
:
"2"
,
"imageURL"
:
""
,
"expandedImageURL"
:
""
,
"id"
:
1
,
"inputOptions"
:
true
},
{
"displayName"
:
"X"
,
"imageURL"
:
""
,
"imageURL"
:
"/static/test_url_expansion"
,
"expandedImageURL"
:
"/course/test-course/assets/test_url_expansion"
,
"id"
:
2
,
"inputOptions"
:
false
},
{
"displayName"
:
""
,
"imageURL"
:
"http://placehold.it/200x100"
,
"expandedImageURL"
:
"http://placehold.it/200x100"
,
"id"
:
3
,
"inputOptions"
:
false
}
...
...
tests/unit/data/plain/data.json
View file @
0eeb3981
...
...
@@ -51,7 +51,7 @@
"correct"
:
""
},
"zone"
:
"none"
,
"imageURL"
:
""
,
"imageURL"
:
"
/static/test_url_expansion
"
,
"id"
:
2
},
{
...
...
tests/unit/test_basics.py
View file @
0eeb3981
...
...
@@ -45,10 +45,10 @@ class BasicTests(TestCaseMixin, unittest.TestCase):
self
.
assertEqual
(
zones
,
DEFAULT_DATA
[
"zones"
])
# Items should contain no answer data:
self
.
assertEqual
(
items
,
[
{
"id"
:
0
,
"displayName"
:
"Goes to the top"
,
"imageURL"
:
""
,
"inputOptions"
:
False
},
{
"id"
:
1
,
"displayName"
:
"Goes to the middle"
,
"imageURL"
:
""
,
"inputOptions"
:
False
},
{
"id"
:
2
,
"displayName"
:
"Goes to the bottom"
,
"imageURL"
:
""
,
"inputOptions"
:
False
},
{
"id"
:
3
,
"displayName"
:
"I don't belong anywhere"
,
"imageURL"
:
""
,
"inputOptions"
:
False
},
{
"id"
:
i
,
"displayName"
:
display_name
,
"imageURL"
:
""
,
"expandedImageURL"
:
""
,
"inputOptions"
:
False
}
for
i
,
display_name
in
enumerate
(
[
"Goes to the top"
,
"Goes to the middle"
,
"Goes to the bottom"
,
"I don't belong anywhere"
]
)
])
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