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
4f9d18df
Commit
4f9d18df
authored
Mar 29, 2013
by
Will Daly
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Wrote unit tests to verify bug fix in
https://github.com/MITx/mitx/pull/1764
parent
34899c20
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
59 additions
and
0 deletions
+59
-0
common/lib/xmodule/xmodule/tests/test_capa_module.py
+59
-0
No files found.
common/lib/xmodule/xmodule/tests/test_capa_module.py
View file @
4f9d18df
...
...
@@ -859,3 +859,62 @@ class CapaModuleTest(unittest.TestCase):
# Expect that the module has created a new dummy problem with the error
self
.
assertNotEqual
(
original_problem
,
module
.
lcp
)
def
test_random_seed_no_change
(
self
):
rerandomize_options
=
[
'never'
,
'per_student'
,
'always'
,
'onreset'
]
for
rerandomize
in
rerandomize_options
:
module
=
CapaFactory
.
create
(
rerandomize
=
rerandomize
)
# Get the seed
# module.seed isn't set until the problem is checked/saved,
# so we access the capa problem seed directly
seed
=
module
.
lcp
.
seed
self
.
assertTrue
(
seed
is
not
None
)
if
rerandomize
==
'never'
:
self
.
assertEqual
(
seed
,
1
)
# Check the problem
get_request_dict
=
{
CapaFactory
.
input_key
():
'3.14'
}
module
.
check_problem
(
get_request_dict
)
# Expect that the seed is the same
self
.
assertEqual
(
seed
,
module
.
seed
)
# Save the problem
module
.
save_problem
(
get_request_dict
)
# Expect that the seed is the same
self
.
assertEqual
(
seed
,
module
.
seed
)
def
test_random_seed_with_reset
(
self
):
rerandomize_options
=
[
'never'
,
'per_student'
,
'always'
,
'onreset'
]
for
rerandomize
in
rerandomize_options
:
module
=
CapaFactory
.
create
(
rerandomize
=
rerandomize
)
# Get the seed
seed
=
module
.
lcp
.
seed
# Reset the problem
module
.
reset_problem
({})
# We do NOT want the seed to reset if rerandomize
# is set to 'never' -- it should still be 1
# The seed also stays the same if we're randomizing
# 'per_student': the same student should see the same problem
if
rerandomize
in
[
'never'
,
'per_student'
]:
self
.
assertEqual
(
seed
,
module
.
seed
)
# Otherwise, we expect the seed to change
# to another valid seed
else
:
# After we save, the seed is stored in the module
get_request_dict
=
{
CapaFactory
.
input_key
():
'3.14'
}
module
.
save_problem
(
get_request_dict
)
self
.
assertEqual
(
seed
,
module
.
seed
)
self
.
assertTrue
(
module
.
seed
is
not
None
)
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