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

Commit ce15bc9

Browse files
committed
Fix: Avoid crasher if htmlsrc is missing
* This will log an error if a question has no htmlsrc
1 parent fbf2e30 commit ce15bc9

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

controllers/assignments.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1206,13 +1206,18 @@ def practice():
12061206
# present the next one in the list after the last one that was asked
12071207
question = questions[(qIndex + 1) % len(questions)]
12081208

1209-
# This replacement is to render images
1210-
question.htmlsrc = question.htmlsrc.replace(
1211-
'src="../_static/', 'src="' + get_course_url("_static/")
1212-
)
1213-
question.htmlsrc = question.htmlsrc.replace(
1214-
"../_images/", get_course_url("_images/")
1215-
)
1209+
if question.htmlsrc:
1210+
# This replacement is to render images
1211+
question.htmlsrc = question.htmlsrc.replace(
1212+
'src="../_static/', 'src="' + get_course_url("_static/")
1213+
)
1214+
question.htmlsrc = question.htmlsrc.replace(
1215+
"../_images/", get_course_url("_images/")
1216+
)
1217+
else:
1218+
logger.error(
1219+
f"NO HTML SOURCE for question {question.id}, {question.name} sid: {auth.user.username}"
1220+
)
12161221

12171222
autogradable = 1
12181223
# If it is possible to autograde it:

0 commit comments

Comments
 (0)