Skip to content
Snippets Groups Projects
Commit 9032562c authored by Awais Jibran's avatar Awais Jibran
Browse files

Fix Error in find_question_label.

parent 230bee9a
No related branches found
No related tags found
No related merge requests found
......@@ -562,7 +562,12 @@ class LoncapaProblem(object):
"""
_ = get_gettext(self.capa_system.i18n)
# Some questions define a prompt with this format: >>This is a prompt<<
prompt = self.problem_data[answer_id].get('label')
log_error = False
try:
prompt = self.problem_data[answer_id].get('label')
except KeyError:
log_error = True
prompt = self.problem_data.get(answer_id, {}).get('label')
if prompt:
question_text = prompt.striptags()
......@@ -607,6 +612,11 @@ class LoncapaProblem(object):
question_nr = int(answer_id.split('_')[-2]) - 1
question_text = _("Question {0}").format(question_nr)
if log_error:
log.error(
'KeyError: answer_id: %s, Problem data: %s, question_text: %s',
(answer_id, self.problem_data, question_text)
)
return question_text
def find_answer_text(self, answer_id, current_answer):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment