From dfa977dbfa12daeead788a36f62e34401c0149cb Mon Sep 17 00:00:00 2001 From: Bridger Maxwell Date: Thu, 20 Sep 2012 17:37:34 -0400 Subject: [PATCH] Fixed problem weighting bug. Attribute is on descriptor, not module. --- common/lib/xmodule/xmodule/capa_module.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/common/lib/xmodule/xmodule/capa_module.py b/common/lib/xmodule/xmodule/capa_module.py index 8bf1a56404..51ee79b380 100644 --- a/common/lib/xmodule/xmodule/capa_module.py +++ b/common/lib/xmodule/xmodule/capa_module.py @@ -124,12 +124,6 @@ class CapaModule(XModule): self.name = only_one(dom2.xpath('/problem/@name')) - weight_string = only_one(dom2.xpath('/problem/@weight')) - if weight_string: - self.weight = float(weight_string) - else: - self.weight = None - if self.rerandomize == 'never': seed = 1 elif self.rerandomize == "per_student" and hasattr(self.system, 'id'): @@ -235,7 +229,7 @@ class CapaModule(XModule): content = {'name': self.display_name, 'html': html, - 'weight': self.weight, + 'weight': self.descriptor.weight, } # We using strings as truthy values, because the terminology of the @@ -615,3 +609,12 @@ class CapaDescriptor(RawDescriptor): 'problems/' + path[8:], path[8:], ] + + def __init__(self, *args, **kwargs): + super(CapaDescriptor, self).__init__(*args, **kwargs) + + weight_string = self.metadata.get('weight', None) + if weight_string: + self.weight = float(weight_string) + else: + self.weight = None