Commit dacc1f3c by Nimisha Asthagiri Committed by GitHub

Merge pull request #14055 from edx/naa/fix-capa-max-score

Fix CAPA's max_score computation
parents ca5c741f 562aeee0
......@@ -187,7 +187,7 @@ class LoncapaProblem(object):
# construct script processor context (eg for customresponse problems)
if minimal_init:
self.context = {'script_code': ""}
self.context = {}
else:
self.context = self._extract_context(self.tree)
......@@ -195,8 +195,9 @@ class LoncapaProblem(object):
# transformations. This also creates the dict (self.responders) of Response
# instances for each question in the problem. The dict has keys = xml subtree of
# Response, values = Response instance
self.problem_data = self._preprocess_problem(self.tree)
self.problem_data = self._preprocess_problem(self.tree, minimal_init)
if not minimal_init:
if not self.student_answers: # True when student_answers is an empty dict
self.set_initial_display()
......@@ -212,7 +213,6 @@ class LoncapaProblem(object):
if hasattr(response, 'late_transforms'):
response.late_transforms(self)
if not minimal_init:
self.extracted_tree = self._extract_html(self.tree)
def make_xml_compatible(self, tree):
......@@ -869,7 +869,7 @@ class LoncapaProblem(object):
return tree
def _preprocess_problem(self, tree): # private
def _preprocess_problem(self, tree, minimal_init): # private
"""
Assign IDs to all the responses
Assign sub-IDs to all entries (textline, schematic, etc.)
......@@ -907,10 +907,13 @@ class LoncapaProblem(object):
# instantiate capa Response
responsetype_cls = responsetypes.registry.get_class_for_tag(response.tag)
responder = responsetype_cls(response, inputfields, self.context, self.capa_system, self.capa_module)
responder = responsetype_cls(
response, inputfields, self.context, self.capa_system, self.capa_module, minimal_init
)
# save in list in self
self.responders[response] = responder
if not minimal_init:
# get responder answers (do this only once, since there may be a performance cost,
# eg with externalresponse)
self.responder_answers = {}
......
......@@ -154,7 +154,7 @@ class LoncapaResponse(object):
# By default, we set this to False, allowing subclasses to override as appropriate.
multi_device_support = False
def __init__(self, xml, inputfields, context, system, capa_module):
def __init__(self, xml, inputfields, context, system, capa_module, minimal_init):
"""
Init is passed the following arguments:
......@@ -213,6 +213,7 @@ class LoncapaResponse(object):
maxpoints = inputfield.get('points', '1')
self.maxpoints.update({inputfield.get('id'): int(maxpoints)})
if not minimal_init:
# dict for default answer map (provided in input elements)
self.default_answer_map = {}
for entry in self.inputfields:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment