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
4d4e3931
Commit
4d4e3931
authored
Aug 20, 2014
by
dragonfi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add server side reset handler
parent
27dcf96e
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
2 deletions
+24
-2
drag_and_drop_v2/drag_and_drop_v2.py
+4
-0
tests/test_drag_and_drop_v2.py
+20
-2
No files found.
drag_and_drop_v2/drag_and_drop_v2.py
View file @
4d4e3931
...
@@ -205,6 +205,10 @@ class DragAndDropBlock(XBlock):
...
@@ -205,6 +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
def
reset
(
self
,
request
,
suffix
=
''
):
self
.
item_state
=
{}
def
_is_finished
(
self
):
def
_is_finished
(
self
):
"""All items are at their correct place"""
"""All items are at their correct place"""
tot_items
=
sum
(
1
for
i
in
self
.
data
[
'items'
]
if
i
[
'zone'
]
!=
'none'
)
tot_items
=
sum
(
1
for
i
in
self
.
data
[
'items'
]
if
i
[
'zone'
]
!=
'none'
)
...
...
tests/test_drag_and_drop_v2.py
View file @
4d4e3931
...
@@ -11,8 +11,8 @@ from workbench.runtime import WorkbenchRuntime
...
@@ -11,8 +11,8 @@ from workbench.runtime import WorkbenchRuntime
from
xblock.runtime
import
KvsFieldData
,
DictKeyValueStore
from
xblock.runtime
import
KvsFieldData
,
DictKeyValueStore
from
nose.tools
import
(
from
nose.tools
import
(
assert_equals
,
assert_true
,
assert_
in
,
assert_equals
,
assert_true
,
assert_
false
,
assert_regexp_matches
assert_
in
,
assert_
regexp_matches
)
)
import
drag_and_drop_v2
import
drag_and_drop_v2
...
@@ -155,3 +155,21 @@ def test_ajax():
...
@@ -155,3 +155,21 @@ def test_ajax():
get_data
=
json
.
loads
(
block
.
handle
(
'get_data'
,
Mock
())
.
body
)
get_data
=
json
.
loads
(
block
.
handle
(
'get_data'
,
Mock
())
.
body
)
assert_equals
(
expected
,
get_data
)
assert_equals
(
expected
,
get_data
)
def
test_ajax_solve_and_reset
():
block
=
make_block
()
assert_false
(
block
.
completed
)
assert_equals
(
block
.
item_state
,
{})
data
=
json
.
dumps
({
"val"
:
0
,
"zone"
:
"Zone A"
,
"top"
:
"11px"
,
"left"
:
"111px"
})
block
.
handle
(
'do_attempt'
,
make_request
(
data
))
data
=
json
.
dumps
({
"val"
:
1
,
"zone"
:
"Zone B"
,
"top"
:
"22px"
,
"left"
:
"222px"
})
block
.
handle
(
'do_attempt'
,
make_request
(
data
))
assert_true
(
block
.
completed
)
assert_equals
(
block
.
item_state
,
{
0
:(
"11px"
,
"111px"
),
1
:(
"22px"
,
"222px"
)})
block
.
handle
(
'reset'
,
make_request
(
""
))
assert_true
(
block
.
completed
)
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