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