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
fb976024
Commit
fb976024
authored
Apr 01, 2013
by
Will Daly
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Save randomization seed if it is not already set,
so that the same problem loads when the user checks/saves/resets
parent
7f004872
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
8 deletions
+15
-8
common/lib/xmodule/xmodule/capa_module.py
+10
-0
common/lib/xmodule/xmodule/tests/test_capa_module.py
+5
-8
No files found.
common/lib/xmodule/xmodule/capa_module.py
View file @
fb976024
...
...
@@ -150,6 +150,16 @@ class CapaModule(CapaFields, XModule):
# TODO (vshnayder): move as much as possible of this work and error
# checking to descriptor load time
self
.
lcp
=
self
.
new_lcp
(
self
.
get_state_for_lcp
())
# At this point, we need to persist the randomization seed
# so that when the problem is re-loaded (to check/view/save)
# it stays the same.
# However, we do not want to write to the database
# every time the module is loaded.
# So we set the seed ONLY when there is not one set already
if
self
.
seed
is
None
:
self
.
seed
=
self
.
lcp
.
seed
except
Exception
as
err
:
msg
=
'cannot create LoncapaProblem {loc}: {err}'
.
format
(
loc
=
self
.
location
.
url
(),
err
=
err
)
...
...
common/lib/xmodule/xmodule/tests/test_capa_module.py
View file @
fb976024
...
...
@@ -868,10 +868,8 @@ class CapaModuleTest(unittest.TestCase):
module
=
CapaFactory
.
create
(
rerandomize
=
rerandomize
)
# Get the seed
# This isn't stored in the XModule until
# we check/save/reset the problem, so we
# access the lcp seed directly
seed
=
module
.
lcp
.
seed
# By this point, the module should have persisted the seed
seed
=
module
.
seed
self
.
assertTrue
(
seed
is
not
None
)
# If we're not rerandomizing, the seed is always set
...
...
@@ -931,10 +929,9 @@ class CapaModuleTest(unittest.TestCase):
module
=
CapaFactory
.
create
(
rerandomize
=
rerandomize
)
# Get the seed
# This isn't stored in the XModule until
# we check/save/reset the problem, so we
# access the lcp seed directly
seed
=
module
.
lcp
.
seed
# By this point, the module should have persisted the seed
seed
=
module
.
seed
self
.
assertTrue
(
seed
is
not
None
)
# We do NOT want the seed to reset if rerandomize
# is set to 'never' -- it should still be 1
...
...
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