Merge branch 'feature/alex/poll-merged' of github.com:MITx/mitx into feature/alex/poll-merged
This commit is contained in:
@@ -29,9 +29,21 @@ class StringyInteger(Integer):
|
||||
A model type that converts from strings to integers when reading from json
|
||||
"""
|
||||
def from_json(self, value):
|
||||
if isinstance(value, basestring):
|
||||
try:
|
||||
return int(value)
|
||||
return value
|
||||
except:
|
||||
return value
|
||||
|
||||
|
||||
class StringyFloat(Float):
|
||||
"""
|
||||
A model type that converts from string to floats when reading from json
|
||||
"""
|
||||
def from_json(self, value):
|
||||
try:
|
||||
return float(value)
|
||||
except:
|
||||
return value
|
||||
|
||||
|
||||
# Generated this many different variants of problems with rerandomize=per_student
|
||||
@@ -781,7 +793,7 @@ class CapaDescriptor(RawDescriptor):
|
||||
|
||||
module_class = CapaModule
|
||||
|
||||
weight = Float(help="How much to weight this problem by", scope=Scope.settings)
|
||||
weight = StringyFloat(help="How much to weight this problem by", scope=Scope.settings)
|
||||
markdown = String(help="Markdown source of this module", scope=Scope.settings, default='')
|
||||
|
||||
stores_state = True
|
||||
|
||||
@@ -395,7 +395,7 @@ def get_score(course_id, user, problem_descriptor, module_creator, model_data_ca
|
||||
return (None, None)
|
||||
|
||||
#Now we re-weight the problem, if specified
|
||||
weight = getattr(problem_descriptor, 'weight', None)
|
||||
weight = problem_descriptor.weight
|
||||
if weight is not None:
|
||||
if total == 0:
|
||||
log.exception("Cannot reweight a problem with zero total points. Problem: " + str(student_module))
|
||||
|
||||
Reference in New Issue
Block a user