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
0684dd4e
Commit
0684dd4e
authored
Jan 14, 2016
by
Jonathan Piacenti
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Address Analytics notes.
parent
7c14fb8f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
14 deletions
+33
-14
drag_and_drop_v2/drag_and_drop_v2.py
+1
-1
drag_and_drop_v2/public/js/drag_and_drop.js
+25
-8
tests/integration/test_interaction.py
+7
-5
No files found.
drag_and_drop_v2/drag_and_drop_v2.py
View file @
0684dd4e
...
...
@@ -287,7 +287,7 @@ class DragAndDropBlock(XBlock, XBlockWithSettingsMixin, ThemableXBlockMixin):
# so we have to figure that we're running in Studio for now
pass
self
.
runtime
.
publish
(
self
,
'
xblock.drag-and-drop-
v2.item.dropped'
,
{
self
.
runtime
.
publish
(
self
,
'
edx.drag_and_drop_
v2.item.dropped'
,
{
'user_id'
:
self
.
scope_ids
.
user_id
,
'component_id'
:
self
.
_get_unique_id
(),
'item_id'
:
item
[
'id'
],
...
...
drag_and_drop_v2/public/js/drag_and_drop.js
View file @
0684dd4e
...
...
@@ -19,6 +19,9 @@ function DragAndDropBlock(runtime, element, configuration) {
var
TAB
=
9
;
var
M
=
77
;
// Event string size limit.
var
MAX_LENGTH
=
255
;
var
placementMode
=
false
;
var
$selectedItem
;
var
$focusedElement
;
...
...
@@ -57,7 +60,7 @@ function DragAndDropBlock(runtime, element, configuration) {
$element
.
on
(
'click'
,
'.submit-input'
,
submitInput
);
// Indicate that exercise is done loading
publishEvent
({
event_type
:
'
xblock.drag-and-drop-
v2.loaded'
});
publishEvent
({
event_type
:
'
edx.drag_and_drop_
v2.loaded'
});
}).
fail
(
function
()
{
$root
.
text
(
gettext
(
"An error occurred. Unable to load drag and drop exercise."
));
});
...
...
@@ -84,6 +87,15 @@ function DragAndDropBlock(runtime, element, configuration) {
}
};
var
truncateField
=
function
(
data
,
fieldName
){
if
(
data
[
fieldName
].
length
>
MAX_LENGTH
)
{
data
[
fieldName
]
=
data
[
fieldName
].
substring
(
0
,
MAX_LENGTH
);
data
[
'truncated'
]
=
true
;
}
else
{
data
[
'truncated'
]
=
false
;
}
};
var
focusModalButton
=
function
()
{
$root
.
find
(
'.keyboard-help-dialog .modal-dismiss-button '
).
focus
();
};
...
...
@@ -162,19 +174,24 @@ function DragAndDropBlock(runtime, element, configuration) {
var
applyState
=
function
()
{
// Has the feedback popup been closed?
if
(
state
.
closing
)
{
publishEvent
(
{
event_type
:
'
xblock.drag-and-drop-
v2.feedback.closed'
,
var
data
=
{
event_type
:
'
edx.drag_and_drop_
v2.feedback.closed'
,
content
:
previousFeedback
||
state
.
feedback
,
manually
:
state
.
manually_closed
,
});
};
truncateField
(
data
,
'content'
);
publishEvent
(
data
);
previousFeedback
=
undefined
;
delete
state
.
closing
;
}
// Has feedback been set?
if
(
state
.
feedback
)
{
publishEvent
(
{
event_type
:
'
xblock.drag-and-drop-
v2.feedback.opened'
,
var
data
=
{
event_type
:
'
edx.drag_and_drop_
v2.feedback.opened'
,
content
:
state
.
feedback
,
});
};
truncateField
(
data
,
'content'
);
publishEvent
(
data
);
}
updateDOM
();
...
...
@@ -329,7 +346,7 @@ function DragAndDropBlock(runtime, element, configuration) {
var
$item
=
$
(
this
);
grabItem
(
$item
);
publishEvent
({
event_type
:
'
xblock.drag-and-drop-v2.item.picked-
up'
,
event_type
:
'
edx.drag_and_drop_v2.item.picked_
up'
,
item_id
:
$item
.
data
(
'value'
),
});
},
...
...
tests/integration/test_interaction.py
View file @
0684dd4e
...
...
@@ -381,7 +381,7 @@ class EventsFiredTest(DefaultDataTestMixin, InteractionTestBase, BaseIntegration
def
test_loaded
(
self
):
dummy
,
name
,
data
=
self
.
publish
.
call_args
[
0
]
self
.
assertEqual
(
name
,
'
xblock.drag-and-drop-
v2.loaded'
)
self
.
assertEqual
(
name
,
'
edx.drag_and_drop_
v2.loaded'
)
self
.
assertEqual
(
data
,
{
'component_id'
:
u'drag-and-drop-v2.drag-and-drop-v2.d0.u0'
,
...
...
@@ -392,7 +392,7 @@ class EventsFiredTest(DefaultDataTestMixin, InteractionTestBase, BaseIntegration
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
(
name
,
'
edx.drag_and_drop_v2.item.picked_
up'
)
self
.
assertEqual
(
data
,
{
'component_id'
:
u'drag-and-drop-v2.drag-and-drop-v2.d0.u0'
,
...
...
@@ -405,7 +405,7 @@ class EventsFiredTest(DefaultDataTestMixin, InteractionTestBase, BaseIntegration
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
(
name
,
'
edx.drag_and_drop_
v2.item.dropped'
)
self
.
assertEqual
(
data
,
{
'component_id'
:
u'drag-and-drop-v2.drag-and-drop-v2.d0.u0'
,
...
...
@@ -421,25 +421,27 @@ class EventsFiredTest(DefaultDataTestMixin, InteractionTestBase, BaseIntegration
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
(
name
,
'
edx.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'
,
'truncated'
:
False
,
}
)
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
(
name
,
'
edx.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.'
,
'truncated'
:
False
,
}
)
...
...
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