Skip to content
This repository has been archived by the owner on Jun 30, 2024. It is now read-only.

Commit

Permalink
Fix: Avoid crasher if htmlsrc is missing
Browse files Browse the repository at this point in the history
* This will log an error if a question has no htmlsrc
  • Loading branch information
bnmnetp committed Oct 7, 2022
1 parent fbf2e30 commit ce15bc9
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions controllers/assignments.py
Original file line number Diff line number Diff line change
Expand Up @@ -1206,13 +1206,18 @@ def practice():
# present the next one in the list after the last one that was asked
question = questions[(qIndex + 1) % len(questions)]

# This replacement is to render images
question.htmlsrc = question.htmlsrc.replace(
'src="../_static/', 'src="' + get_course_url("_static/")
)
question.htmlsrc = question.htmlsrc.replace(
"../_images/", get_course_url("_images/")
)
if question.htmlsrc:
# This replacement is to render images
question.htmlsrc = question.htmlsrc.replace(
'src="../_static/', 'src="' + get_course_url("_static/")
)
question.htmlsrc = question.htmlsrc.replace(
"../_images/", get_course_url("_images/")
)
else:
logger.error(
f"NO HTML SOURCE for question {question.id}, {question.name} sid: {auth.user.username}"
)

autogradable = 1
# If it is possible to autograde it:
Expand Down

0 comments on commit ce15bc9

Please sign in to comment.