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
16ecdadf
Commit
16ecdadf
authored
Jan 03, 2013
by
Alexander Kryklia
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
changed interface
parent
31513787
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
8 deletions
+13
-8
common/lib/capa/capa/graders/draganddrop.py
+13
-8
No files found.
common/lib/capa/capa/graders/draganddrop.py
View file @
16ecdadf
...
@@ -201,11 +201,15 @@ class DragAndDrop(object):
...
@@ -201,11 +201,15 @@ class DragAndDrop(object):
def
populate
(
self
,
correct_answer
,
user_answer
):
def
populate
(
self
,
correct_answer
,
user_answer
):
""" """
""" """
# convert from dict format to list format
tmp
=
[]
if
isinstance
(
correct_answer
,
dict
):
if
isinstance
(
correct_answer
,
dict
):
for
key
,
value
in
correct_answer
.
items
():
for
key
,
value
in
correct_answer
.
items
():
self
.
correct_groups
[
key
]
=
[
key
]
tmp_dict
=
{
'draggables'
:
[],
'targets'
:
[],
'rule'
:
'exact'
}
self
.
correct_positions
[
key
]
=
{
'exact'
:
[
value
]}
tmp_dict
[
'draggables'
]
.
append
(
key
)
tmp_dict
[
'targets'
]
.
append
(
value
)
tmp
.
append
(
tmp_dict
)
correct_answer
=
tmp
user_answer
=
json
.
loads
(
user_answer
)
user_answer
=
json
.
loads
(
user_answer
)
self
.
use_targets
=
user_answer
.
get
(
'use_targets'
)
self
.
use_targets
=
user_answer
.
get
(
'use_targets'
)
...
@@ -216,7 +220,12 @@ class DragAndDrop(object):
...
@@ -216,7 +220,12 @@ class DragAndDrop(object):
# create identical data structures
# create identical data structures
# user groups must mirror correct_groups
# user groups must mirror correct_groups
# and positions must reflect order in group
# and positions must reflect order in group
for
groupname
in
self
.
correct_groups
:
for
i
in
xrange
(
0
,
len
(
correct_answer
)):
groupname
=
str
(
i
)
self
.
correct_groups
=
OrderedDict
()
self
.
correct_groups
[
groupname
]
=
correct_answer
[
i
][
'draggables'
]
self
.
correct_positions
=
OrderedDict
()
self
.
correct_positions
[
groupname
]
=
{
correct_answer
[
i
][
'rule'
]:
correct_answer
[
i
][
'targets'
]}
self
.
user_groups
[
groupname
]
=
[]
self
.
user_groups
[
groupname
]
=
[]
self
.
user_positions
[
groupname
]
=
{
'user'
:
[]}
self
.
user_positions
[
groupname
]
=
{
'user'
:
[]}
for
draggable_dict
in
user_answer
[
'draggables'
]:
for
draggable_dict
in
user_answer
[
'draggables'
]:
...
@@ -249,10 +258,6 @@ def grade(user_input, correct_answer):
...
@@ -249,10 +258,6 @@ def grade(user_input, correct_answer):
else:
else:
{'1': '[10, 10]', 'name_with_icon': '[[10, 10], 20]'}
{'1': '[10, 10]', 'name_with_icon': '[[10, 10], 20]'}
Support 2 interfaces"""
Support 2 interfaces"""
if
isinstance
(
correct_answer
,
dict
):
dnd
=
DragAndDrop
()
dnd
=
DragAndDrop
()
else
:
dnd
=
correct_answer
dnd
.
populate
(
correct_answer
=
correct_answer
,
user_answer
=
user_input
)
dnd
.
populate
(
correct_answer
=
correct_answer
,
user_answer
=
user_input
)
return
dnd
.
grade
()
return
dnd
.
grade
()
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