Fix Error in find_question_label.
This commit is contained in:
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user