From b76adb4b0681b1d1d71ca7bc76f812ca4c711ea4 Mon Sep 17 00:00:00 2001 From: Will Daly Date: Mon, 1 Apr 2013 11:22:42 -0400 Subject: [PATCH] Updated tests to address on-going randomization bug. Capa problem state was not being copied to module state during module initialization. This meant that when check_problem was called the first time, the seed would be re-generated and saved. --- common/lib/xmodule/xmodule/capa_module.py | 4 +++- common/lib/xmodule/xmodule/tests/test_capa_module.py | 8 ++------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/common/lib/xmodule/xmodule/capa_module.py b/common/lib/xmodule/xmodule/capa_module.py index da8b5b4f96..0e6d81bdeb 100644 --- a/common/lib/xmodule/xmodule/capa_module.py +++ b/common/lib/xmodule/xmodule/capa_module.py @@ -171,7 +171,9 @@ class CapaModule(CapaFields, XModule): # add extra info and raise raise Exception(msg), None, sys.exc_info()[2] - self.set_state_from_lcp() + # Ensure that the module state matches the state of the + # capa problem + self.set_state_from_lcp() def new_lcp(self, state, text=None): if text is None: diff --git a/common/lib/xmodule/xmodule/tests/test_capa_module.py b/common/lib/xmodule/xmodule/tests/test_capa_module.py index 08565e97ad..fa6d7ce724 100644 --- a/common/lib/xmodule/xmodule/tests/test_capa_module.py +++ b/common/lib/xmodule/xmodule/tests/test_capa_module.py @@ -868,9 +868,7 @@ class CapaModuleTest(unittest.TestCase): 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 + seed = module.seed self.assertTrue(seed is not None) # If we're not rerandomizing, the seed is always set @@ -930,9 +928,7 @@ class CapaModuleTest(unittest.TestCase): module = CapaFactory.create(rerandomize=rerandomize) # Get the seed - # module.seed isn't set until we check/save/reset the problem, - # so we access the capa problem seed directly - seed = module.lcp.seed + seed = module.seed # We do NOT want the seed to reset if rerandomize # is set to 'never' -- it should still be 1