From 44e6572e1262ae5548fef264dd2c82f0252db4c2 Mon Sep 17 00:00:00 2001 From: Calen Pennington Date: Fri, 15 Mar 2013 08:25:27 -0400 Subject: [PATCH] Make StringyInteger and StringyFloat return None when they can't parse the string from json, and don't try to overwrite max_attempts if it's '' --- common/lib/xmodule/xmodule/capa_module.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/common/lib/xmodule/xmodule/capa_module.py b/common/lib/xmodule/xmodule/capa_module.py index 9c38347900..07afba0245 100644 --- a/common/lib/xmodule/xmodule/capa_module.py +++ b/common/lib/xmodule/xmodule/capa_module.py @@ -32,7 +32,7 @@ class StringyInteger(Integer): try: return int(value) except: - return value + return None class StringyFloat(Float): @@ -43,7 +43,7 @@ class StringyFloat(Float): try: return float(value) except: - return value + return None # Generated this many different variants of problems with rerandomize=per_student @@ -140,9 +140,6 @@ class CapaModule(CapaFields, XModule): # see comment on randomization_bin self.seed = randomization_bin(system.seed, self.location.url) - if self.max_attempts == '': - self.max_attempts = None - # Need the problem location in openendedresponse to send out. Adding # it to the system here seems like the least clunky way to get it # there. @@ -391,7 +388,7 @@ class CapaModule(CapaFields, XModule): content = {'name': self.display_name_with_default, 'html': html, - 'weight': self.descriptor.weight, + 'weight': self.weight, } context = {'problem': content,