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): ...@@ -187,7 +187,7 @@ class LoncapaProblem(object):
# construct script processor context (eg for customresponse problems) # construct script processor context (eg for customresponse problems)
if minimal_init: if minimal_init:
self.context = {'script_code': ""} self.context = {}
else: else:
self.context = self._extract_context(self.tree) self.context = self._extract_context(self.tree)
...@@ -195,8 +195,9 @@ class LoncapaProblem(object): ...@@ -195,8 +195,9 @@ class LoncapaProblem(object):
# transformations. This also creates the dict (self.responders) of Response # transformations. This also creates the dict (self.responders) of Response
# instances for each question in the problem. The dict has keys = xml subtree of # instances for each question in the problem. The dict has keys = xml subtree of
# Response, values = Response instance # 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 if not self.student_answers: # True when student_answers is an empty dict
self.set_initial_display() self.set_initial_display()
...@@ -212,7 +213,6 @@ class LoncapaProblem(object): ...@@ -212,7 +213,6 @@ class LoncapaProblem(object):
if hasattr(response, 'late_transforms'): if hasattr(response, 'late_transforms'):
response.late_transforms(self) response.late_transforms(self)
if not minimal_init:
self.extracted_tree = self._extract_html(self.tree) self.extracted_tree = self._extract_html(self.tree)
def make_xml_compatible(self, tree): def make_xml_compatible(self, tree):
...@@ -869,7 +869,7 @@ class LoncapaProblem(object): ...@@ -869,7 +869,7 @@ class LoncapaProblem(object):
return tree return tree
def _preprocess_problem(self, tree): # private def _preprocess_problem(self, tree, minimal_init): # private
""" """
Assign IDs to all the responses Assign IDs to all the responses
Assign sub-IDs to all entries (textline, schematic, etc.) Assign sub-IDs to all entries (textline, schematic, etc.)
...@@ -907,10 +907,13 @@ class LoncapaProblem(object): ...@@ -907,10 +907,13 @@ class LoncapaProblem(object):
# instantiate capa Response # instantiate capa Response
responsetype_cls = responsetypes.registry.get_class_for_tag(response.tag) 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 # save in list in self
self.responders[response] = responder self.responders[response] = responder
if not minimal_init:
# get responder answers (do this only once, since there may be a performance cost, # get responder answers (do this only once, since there may be a performance cost,
# eg with externalresponse) # eg with externalresponse)
self.responder_answers = {} self.responder_answers = {}
......
...@@ -154,7 +154,7 @@ class LoncapaResponse(object): ...@@ -154,7 +154,7 @@ class LoncapaResponse(object):
# By default, we set this to False, allowing subclasses to override as appropriate. # By default, we set this to False, allowing subclasses to override as appropriate.
multi_device_support = False 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: Init is passed the following arguments:
...@@ -213,6 +213,7 @@ class LoncapaResponse(object): ...@@ -213,6 +213,7 @@ class LoncapaResponse(object):
maxpoints = inputfield.get('points', '1') maxpoints = inputfield.get('points', '1')
self.maxpoints.update({inputfield.get('id'): int(maxpoints)}) self.maxpoints.update({inputfield.get('id'): int(maxpoints)})
if not minimal_init:
# dict for default answer map (provided in input elements) # dict for default answer map (provided in input elements)
self.default_answer_map = {} self.default_answer_map = {}
for entry in self.inputfields: 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