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
ba700333
Commit
ba700333
authored
Feb 20, 2014
by
Sef Kloninger
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2653 from edx/nick/disable-masking
Turn off capa name masking
parents
bf5bac8f
951e4378
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
19 deletions
+21
-19
common/lib/capa/capa/responsetypes.py
+1
-1
common/lib/capa/capa/tests/test_answer_pool.py
+9
-8
common/lib/capa/capa/tests/test_shuffle.py
+11
-10
No files found.
common/lib/capa/capa/responsetypes.py
View file @
ba700333
...
@@ -748,7 +748,7 @@ class MultipleChoiceResponse(LoncapaResponse):
...
@@ -748,7 +748,7 @@ class MultipleChoiceResponse(LoncapaResponse):
for
response
in
self
.
xml
.
xpath
(
"choicegroup"
):
for
response
in
self
.
xml
.
xpath
(
"choicegroup"
):
# Is Masking enabled? -- check for shuffle or answer-pool features
# Is Masking enabled? -- check for shuffle or answer-pool features
ans_str
=
response
.
get
(
"answer-pool"
)
ans_str
=
response
.
get
(
"answer-pool"
)
if
response
.
get
(
"shuffle"
)
==
"true"
or
(
ans_str
is
not
None
and
ans_str
!=
"0"
):
if
False
:
# Temporarily turn off masking
self
.
is_masked
=
True
self
.
is_masked
=
True
self
.
mask_dict
=
{}
self
.
mask_dict
=
{}
rng
=
random
.
Random
(
self
.
context
[
"seed"
])
rng
=
random
.
Random
(
self
.
context
[
"seed"
])
...
...
common/lib/capa/capa/tests/test_answer_pool.py
View file @
ba700333
...
@@ -64,8 +64,9 @@ class CapaAnswerPoolTest(unittest.TestCase):
...
@@ -64,8 +64,9 @@ class CapaAnswerPoolTest(unittest.TestCase):
self
.
assertIsNotNone
(
problem
.
tree
.
xpath
(
'//choicegroup[@answer-pool-done="done"]'
))
self
.
assertIsNotNone
(
problem
.
tree
.
xpath
(
'//choicegroup[@answer-pool-done="done"]'
))
# Check about masking
# Check about masking
response
=
problem
.
responders
.
values
()[
0
]
response
=
problem
.
responders
.
values
()[
0
]
self
.
assertTrue
(
hasattr
(
response
,
'is_masked'
))
### Temporarily disabling masking
self
.
assertEqual
(
response
.
unmask_order
(),
[
'choice_3'
,
'choice_5'
,
'choice_1'
,
'choice_4'
])
###self.assertTrue(hasattr(response, 'is_masked'))
###self.assertEqual(response.unmask_order(), ['choice_3', 'choice_5', 'choice_1', 'choice_4'])
def
test_answer_pool_4_choices_1_multiplechoiceresponse_seed2
(
self
):
def
test_answer_pool_4_choices_1_multiplechoiceresponse_seed2
(
self
):
xml_str
=
textwrap
.
dedent
(
"""
xml_str
=
textwrap
.
dedent
(
"""
...
@@ -112,8 +113,8 @@ class CapaAnswerPoolTest(unittest.TestCase):
...
@@ -112,8 +113,8 @@ class CapaAnswerPoolTest(unittest.TestCase):
self
.
assertIsNotNone
(
problem
.
tree
.
xpath
(
'//choicegroup[@answer-pool-done="done"]'
))
self
.
assertIsNotNone
(
problem
.
tree
.
xpath
(
'//choicegroup[@answer-pool-done="done"]'
))
# Check about masking
# Check about masking
response
=
problem
.
responders
.
values
()[
0
]
response
=
problem
.
responders
.
values
()[
0
]
self
.
assertTrue
(
hasattr
(
response
,
'is_masked'
))
###
self.assertTrue(hasattr(response, 'is_masked'))
self
.
assertEqual
(
response
.
unmask_order
(),
[
'choice_0'
,
'choice_4'
,
'choice_3'
,
'choice_2'
])
###
self.assertEqual(response.unmask_order(), ['choice_0', 'choice_4', 'choice_3', 'choice_2'])
def
test_no_answer_pool_4_choices_1_multiplechoiceresponse
(
self
):
def
test_no_answer_pool_4_choices_1_multiplechoiceresponse
(
self
):
xml_str
=
textwrap
.
dedent
(
"""
xml_str
=
textwrap
.
dedent
(
"""
...
@@ -160,7 +161,7 @@ class CapaAnswerPoolTest(unittest.TestCase):
...
@@ -160,7 +161,7 @@ class CapaAnswerPoolTest(unittest.TestCase):
self
.
assertEquals
(
problem
.
tree
.
xpath
(
'//choicegroup[@answer-pool-done="done"]'
),
[])
self
.
assertEquals
(
problem
.
tree
.
xpath
(
'//choicegroup[@answer-pool-done="done"]'
),
[])
# Check about masking
# Check about masking
response
=
problem
.
responders
.
values
()[
0
]
response
=
problem
.
responders
.
values
()[
0
]
self
.
assertFalse
(
hasattr
(
response
,
'is_masked'
))
###
self.assertFalse(hasattr(response, 'is_masked'))
def
test_0_answer_pool_4_choices_1_multiplechoiceresponse
(
self
):
def
test_0_answer_pool_4_choices_1_multiplechoiceresponse
(
self
):
xml_str
=
textwrap
.
dedent
(
"""
xml_str
=
textwrap
.
dedent
(
"""
...
@@ -205,7 +206,7 @@ class CapaAnswerPoolTest(unittest.TestCase):
...
@@ -205,7 +206,7 @@ class CapaAnswerPoolTest(unittest.TestCase):
self
.
assertRegexpMatches
(
the_html
,
r"<div>\{.*'1_solution_1'.*'1_solution_2'.*\}</div>"
)
self
.
assertRegexpMatches
(
the_html
,
r"<div>\{.*'1_solution_1'.*'1_solution_2'.*\}</div>"
)
self
.
assertEquals
(
problem
.
tree
.
xpath
(
'//choicegroup[@answer-pool-done="done"]'
),
[])
self
.
assertEquals
(
problem
.
tree
.
xpath
(
'//choicegroup[@answer-pool-done="done"]'
),
[])
response
=
problem
.
responders
.
values
()[
0
]
response
=
problem
.
responders
.
values
()[
0
]
self
.
assertFalse
(
hasattr
(
response
,
'is_masked'
))
###
self.assertFalse(hasattr(response, 'is_masked'))
def
test_invalid_answer_pool
(
self
):
def
test_invalid_answer_pool
(
self
):
xml_str
=
textwrap
.
dedent
(
"""
xml_str
=
textwrap
.
dedent
(
"""
...
@@ -290,8 +291,8 @@ class CapaAnswerPoolTest(unittest.TestCase):
...
@@ -290,8 +291,8 @@ class CapaAnswerPoolTest(unittest.TestCase):
self
.
assertRegexpMatches
(
the_html
,
r"<div>.*\[.*'correct-2'.*'wrong-1'.*'wrong-2'.*.*'wrong-3'.*'wrong-4'.*\].*</div>"
)
self
.
assertRegexpMatches
(
the_html
,
r"<div>.*\[.*'correct-2'.*'wrong-1'.*'wrong-2'.*.*'wrong-3'.*'wrong-4'.*\].*</div>"
)
self
.
assertRegexpMatches
(
the_html
,
r"<div>\{.*'1_solution_2'.*\}</div>"
)
self
.
assertRegexpMatches
(
the_html
,
r"<div>\{.*'1_solution_2'.*\}</div>"
)
response
=
problem
.
responders
.
values
()[
0
]
response
=
problem
.
responders
.
values
()[
0
]
self
.
assertTrue
(
hasattr
(
response
,
'is_masked'
))
###
self.assertTrue(hasattr(response, 'is_masked'))
self
.
assertEqual
(
response
.
unmask_order
(),
[
'choice_5'
,
'choice_0'
,
'choice_1'
,
'choice_3'
,
'choice_4'
])
###
self.assertEqual(response.unmask_order(), ['choice_5', 'choice_0', 'choice_1', 'choice_3', 'choice_4'])
def
test_answer_pool_2_multiplechoiceresponses_seed1
(
self
):
def
test_answer_pool_2_multiplechoiceresponses_seed1
(
self
):
xml_str
=
textwrap
.
dedent
(
"""
xml_str
=
textwrap
.
dedent
(
"""
...
...
common/lib/capa/capa/tests/test_shuffle.py
View file @
ba700333
...
@@ -33,8 +33,9 @@ class CapaShuffleTest(unittest.TestCase):
...
@@ -33,8 +33,9 @@ class CapaShuffleTest(unittest.TestCase):
self
.
assertRegexpMatches
(
the_html
,
r"<div>.*\[.*'Banana'.*'Apple'.*'Chocolate'.*'Donut'.*\].*</div>"
)
self
.
assertRegexpMatches
(
the_html
,
r"<div>.*\[.*'Banana'.*'Apple'.*'Chocolate'.*'Donut'.*\].*</div>"
)
# Check that choice name masking is enabled and that unmasking works
# Check that choice name masking is enabled and that unmasking works
response
=
problem
.
responders
.
values
()[
0
]
response
=
problem
.
responders
.
values
()[
0
]
self
.
assertTrue
(
hasattr
(
response
,
'is_masked'
))
### Temporarily disabling masking
self
.
assertEqual
(
response
.
unmask_order
(),
[
'choice_1'
,
'choice_0'
,
'choice_2'
,
'choice_3'
])
###self.assertTrue(hasattr(response, 'is_masked'))
###self.assertEqual(response.unmask_order(), ['choice_1', 'choice_0', 'choice_2', 'choice_3'])
self
.
assertEqual
(
the_html
,
problem
.
get_html
(),
'should be able to call get_html() twice'
)
self
.
assertEqual
(
the_html
,
problem
.
get_html
(),
'should be able to call get_html() twice'
)
self
.
assertIsNotNone
(
problem
.
tree
.
xpath
(
'//choicegroup[@shuffle-done="done"]'
))
self
.
assertIsNotNone
(
problem
.
tree
.
xpath
(
'//choicegroup[@shuffle-done="done"]'
))
...
@@ -55,8 +56,8 @@ class CapaShuffleTest(unittest.TestCase):
...
@@ -55,8 +56,8 @@ class CapaShuffleTest(unittest.TestCase):
# B A C D
# B A C D
# Check that the custom name= names come through
# Check that the custom name= names come through
response
=
problem
.
responders
.
values
()[
0
]
response
=
problem
.
responders
.
values
()[
0
]
self
.
assertTrue
(
hasattr
(
response
,
'is_masked'
))
###
self.assertTrue(hasattr(response, 'is_masked'))
self
.
assertEqual
(
response
.
unmask_order
(),
[
'choice_0'
,
'choice_aaa'
,
'choice_1'
,
'choice_ddd'
])
###
self.assertEqual(response.unmask_order(), ['choice_0', 'choice_aaa', 'choice_1', 'choice_ddd'])
self
.
assertIsNotNone
(
problem
.
tree
.
xpath
(
'//choicegroup[@shuffle-done="done"]'
))
self
.
assertIsNotNone
(
problem
.
tree
.
xpath
(
'//choicegroup[@shuffle-done="done"]'
))
def
test_shuffle_different_seed
(
self
):
def
test_shuffle_different_seed
(
self
):
...
@@ -90,8 +91,8 @@ class CapaShuffleTest(unittest.TestCase):
...
@@ -90,8 +91,8 @@ class CapaShuffleTest(unittest.TestCase):
the_html
=
problem
.
get_html
()
the_html
=
problem
.
get_html
()
self
.
assertRegexpMatches
(
the_html
,
r"<div>.*\[.*'Apple'.*\].*</div>"
)
self
.
assertRegexpMatches
(
the_html
,
r"<div>.*\[.*'Apple'.*\].*</div>"
)
response
=
problem
.
responders
.
values
()[
0
]
response
=
problem
.
responders
.
values
()[
0
]
self
.
assertEqual
(
response
.
unmask_order
(),
[
'choice_0'
])
###
self.assertEqual(response.unmask_order(), ['choice_0'])
self
.
assertEqual
(
response
.
unmask_name
(
'mask_0'
),
'choice_0'
)
###
self.assertEqual(response.unmask_name('mask_0'), 'choice_0')
self
.
assertIsNotNone
(
problem
.
tree
.
xpath
(
'//choicegroup[@shuffle-done="done"]'
))
self
.
assertIsNotNone
(
problem
.
tree
.
xpath
(
'//choicegroup[@shuffle-done="done"]'
))
def
test_shuffle_6_choices
(
self
):
def
test_shuffle_6_choices
(
self
):
...
@@ -275,7 +276,7 @@ class CapaShuffleTest(unittest.TestCase):
...
@@ -275,7 +276,7 @@ class CapaShuffleTest(unittest.TestCase):
self
.
assertRegexpMatches
(
html
,
r"<div>.*\[.*'Banana'.*'Apple'.*'Chocolate'.*'Donut'.*\].*</div>.*"
+
self
.
assertRegexpMatches
(
html
,
r"<div>.*\[.*'Banana'.*'Apple'.*'Chocolate'.*'Donut'.*\].*</div>.*"
+
r"<div>.*\[.*'B'.*'A'.*'C'.*'D'.*\].*</div>"
)
r"<div>.*\[.*'B'.*'A'.*'C'.*'D'.*\].*</div>"
)
responses
=
problem
.
responders
.
values
()
responses
=
problem
.
responders
.
values
()
self
.
assertTrue
(
hasattr
(
responses
[
0
],
'is_masked'
))
###
self.assertTrue(hasattr(responses[0], 'is_masked'))
self
.
assertTrue
(
hasattr
(
responses
[
1
],
'is_masked'
))
###
self.assertTrue(hasattr(responses[1], 'is_masked'))
self
.
assertEqual
(
responses
[
0
]
.
unmask_order
(),
[
'choice_1'
,
'choice_0'
,
'choice_2'
,
'choice_3'
])
###
self.assertEqual(responses[0].unmask_order(), ['choice_1', 'choice_0', 'choice_2', 'choice_3'])
self
.
assertEqual
(
responses
[
1
]
.
unmask_order
(),
[
'choice_1'
,
'choice_0'
,
'choice_2'
,
'choice_3'
])
###
self.assertEqual(responses[1].unmask_order(), ['choice_1', 'choice_0', 'choice_2', 'choice_3'])
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