Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
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
edx
edx-platform
Commits
dd9cdc1c
Commit
dd9cdc1c
authored
Dec 26, 2012
by
Alexander Kryklia
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tests for drag and drop
parent
ff0f2161
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
60 additions
and
6 deletions
+60
-6
common/lib/capa/capa/graders/tests.py
+60
-6
No files found.
common/lib/capa/capa/graders/tests.py
View file @
dd9cdc1c
...
...
@@ -6,17 +6,71 @@ import draganddrop
class
Test_DragAndDrop
(
unittest
.
TestCase
):
def
test_targets_true
(
self
):
user_input
=
'{"use_targets":
"true", "draggables":
\
["1": "t1", "name_with_icon": "t2"
]}'
user_input
=
'{"use_targets":
true, "draggables": [{"1": "t1"},
\
{"name_with_icon": "t2"}
]}'
correct_answer
=
{
'1'
:
't1'
,
'name_with_icon'
:
't2'
}
self
.
assertTrue
(
draganddrop
.
grade
(
user_input
,
correct_answer
))
def
test_targets_true
(
self
):
user_input
=
'{"use_targets": "true", "draggables":
\
["1": "t1", "name_with_icon": "t2"]}'
correct_answer
=
{
'1'
:
't1'
,
'name_with_icon'
:
't2'
}
def
test_targets_false
(
self
):
user_input
=
'{"use_targets": true, "draggables": [{"1": "t1"},
\
{"name_with_icon": "t2"}]}'
correct_answer
=
{
'1'
:
't3'
,
'name_with_icon'
:
't2'
}
self
.
assertFalse
(
draganddrop
.
grade
(
user_input
,
correct_answer
))
def
test_multiple_images_per_target_true
(
self
):
user_input
=
'{"use_targets": true,
\
"draggables": [{"1": "t1"}, {"name_with_icon": "t1"}]}'
correct_answer
=
{
'1'
:
't1'
,
'name_with_icon'
:
't1'
}
self
.
assertTrue
(
draganddrop
.
grade
(
user_input
,
correct_answer
))
def
test_multiple_images_per_target_false
(
self
):
user_input
=
'{"use_targets": true,
\
"draggables": [{"1": "t1"}, {"name_with_icon": "t1"}]}'
correct_answer
=
{
'1'
:
't2'
,
'name_with_icon'
:
't1'
}
self
.
assertFalse
(
draganddrop
.
grade
(
user_input
,
correct_answer
))
def
test_targets_and_positions
(
self
):
user_input
=
'{"use_targets": true, "draggables": [{"1": [10,10]},
\
{"name_with_icon": [[10,10],4]}]}'
correct_answer
=
{
'1'
:
[
10
,
10
],
'name_with_icon'
:
[[
10
,
10
],
4
]}
self
.
assertFalse
(
draganddrop
.
grade
(
user_input
,
correct_answer
))
def
test_position_and_targets
(
self
):
user_input
=
'{"use_targets": false,
\
"draggables": [{"1": "t1"}, {"name_with_icon": "t2"}]}'
correct_answer
=
{
'1'
:
't1'
,
'name_with_icon'
:
't2'
}
self
.
assertFalse
(
draganddrop
.
grade
(
user_input
,
correct_answer
))
def
test_positions_exact
(
self
):
user_input
=
'{"use_targets": false, "draggables":
\
[{"1": [10, 10]}, {"name_with_icon": [20, 20]}]}'
correct_answer
=
{
'1'
:
[
10
,
10
],
'name_with_icon'
:
[
20
,
20
]}
self
.
assertTrue
(
draganddrop
.
grade
(
user_input
,
correct_answer
))
def
test_positions_false
(
self
):
user_input
=
'{"use_targets": false, "draggables":
\
[{"1": [10, 10]}, {"name_with_icon": [20, 20]}]}'
correct_answer
=
{
'1'
:
[
25
,
25
],
'name_with_icon'
:
[
20
,
20
]}
self
.
assertFalse
(
draganddrop
.
grade
(
user_input
,
correct_answer
))
def
test_positions_true_in_radius
(
self
):
user_input
=
'{"use_targets": false, "draggables":
\
[{"1": [10, 10]}, {"name_with_icon": [20, 20]}]}'
correct_answer
=
{
'1'
:
[
14
,
14
],
'name_with_icon'
:
[
20
,
20
]}
self
.
assertTrue
(
draganddrop
.
grade
(
user_input
,
correct_answer
))
def
test_positions_true_in_manual_radius
(
self
):
user_input
=
'{"use_targets": false, "draggables":
\
[{"1": [10, 10]}, {"name_with_icon": [20, 20]}]}'
correct_answer
=
{
'1'
:
[[
40
,
10
],
30
],
'name_with_icon'
:
[
20
,
20
]}
self
.
assertTrue
(
draganddrop
.
grade
(
user_input
,
correct_answer
))
def
test_positions_false_in_manual_radius
(
self
):
user_input
=
'{"use_targets": false, "draggables":
\
[{"1": [10, 10]}, {"name_with_icon": [20, 20]}]}'
correct_answer
=
{
'1'
:
[[
40
,
10
],
29
],
'name_with_icon'
:
[
20
,
20
]}
self
.
assertFalse
(
draganddrop
.
grade
(
user_input
,
correct_answer
))
def
suite
():
...
...
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