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
397266ec
Commit
397266ec
authored
Aug 20, 2014
by
dragonfi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement browser side behaviour for reset button
parent
034e3b08
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
5 deletions
+30
-5
drag_and_drop_v2/drag_and_drop_v2.py
+3
-2
drag_and_drop_v2/public/js/drag_and_drop.js
+26
-2
tests/test_drag_and_drop_v2.py
+1
-1
No files found.
drag_and_drop_v2/drag_and_drop_v2.py
View file @
397266ec
...
@@ -205,9 +205,10 @@ class DragAndDropBlock(XBlock):
...
@@ -205,9 +205,10 @@ class DragAndDropBlock(XBlock):
'feedback'
:
item
[
'feedback'
][
'correct'
]
if
is_correct
else
item
[
'feedback'
][
'incorrect'
]
'feedback'
:
item
[
'feedback'
][
'correct'
]
if
is_correct
else
item
[
'feedback'
][
'incorrect'
]
}
}
@XBlock.handler
@XBlock.
json_
handler
def
reset
(
self
,
request
,
suffix
=
''
):
def
reset
(
self
,
data
,
suffix
=
''
):
self
.
item_state
=
{}
self
.
item_state
=
{}
return
{
'result'
:
'success'
}
def
_is_finished
(
self
):
def
_is_finished
(
self
):
"""All items are at their correct place"""
"""All items are at their correct place"""
...
...
drag_and_drop_v2/public/js/drag_and_drop.js
View file @
397266ec
...
@@ -15,6 +15,7 @@ function DragAndDropBlock(runtime, element) {
...
@@ -15,6 +15,7 @@ function DragAndDropBlock(runtime, element) {
$target
:
$
(
'.xblock--drag-and-drop .target-img'
,
element
),
$target
:
$
(
'.xblock--drag-and-drop .target-img'
,
element
),
$feedback
:
$
(
'.xblock--drag-and-drop .feedback .message'
,
element
),
$feedback
:
$
(
'.xblock--drag-and-drop .feedback .message'
,
element
),
$popup
:
$
(
'.xblock--drag-and-drop .popup'
,
element
),
$popup
:
$
(
'.xblock--drag-and-drop .popup'
,
element
),
$reset_button
:
$
(
'.xblock--drag-and-drop .reset-button'
,
element
),
// Cannot set until items added to DOM
// Cannot set until items added to DOM
$items
:
{},
// $('.xblock--drag-and-drop .items .option'),
$items
:
{},
// $('.xblock--drag-and-drop .items .option'),
...
@@ -82,6 +83,15 @@ function DragAndDropBlock(runtime, element) {
...
@@ -82,6 +83,15 @@ function DragAndDropBlock(runtime, element) {
if
(
final_feedback
)
_fn
.
feedback
.
set
(
final_feedback
);
if
(
final_feedback
)
_fn
.
feedback
.
set
(
final_feedback
);
},
},
reset
:
function
()
{
_fn
.
$items
.
draggable
(
'enable'
);
_fn
.
$items
.
each
(
function
(
index
,
element
)
{
_fn
.
clickHandlers
.
drag
.
reset
(
$
(
element
));
});
_fn
.
$popup
.
hide
();
_fn
.
feedback
.
set
(
_fn
.
data
.
feedback
.
start
);
},
clickHandlers
:
{
clickHandlers
:
{
init
:
function
(
$drag
,
$dropzone
)
{
init
:
function
(
$drag
,
$dropzone
)
{
var
clk
=
_fn
.
clickHandlers
;
var
clk
=
_fn
.
clickHandlers
;
...
@@ -92,14 +102,28 @@ function DragAndDropBlock(runtime, element) {
...
@@ -92,14 +102,28 @@ function DragAndDropBlock(runtime, element) {
$dropzone
.
on
(
'drop'
,
clk
.
drop
.
success
);
$dropzone
.
on
(
'drop'
,
clk
.
drop
.
success
);
$dropzone
.
on
(
'dropover'
,
clk
.
drop
.
hover
);
$dropzone
.
on
(
'dropover'
,
clk
.
drop
.
hover
);
$
(
".close"
,
_fn
.
$popup
).
on
(
'click'
,
function
()
{
$
(
".close"
,
_fn
.
$popup
).
on
(
'click'
,
clk
.
popup
.
close
);
_fn
.
$reset_button
.
on
(
'click'
,
clk
.
problem
.
reset
);
},
problem
:
{
reset
:
function
(
event
,
ui
)
{
$
.
ajax
({
type
:
"POST"
,
url
:
runtime
.
handlerUrl
(
element
,
"reset"
),
data
:
"{}"
,
success
:
_fn
.
reset
});
}
},
popup
:
{
close
:
function
(
event
,
ui
)
{
_fn
.
$popup
.
hide
();
_fn
.
$popup
.
hide
();
publish_event
({
publish_event
({
event_type
:
'xblock.drag-and-drop-v2.feedback.closed'
,
event_type
:
'xblock.drag-and-drop-v2.feedback.closed'
,
content
:
_fn
.
$popup
.
find
(
".popup-content"
).
text
(),
content
:
_fn
.
$popup
.
find
(
".popup-content"
).
text
(),
manually
:
true
manually
:
true
});
});
}
);
}
},
},
drag
:
{
drag
:
{
start
:
function
(
event
,
ui
)
{
start
:
function
(
event
,
ui
)
{
...
...
tests/test_drag_and_drop_v2.py
View file @
397266ec
...
@@ -169,7 +169,7 @@ def test_ajax_solve_and_reset():
...
@@ -169,7 +169,7 @@ def test_ajax_solve_and_reset():
assert_true
(
block
.
completed
)
assert_true
(
block
.
completed
)
assert_equals
(
block
.
item_state
,
{
0
:(
"11px"
,
"111px"
),
1
:(
"22px"
,
"222px"
)})
assert_equals
(
block
.
item_state
,
{
0
:(
"11px"
,
"111px"
),
1
:(
"22px"
,
"222px"
)})
block
.
handle
(
'reset'
,
make_request
(
""
))
block
.
handle
(
'reset'
,
make_request
(
"
{}
"
))
assert_true
(
block
.
completed
)
assert_true
(
block
.
completed
)
assert_equals
(
block
.
item_state
,
{})
assert_equals
(
block
.
item_state
,
{})
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