diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 06fa45818e8d..b2df3a650858 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -23,6 +23,8 @@ LMS: Support adding students to a cohort via the instructor dashboard. TNL-163 LMS: Show cohorts on the new instructor dashboard. TNL-161 +LMS: Extended hints feature + LMS: Mobile API available for courses that opt in using the Course Advanced Setting "Mobile Course Available" (only used in limited closed beta). diff --git a/common/lib/capa/capa/capa_problem.py b/common/lib/capa/capa/capa_problem.py index 699db9aaf35e..37faf54f1a58 100644 --- a/common/lib/capa/capa/capa_problem.py +++ b/common/lib/capa/capa/capa_problem.py @@ -162,6 +162,8 @@ def __init__(self, problem_text, id, capa_system, state=None, seed=None): # parse problem XML file into an element tree self.tree = etree.XML(problem_text) + self.make_xml_compatible(self.tree) + # handle any tags self._process_includes() @@ -191,6 +193,48 @@ def __init__(self, problem_text, id, capa_system, state=None, seed=None): self.extracted_tree = self._extract_html(self.tree) + def make_xml_compatible(self, tree): + """ + Adjust tree xml in-place for compatibility, such as + supporting an old xml format by translating it to a new format. + """ + # compatibility translation: + # old: ANSWER + # convert to + # new: OPTIONAL-HINT + # the new format is the form used at runtime and by this conversion we support + # the old format + additionals = tree.xpath('//stringresponse/additional_answer') + for additional in additionals: + answer = additional.get('answer') + text = additional.text + if not answer and text: # trigger of old->new conversion + additional.set('answer', text) + additional.text = '' + + # compatibility translation: + # optioninput uses option= like this: + # + # With extended hints there is a new + # This translation takes in the new format and synthesizes the old option= attribute + # so all downstream logic works unchanged with the new