Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix capa report generation issue #264

Merged
merged 3 commits into from
Jun 3, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions common/lib/capa/capa/capa_problem.py
Original file line number Diff line number Diff line change
Expand Up @@ -667,11 +667,17 @@ def find_answer_text(self, answer_id, current_answer):
answer_id=answer_id,
choice_number=current_answer
))
assert len(elems) == 1
choicegroup = elems[0].getparent()
input_cls = inputtypes.registry.get_class_for_tag(choicegroup.tag)
choices_map = dict(input_cls.extract_choices(choicegroup, self.capa_system.i18n, text_only=True))
answer_text = choices_map[current_answer]
if len(elems) == 0:
log.warning("Answer Text Missing for answer id: %s and choice number: %s", answer_id, current_answer)
answer_text = "Answer Text Missing"
elif len(elems) == 1:
choicegroup = elems[0].getparent()
input_cls = inputtypes.registry.get_class_for_tag(choicegroup.tag)
choices_map = dict(input_cls.extract_choices(choicegroup, self.capa_system.i18n, text_only=True))
answer_text = choices_map.get(current_answer, "Answer Text Missing")
else:
log.warning("Multiple answers found for answer id: %s and choice number: %s", answer_id, current_answer)
answer_text = "Multiple answers found"

elif isinstance(current_answer, six.string_types):
# Already a string with the answer
Expand All @@ -680,7 +686,7 @@ def find_answer_text(self, answer_id, current_answer):
else:
raise NotImplementedError()

return answer_text
return answer_text or "Answer Text Missing"

def do_targeted_feedback(self, tree):
"""
Expand Down