From 8398f772cc88b014ecede67b72e1cb2ec59fccaf Mon Sep 17 00:00:00 2001 From: Jan Britz Date: Tue, 22 Oct 2024 12:39:54 +0200 Subject: [PATCH] fix: only view and log errors if there are any --- questionpy_sdk/webserver/attempt.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/questionpy_sdk/webserver/attempt.py b/questionpy_sdk/webserver/attempt.py index e44c047..0da21e3 100644 --- a/questionpy_sdk/webserver/attempt.py +++ b/questionpy_sdk/webserver/attempt.py @@ -66,15 +66,18 @@ def get_attempt_render_context( if display_options.general_feedback and attempt.ui.general_feedback: html, errors = QuestionUIRenderer(attempt.ui.general_feedback, *renderer_args).render() context["general_feedback"] = html - context["render_errors"]["General Feedback"] = errors + if errors: + context["render_errors"]["General Feedback"] = errors if display_options.feedback and attempt.ui.specific_feedback: html, errors = QuestionUIRenderer(attempt.ui.specific_feedback, *renderer_args).render() context["specific_feedback"] = html - context["render_errors"]["Specific Feedback"] = errors + if errors: + context["render_errors"]["Specific Feedback"] = errors if display_options.right_answer and attempt.ui.right_answer: html, errors = QuestionUIRenderer(attempt.ui.right_answer, *renderer_args).render() context["right_answer"] = html - context["render_errors"]["Right Answer"] = errors + if errors: + context["render_errors"]["Right Answer"] = errors log_render_errors(context["render_errors"])