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
31513787
Commit
31513787
authored
Jan 03, 2013
by
Alexander Kryklia
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
removed denied and allowed rule
parent
75ff3aaa
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
45 deletions
+28
-45
common/lib/capa/capa/graders/draganddrop.py
+28
-45
No files found.
common/lib/capa/capa/graders/draganddrop.py
View file @
31513787
...
@@ -145,42 +145,25 @@ class DragAndDrop(object):
...
@@ -145,42 +145,25 @@ class DragAndDrop(object):
# Checks in every group that user positions of every element are equal
# Checks in every group that user positions of every element are equal
# with correct positions for every rule
# with correct positions for every rule
for
group
in
self
.
correct_groups
:
# 'denied' rule
# for group in self.correct_groups: # 'denied' rule
if
not
self
.
compare_positions
(
self
.
correct_positions
[
group
]
.
get
(
# if not self.compare_positions(self.correct_positions[group].get(
'denied'
,
[]),
self
.
user_positions
[
group
][
'user'
],
flag
=
'denied'
):
# 'denied', []), self.user_positions[group]['user'], flag='denied'):
return
False
# return False
no_exact
,
no_allowed
,
no_anyof
=
False
,
False
,
False
passed_rules
=
dict
()
for
rule
in
(
'exact'
,
'anyof'
):
for
groupname
in
self
.
correct_groups
:
# 'exact' rule
passed_rules
[
rule
]
=
True
if
self
.
correct_positions
[
groupname
]
.
get
(
'exact'
,
[]):
for
groupname
in
self
.
correct_groups
:
if
not
self
.
compare_positions
(
if
self
.
correct_positions
[
groupname
]
.
get
(
rule
,
[]):
self
.
correct_positions
[
groupname
][
'exact'
],
if
not
self
.
compare_positions
(
self
.
user_positions
[
groupname
][
'user'
],
flag
=
'exact'
):
self
.
correct_positions
[
groupname
][
rule
],
return
False
self
.
user_positions
[
groupname
][
'user'
],
flag
=
rule
):
else
:
return
False
no_exact
=
True
else
:
passed_rules
[
rule
]
=
False
for
groupname
in
self
.
correct_groups
:
# 'allowed' rule
if
self
.
correct_positions
[
groupname
]
.
get
(
'allowed'
,
[]):
if
not
self
.
compare_positions
(
self
.
correct_positions
[
groupname
][
'allowed'
],
self
.
user_positions
[
groupname
][
'user'
],
flag
=
'allowed'
):
return
False
else
:
no_allowed
=
True
# 'anyof' rule
for
groupname
in
self
.
correct_groups
:
if
self
.
correct_positions
[
groupname
]
.
get
(
'anyof'
,
[]):
if
not
self
.
compare_positions
(
self
.
correct_positions
[
groupname
][
'anyof'
],
self
.
user_positions
[
groupname
][
'user'
],
flag
=
'anyof'
):
return
False
else
:
no_anyof
=
True
if
no_allowed
and
no_exact
and
no_anyof
:
# if all passed rules are false
if
not
reduce
(
lambda
x
,
y
:
x
or
y
,
passed_rules
):
return
False
return
False
return
True
return
True
...
@@ -188,16 +171,16 @@ class DragAndDrop(object):
...
@@ -188,16 +171,16 @@ class DragAndDrop(object):
def
compare_positions
(
self
,
correct
,
user
,
flag
):
def
compare_positions
(
self
,
correct
,
user
,
flag
):
""" order of correct/user is matter only in anyof_flag"""
""" order of correct/user is matter only in anyof_flag"""
# import ipdb; ipdb.set_trace()
# import ipdb; ipdb.set_trace()
if
flag
==
'denied'
:
#
if flag == 'denied':
for
el1
in
correct
:
#
for el1 in correct:
for
el2
in
user
:
#
for el2 in user:
if
PositionsCompare
(
el1
)
==
PositionsCompare
(
el2
):
#
if PositionsCompare(el1) == PositionsCompare(el2):
return
False
#
return False
if
flag
==
'allowed'
:
#
if flag == 'allowed':
for
el1
,
el2
in
zip
(
sorted
(
correct
),
sorted
(
user
)):
#
for el1, el2 in zip(sorted(correct), sorted(user)):
if
PositionsCompare
(
el1
)
!=
PositionsCompare
(
el2
):
#
if PositionsCompare(el1) != PositionsCompare(el2):
return
False
#
return False
if
flag
==
'exact'
:
if
flag
==
'exact'
:
for
el1
,
el2
in
zip
(
correct
,
user
):
for
el1
,
el2
in
zip
(
correct
,
user
):
...
@@ -210,7 +193,7 @@ class DragAndDrop(object):
...
@@ -210,7 +193,7 @@ class DragAndDrop(object):
for
c_el
in
correct
:
for
c_el
in
correct
:
if
PositionsCompare
(
u_el
)
==
PositionsCompare
(
c_el
):
if
PositionsCompare
(
u_el
)
==
PositionsCompare
(
c_el
):
count
+=
1
count
+=
1
continue
break
if
count
!=
len
(
user
):
if
count
!=
len
(
user
):
return
False
return
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