Refactor question review template for improved readability and structure; enhance question title display and answer rendering

This commit is contained in:
Ross
2025-10-27 10:28:40 +00:00
parent 8380ca1dd9
commit a404a335c0
@@ -1,7 +1,9 @@
{# Generic question display used in review UI. Tries to be resilient across apps. #} {% extends 'sbas/base.html' %}
{% block content %}
<div class="question-review-question mb-3"> <div class="question-review-question mb-3">
{% if question.title %} {% if question.title %}
<h5 class="mb-1">{{ question.title }}</h5> <h5 class="mb-1">Reviewing question: {{ question.title }}</h5>
{% endif %} {% endif %}
<div class="mb-2"> <div class="mb-2">
@@ -12,29 +14,46 @@
{% endif %} {% endif %}
</div> </div>
{# Multiple-choice answers (SBA style) #} {# Multiple-choice answers (SBA specific) #}
{% if question.get_answers is defined or question.a_answer is defined %} <div class="list-group mb-2">
<div class="list-group mb-2"> {% if question.a_answer %}
{% for code,label in (('a','A'),('b','B'),('c','C'),('d','D'),('e','E')) %} <div class="list-group-item d-flex justify-content-between align-items-start">
{% with ans=getattr(question, code|add:'_answer', None) %} <div><strong>A.</strong> <span class="ms-2">{{ question.a_answer|safe }}</span></div>
{% if ans %} {% if question.best_answer == 'a' %}<span class="badge bg-success">Correct</span>{% endif %}
<div class="list-group-item d-flex justify-content-between align-items-start"> </div>
<div> {% endif %}
<strong>{{ label }}.</strong> {% if question.b_answer %}
<span class="ms-2">{{ ans|safe }}</span> <div class="list-group-item d-flex justify-content-between align-items-start">
</div> <div><strong>B.</strong> <span class="ms-2">{{ question.b_answer|safe }}</span></div>
{% if question.best_answer and question.best_answer == code %} {% if question.best_answer == 'b' %}<span class="badge bg-success">Correct</span>{% endif %}
<span class="badge bg-success">Correct</span> </div>
{% endif %} {% endif %}
</div> {% if question.c_answer %}
{% endif %} <div class="list-group-item d-flex justify-content-between align-items-start">
{% endwith %} <div><strong>C.</strong> <span class="ms-2">{{ question.c_answer|safe }}</span></div>
{% endfor %} {% if question.best_answer == 'c' %}<span class="badge bg-success">Correct</span>{% endif %}
</div> </div>
{% endif %} {% endif %}
{% if question.d_answer %}
<div class="list-group-item d-flex justify-content-between align-items-start">
<div><strong>D.</strong> <span class="ms-2">{{ question.d_answer|safe }}</span></div>
{% if question.best_answer == 'd' %}<span class="badge bg-success">Correct</span>{% endif %}
</div>
{% endif %}
{% if question.e_answer %}
<div class="list-group-item d-flex justify-content-between align-items-start">
<div><strong>E.</strong> <span class="ms-2">{{ question.e_answer|safe }}</span></div>
{% if question.best_answer == 'e' %}<span class="badge bg-success">Correct</span>{% endif %}
</div>
{% endif %}
</div>
{# Generic feedback text if present #} {# Generic feedback text if present #}
{% if question.feedback %} {% if question.feedback %}
<div class="mt-2"><strong>Feedback:</strong> {{ question.feedback|safe }}</div> <div class="mt-2"><strong>Feedback:</strong> {{ question.feedback|safe }}</div>
{% endif %} {% endif %}
</div> </div>
{% endblock %}