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
99929eae
Commit
99929eae
authored
Jan 07, 2016
by
Tim Krones
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tests for keyboard a11y.
parent
238bbe21
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
65 additions
and
26 deletions
+65
-26
drag_and_drop_v2/default_data.py
+3
-2
drag_and_drop_v2/public/js/drag_and_drop.js
+3
-3
drag_and_drop_v2/public/js/view.js
+20
-21
tests/integration/test_base.py
+15
-0
tests/integration/test_interaction.py
+0
-0
tests/integration/test_render.py
+24
-0
No files found.
drag_and_drop_v2/default_data.py
View file @
99929eae
...
@@ -14,8 +14,9 @@ TOP_ZONE_DESCRIPTION = _("Use this zone to associate an item with the top layer
...
@@ -14,8 +14,9 @@ TOP_ZONE_DESCRIPTION = _("Use this zone to associate an item with the top layer
MIDDLE_ZONE_DESCRIPTION
=
_
(
"Use this zone to associate an item with the middle layer of the triangle."
)
MIDDLE_ZONE_DESCRIPTION
=
_
(
"Use this zone to associate an item with the middle layer of the triangle."
)
BOTTOM_ZONE_DESCRIPTION
=
_
(
"Use this zone to associate an item with the bottom layer of the triangle."
)
BOTTOM_ZONE_DESCRIPTION
=
_
(
"Use this zone to associate an item with the bottom layer of the triangle."
)
ITEM_INCORRECT_FEEDBACK
=
_
(
"No, this item does not belong here. Try again."
)
ITEM_CORRECT_FEEDBACK
=
_
(
"Correct! This one belongs to {zone}."
)
ITEM_CORRECT_FEEDBACK
=
_
(
"Correct! This one belongs to {zone}."
)
ITEM_INCORRECT_FEEDBACK
=
_
(
"No, this item does not belong here. Try again."
)
ITEM_NO_ZONE_FEEDBACK
=
_
(
"You silly, there are no zones for this one."
)
START_FEEDBACK
=
_
(
"Drag the items onto the image above."
)
START_FEEDBACK
=
_
(
"Drag the items onto the image above."
)
FINISH_FEEDBACK
=
_
(
"Good work! You have completed this drag and drop exercise."
)
FINISH_FEEDBACK
=
_
(
"Good work! You have completed this drag and drop exercise."
)
...
@@ -88,7 +89,7 @@ DEFAULT_DATA = {
...
@@ -88,7 +89,7 @@ DEFAULT_DATA = {
{
{
"displayName"
:
_
(
"I don't belong anywhere"
),
"displayName"
:
_
(
"I don't belong anywhere"
),
"feedback"
:
{
"feedback"
:
{
"incorrect"
:
_
(
"You silly, there are no zones for this one."
)
,
"incorrect"
:
ITEM_NO_ZONE_FEEDBACK
,
"correct"
:
""
"correct"
:
""
},
},
"zone"
:
"none"
,
"zone"
:
"none"
,
...
...
drag_and_drop_v2/public/js/drag_and_drop.js
View file @
99929eae
...
@@ -91,7 +91,7 @@ function DragAndDropBlock(runtime, element, configuration) {
...
@@ -91,7 +91,7 @@ function DragAndDropBlock(runtime, element, configuration) {
};
};
var
focusModalButton
=
function
()
{
var
focusModalButton
=
function
()
{
$root
.
find
(
'.keyboard-help-dialog .
dismiss-modal
-button '
).
focus
();
$root
.
find
(
'.keyboard-help-dialog .
modal-dismiss
-button '
).
focus
();
};
};
var
showKeyboardHelp
=
function
(
evt
)
{
var
showKeyboardHelp
=
function
(
evt
)
{
...
@@ -108,7 +108,7 @@ function DragAndDropBlock(runtime, element, configuration) {
...
@@ -108,7 +108,7 @@ function DragAndDropBlock(runtime, element, configuration) {
// Set up event handlers
// Set up event handlers
$
(
document
).
on
(
'keydown'
,
keyboardEventDispatcher
);
$
(
document
).
on
(
'keydown'
,
keyboardEventDispatcher
);
$keyboardHelpDialog
.
find
(
'.
dismiss-modal
-button'
).
on
(
'click'
,
hideKeyboardHelp
);
$keyboardHelpDialog
.
find
(
'.
modal-dismiss
-button'
).
on
(
'click'
,
hideKeyboardHelp
);
};
};
var
hideKeyboardHelp
=
function
(
evt
)
{
var
hideKeyboardHelp
=
function
(
evt
)
{
...
@@ -124,7 +124,7 @@ function DragAndDropBlock(runtime, element, configuration) {
...
@@ -124,7 +124,7 @@ function DragAndDropBlock(runtime, element, configuration) {
// Remove event handlers
// Remove event handlers
$
(
document
).
off
(
'keydown'
,
keyboardEventDispatcher
);
$
(
document
).
off
(
'keydown'
,
keyboardEventDispatcher
);
$keyboardHelpDialog
.
find
(
'.
dismiss-modal
-button'
).
off
();
$keyboardHelpDialog
.
find
(
'.
modal-dismiss
-button'
).
off
();
};
};
/** Asynchronously load the main background image used for this block. */
/** Asynchronously load the main background image used for this block. */
...
...
drag_and_drop_v2/public/js/view.js
View file @
99929eae
...
@@ -164,25 +164,27 @@
...
@@ -164,25 +164,27 @@
var
dialog_attributes
=
{
role
:
'dialog'
,
'aria-labelledby'
:
'modal-window-title'
};
var
dialog_attributes
=
{
role
:
'dialog'
,
'aria-labelledby'
:
'modal-window-title'
};
var
dialog_style
=
{};
var
dialog_style
=
{};
return
(
return
(
h
(
'div.keyboard-help-dialog'
,
[
h
(
'section.keyboard-help'
,
[
h
(
'div.modal-window-overlay'
),
h
(
'a.keyboard-help-button'
,
{
attributes
:
{
tabindex
:
0
}
},
gettext
(
'Keyboard Help'
)),
h
(
'div.modal-window'
,
{
attributes
:
dialog_attributes
,
style
:
dialog_style
},
[
h
(
'div.keyboard-help-dialog'
,
[
h
(
'div.modal-header'
,
[
h
(
'div.modal-window-overlay'
),
h
(
'h2.modal-window-title'
,
gettext
(
'Keyboard Help'
))
h
(
'div.modal-window'
,
{
attributes
:
dialog_attributes
,
style
:
dialog_style
},
[
]),
h
(
'div.modal-header'
,
[
h
(
'div.modal-content'
,
[
h
(
'h2.modal-window-title'
,
gettext
(
'Keyboard Help'
))
h
(
'p'
,
gettext
(
'You can complete this exercise using only your keyboard.'
)),
]),
h
(
'ul'
,
[
h
(
'div.modal-content'
,
[
h
(
'li'
,
gettext
(
'Use "Tab" and "Shift-Tab" to navigate between items and zones.'
)),
h
(
'p'
,
gettext
(
'You can complete this exercise using only your keyboard.'
)),
h
(
'li'
,
gettext
(
'Press "Enter" or "Space" on an item to select it for dropping, then navigate to the zone you want to drop it on.'
)),
h
(
'ul'
,
[
h
(
'li'
,
gettext
(
'Press "Enter" or "Space" to drop the item on the current zone.'
)),
h
(
'li'
,
gettext
(
'Use "Tab" and "Shift-Tab" to navigate between items and zones.'
)),
h
(
'li'
,
gettext
(
'Press "Escape" if you want to cancel the drop operation (e.g. because you would like to select a different item).'
)),
h
(
'li'
,
gettext
(
'Press "Enter" or "Space" on an item to select it for dropping, then navigate to the zone you want to drop it on.'
)),
h
(
'li'
,
gettext
(
'Press "?" at any time to bring up this dialog.'
)),
h
(
'li'
,
gettext
(
'Press "Enter" or "Space" to drop the item on the current zone.'
)),
h
(
'li'
,
gettext
(
'Press "Escape" if you want to cancel the drop operation (e.g. because you would like to select a different item).'
)),
h
(
'li'
,
gettext
(
'Press "?" at any time to bring up this dialog.'
)),
])
]),
h
(
'div.modal-actions'
,
[
h
(
'button.modal-dismiss-button'
,
gettext
(
"OK"
))
])
])
]),
h
(
'div.modal-actions'
,
[
h
(
'h3.sr'
,
gettext
(
'Actions'
)),
h
(
'button.dismiss-modal-button'
,
gettext
(
"OK"
))
])
])
])
])
])
])
...
@@ -223,9 +225,6 @@
...
@@ -223,9 +225,6 @@
renderCollection
(
itemTemplate
,
items_placed
,
ctx
),
renderCollection
(
itemTemplate
,
items_placed
,
ctx
),
]),
]),
]),
]),
h
(
'section.keyboard-help'
,
[
h
(
'a.keyboard-help-button'
,
{
attributes
:
{
tabindex
:
0
}
},
gettext
(
'Keyboard Help'
))
]),
keyboardHelpTemplate
(
ctx
),
keyboardHelpTemplate
(
ctx
),
feedbackTemplate
(
ctx
),
feedbackTemplate
(
ctx
),
])
])
...
...
tests/integration/test_base.py
View file @
99929eae
...
@@ -57,6 +57,21 @@ class BaseIntegrationTest(SeleniumBaseTest):
...
@@ -57,6 +57,21 @@ class BaseIntegrationTest(SeleniumBaseTest):
def
_get_zones
(
self
):
def
_get_zones
(
self
):
return
self
.
_page
.
find_elements_by_css_selector
(
".drag-container .zone"
)
return
self
.
_page
.
find_elements_by_css_selector
(
".drag-container .zone"
)
def
_get_popup
(
self
):
return
self
.
_page
.
find_element_by_css_selector
(
".popup"
)
def
_get_popup_content
(
self
):
return
self
.
_page
.
find_element_by_css_selector
(
".popup .popup-content"
)
def
_get_keyboard_help
(
self
):
return
self
.
_page
.
find_element_by_css_selector
(
".keyboard-help"
)
def
_get_keyboard_help_button
(
self
):
return
self
.
_page
.
find_element_by_css_selector
(
".keyboard-help .keyboard-help-button"
)
def
_get_keyboard_help_dialog
(
self
):
return
self
.
_page
.
find_element_by_css_selector
(
".keyboard-help .keyboard-help-dialog"
)
def
_get_feedback
(
self
):
def
_get_feedback
(
self
):
return
self
.
_page
.
find_element_by_css_selector
(
".feedback"
)
return
self
.
_page
.
find_element_by_css_selector
(
".feedback"
)
...
...
tests/integration/test_interaction.py
View file @
99929eae
This diff is collapsed.
Click to expand it.
tests/integration/test_render.py
View file @
99929eae
...
@@ -179,6 +179,30 @@ class TestDragAndDropRender(BaseIntegrationTest):
...
@@ -179,6 +179,30 @@ class TestDragAndDropRender(BaseIntegrationTest):
# Zone description should only be visible to screen readers:
# Zone description should only be visible to screen readers:
self
.
assertEqual
(
zone_description
.
get_attribute
(
'class'
),
'zone-description sr'
)
self
.
assertEqual
(
zone_description
.
get_attribute
(
'class'
),
'zone-description sr'
)
def
test_popup
(
self
):
self
.
load_scenario
()
popup
=
self
.
_get_popup
()
popup_content
=
self
.
_get_popup_content
()
self
.
assertFalse
(
popup
.
is_displayed
())
self
.
assertEqual
(
popup
.
get_attribute
(
'aria-live'
),
'polite'
)
self
.
assertEqual
(
popup_content
.
text
,
""
)
def
test_keyboard_help
(
self
):
self
.
load_scenario
()
self
.
_get_keyboard_help
()
keyboard_help_button
=
self
.
_get_keyboard_help_button
()
keyboard_help_dialog
=
self
.
_get_keyboard_help_dialog
()
dialog_modal_overlay
=
keyboard_help_dialog
.
find_element_by_css_selector
(
'.modal-window-overlay'
)
dialog_modal
=
keyboard_help_dialog
.
find_element_by_css_selector
(
'.modal-window'
)
self
.
assertEqual
(
keyboard_help_button
.
get_attribute
(
'tabindex'
),
'0'
)
self
.
assertFalse
(
dialog_modal_overlay
.
is_displayed
())
self
.
assertFalse
(
dialog_modal
.
is_displayed
())
self
.
assertEqual
(
dialog_modal
.
get_attribute
(
'role'
),
'dialog'
)
self
.
assertEqual
(
dialog_modal
.
get_attribute
(
'aria-labelledby'
),
'modal-window-title'
)
def
test_feedback
(
self
):
def
test_feedback
(
self
):
self
.
load_scenario
()
self
.
load_scenario
()
...
...
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