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
dfe6105d
Commit
dfe6105d
authored
Jan 13, 2016
by
Jonathan Piacenti
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix analytics events and add tests.
parent
b29dee80
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
98 additions
and
13 deletions
+98
-13
drag_and_drop_v2/public/js/drag_and_drop.js
+7
-9
setup.py
+3
-2
tests/integration/test_interaction.py
+88
-2
No files found.
drag_and_drop_v2/public/js/drag_and_drop.js
View file @
dfe6105d
...
@@ -166,14 +166,12 @@ function DragAndDropBlock(runtime, element, configuration) {
...
@@ -166,14 +166,12 @@ function DragAndDropBlock(runtime, element, configuration) {
var
applyState
=
function
()
{
var
applyState
=
function
()
{
// Has the feedback popup been closed?
// Has the feedback popup been closed?
if
(
state
.
closing
)
{
if
(
state
.
closing
)
{
if
(
previousFeedback
)
{
publishEvent
({
publishEvent
({
event_type
:
'xblock.drag-and-drop-v2.feedback.closed'
,
event_type
:
'xblock.drag-and-drop-v2.feedback.closed'
,
content
:
previousFeedback
||
state
.
feedback
,
content
:
previousFeedback
,
manually
:
state
.
manually_closed
,
manually
:
state
.
manually_closed
,
});
});
previousFeedback
=
undefined
;
previousFeedback
=
undefined
;
}
}
}
// Has feedback been set?
// Has feedback been set?
if
(
state
.
feedback
)
{
if
(
state
.
feedback
)
{
...
@@ -478,8 +476,8 @@ function DragAndDropBlock(runtime, element, configuration) {
...
@@ -478,8 +476,8 @@ function DragAndDropBlock(runtime, element, configuration) {
state
.
manually_closed
=
false
;
state
.
manually_closed
=
false
;
}
}
delete
state
.
feedback
;
applyState
();
applyState
();
delete
state
.
feedback
;
};
};
var
resetExercise
=
function
(
evt
)
{
var
resetExercise
=
function
(
evt
)
{
...
...
setup.py
View file @
dfe6105d
...
@@ -29,9 +29,10 @@ setup(
...
@@ -29,9 +29,10 @@ setup(
install_requires
=
[
install_requires
=
[
'XBlock'
,
'XBlock'
,
'xblock-utils'
,
'xblock-utils'
,
'ddt'
'ddt'
,
'mock'
,
],
],
dependency_links
=
[
'http://github.com/edx/xblock-utils/tarball/master#egg=xblock-utils'
],
dependency_links
=
[
'http://github.com/edx/xblock-utils/tarball/master#egg=xblock-utils'
],
entry_points
=
{
entry_points
=
{
'xblock.v1'
:
'drag-and-drop-v2 = drag_and_drop_v2:DragAndDropBlock'
,
'xblock.v1'
:
'drag-and-drop-v2 = drag_and_drop_v2:DragAndDropBlock'
,
},
},
...
...
tests/integration/test_interaction.py
View file @
dfe6105d
from
ddt
import
ddt
,
data
from
ddt
import
ddt
,
data
from
mock
import
Mock
,
patch
from
selenium.common.exceptions
import
NoSuchElementException
from
selenium.common.exceptions
import
NoSuchElementException
from
selenium.webdriver
import
ActionChains
from
selenium.webdriver
import
ActionChains
from
selenium.webdriver.common.keys
import
Keys
from
selenium.webdriver.common.keys
import
Keys
from
workbench.runtime
import
WorkbenchRuntime
from
drag_and_drop_v2.default_data
import
(
from
drag_and_drop_v2.default_data
import
(
TOP_ZONE_TITLE
,
MIDDLE_ZONE_TITLE
,
BOTTOM_ZONE_TITLE
,
TOP_ZONE_TITLE
,
MIDDLE_ZONE_TITLE
,
BOTTOM_ZONE_TITLE
,
ITEM_CORRECT_FEEDBACK
,
ITEM_INCORRECT_FEEDBACK
,
ITEM_NO_ZONE_FEEDBACK
,
ITEM_CORRECT_FEEDBACK
,
ITEM_INCORRECT_FEEDBACK
,
ITEM_NO_ZONE_FEEDBACK
,
...
@@ -287,9 +290,9 @@ class InteractionTestBase(object):
...
@@ -287,9 +290,9 @@ class InteractionTestBase(object):
self
.
assertTrue
(
dialog_modal
.
is_displayed
())
self
.
assertTrue
(
dialog_modal
.
is_displayed
())
class
BasicInteractionTest
(
InteractionTestBase
):
class
DefaultDataTestMixin
(
object
):
"""
"""
Testing interactions with Drag and Drop XBlock against default data. If default data changes this will break
.
Provides a test scenario with default options
.
"""
"""
PAGE_TITLE
=
'Drag and Drop v2'
PAGE_TITLE
=
'Drag and Drop v2'
PAGE_ID
=
'drag_and_drop_v2'
PAGE_ID
=
'drag_and_drop_v2'
...
@@ -317,6 +320,11 @@ class BasicInteractionTest(InteractionTestBase):
...
@@ -317,6 +320,11 @@ class BasicInteractionTest(InteractionTestBase):
def
_get_scenario_xml
(
self
):
# pylint: disable=no-self-use
def
_get_scenario_xml
(
self
):
# pylint: disable=no-self-use
return
"<vertical_demo><drag-and-drop-v2/></vertical_demo>"
return
"<vertical_demo><drag-and-drop-v2/></vertical_demo>"
class
BasicInteractionTest
(
DefaultDataTestMixin
,
InteractionTestBase
):
"""
Testing interactions with Drag and Drop XBlock against default data. If default data changes this will break.
"""
def
test_item_positive_feedback_on_good_move
(
self
):
def
test_item_positive_feedback_on_good_move
(
self
):
self
.
parameterized_item_positive_feedback_on_good_move
(
self
.
items_map
)
self
.
parameterized_item_positive_feedback_on_good_move
(
self
.
items_map
)
...
@@ -336,6 +344,84 @@ class BasicInteractionTest(InteractionTestBase):
...
@@ -336,6 +344,84 @@ class BasicInteractionTest(InteractionTestBase):
self
.
interact_with_keyboard_help
()
self
.
interact_with_keyboard_help
()
class
EventsFiredTest
(
DefaultDataTestMixin
,
InteractionTestBase
,
BaseIntegrationTest
):
def
setUp
(
self
):
mock
=
Mock
()
context
=
patch
.
object
(
WorkbenchRuntime
,
'publish'
,
mock
)
context
.
start
()
self
.
addCleanup
(
context
.
stop
)
self
.
publish
=
mock
super
(
EventsFiredTest
,
self
)
.
setUp
()
def
_get_scenario_xml
(
self
):
# pylint: disable=no-self-use
return
"<vertical_demo><drag-and-drop-v2/></vertical_demo>"
def
test_loaded
(
self
):
dummy
,
name
,
data
=
self
.
publish
.
call_args
[
0
]
self
.
assertEqual
(
name
,
'xblock.drag-and-drop-v2.loaded'
)
self
.
assertEqual
(
data
,
{
'component_id'
:
u'drag-and-drop-v2.drag-and-drop-v2.d0.u0'
,
'user_id'
:
'student_1'
}
)
def
test_picked_up
(
self
):
self
.
parameterized_item_positive_feedback_on_good_move
(
self
.
items_map
)
dummy
,
name
,
data
=
self
.
publish
.
call_args_list
[
1
][
0
]
self
.
assertEqual
(
name
,
'xblock.drag-and-drop-v2.item.picked-up'
)
self
.
assertEqual
(
data
,
{
'component_id'
:
u'drag-and-drop-v2.drag-and-drop-v2.d0.u0'
,
'user_id'
:
'student_1'
,
'item_id'
:
0
,
}
)
def
test_dropped
(
self
):
self
.
parameterized_item_positive_feedback_on_good_move
(
self
.
items_map
)
# Skipping to 3, since 2 is grade event.
dummy
,
name
,
data
=
self
.
publish
.
call_args_list
[
3
][
0
]
self
.
assertEqual
(
name
,
'xblock.drag-and-drop-v2.item.dropped'
)
self
.
assertEqual
(
data
,
{
'component_id'
:
u'drag-and-drop-v2.drag-and-drop-v2.d0.u0'
,
'input'
:
None
,
'is_correct'
:
True
,
'is_correct_location'
:
True
,
'item_id'
:
0
,
'location'
:
u'The Top Zone'
,
'user_id'
:
'student_1'
,
}
)
def
test_feedback_opened
(
self
):
self
.
parameterized_item_positive_feedback_on_good_move
(
self
.
items_map
)
dummy
,
name
,
data
=
self
.
publish
.
call_args_list
[
4
][
0
]
self
.
assertEqual
(
name
,
'xblock.drag-and-drop-v2.feedback.opened'
)
self
.
assertEqual
(
data
,
{
'component_id'
:
u'drag-and-drop-v2.drag-and-drop-v2.d0.u0'
,
'content'
:
u'Correct! This one belongs to The Top Zone.'
,
'user_id'
:
'student_1'
,
}
)
def
test_feedback_closed
(
self
):
self
.
parameterized_item_positive_feedback_on_good_move
(
self
.
items_map
)
dummy
,
name
,
data
=
self
.
publish
.
call_args_list
[
5
][
0
]
self
.
assertEqual
(
name
,
'xblock.drag-and-drop-v2.feedback.closed'
)
self
.
assertEqual
(
data
,
{
'component_id'
:
u'drag-and-drop-v2.drag-and-drop-v2.d0.u0'
,
'user_id'
:
'student_1'
,
'manually'
:
False
,
'content'
:
u'Correct! This one belongs to The Top Zone.'
,
}
)
@ddt
@ddt
class
KeyboardInteractionTest
(
BasicInteractionTest
,
BaseIntegrationTest
):
class
KeyboardInteractionTest
(
BasicInteractionTest
,
BaseIntegrationTest
):
@data
(
Keys
.
RETURN
,
Keys
.
SPACE
,
Keys
.
CONTROL
+
'm'
,
Keys
.
COMMAND
+
'm'
)
@data
(
Keys
.
RETURN
,
Keys
.
SPACE
,
Keys
.
CONTROL
+
'm'
,
Keys
.
COMMAND
+
'm'
)
...
...
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