Refactor exam review templates and views to improve response summary display and handle unanswered responses

This commit is contained in:
Ross
2025-11-10 09:58:02 +00:00
parent 3d6ca8be54
commit e078b5a98f
4 changed files with 71 additions and 11 deletions
@@ -1,6 +1,5 @@
<div class="card mb-3">
<div class="card-body">
<div class="mb-2"><span class="badge bg-dark">SBAs</span></div>
<h5 class="card-title">Question</h5>
<p class="lead">{{ question|safe }}</p>
@@ -19,7 +19,12 @@
{# Choice A #}
<div class="list-group-item">
<div class="d-flex w-100 justify-content-between align-items-center">
<div>A</div>
<div>
<div class="fw-bold">A</div>
{% if exam_response_texts.a %}
<div class="small text-muted">{{ exam_response_texts.a|safe }}</div>
{% endif %}
</div>
<div class="text-end">
<span class="me-2">{{ exam_response_counts.a|default:0 }}</span>
<small class="text-muted">{{ exam_response_pcts.a|default:0 }}%</small>
@@ -35,7 +40,12 @@
{# Choice B #}
<div class="list-group-item">
<div class="d-flex w-100 justify-content-between align-items-center">
<div>B</div>
<div>
<div class="fw-bold">B</div>
{% if exam_response_texts.b %}
<div class="small text-muted">{{ exam_response_texts.b|safe }}</div>
{% endif %}
</div>
<div class="text-end">
<span class="me-2">{{ exam_response_counts.b|default:0 }}</span>
<small class="text-muted">{{ exam_response_pcts.b|default:0 }}%</small>
@@ -51,7 +61,12 @@
{# Choice C #}
<div class="list-group-item">
<div class="d-flex w-100 justify-content-between align-items-center">
<div>C</div>
<div>
<div class="fw-bold">C</div>
{% if exam_response_texts.c %}
<div class="small text-muted">{{ exam_response_texts.c|safe }}</div>
{% endif %}
</div>
<div class="text-end">
<span class="me-2">{{ exam_response_counts.c|default:0 }}</span>
<small class="text-muted">{{ exam_response_pcts.c|default:0 }}%</small>
@@ -67,7 +82,12 @@
{# Choice D #}
<div class="list-group-item">
<div class="d-flex w-100 justify-content-between align-items-center">
<div>D</div>
<div>
<div class="fw-bold">D</div>
{% if exam_response_texts.d %}
<div class="small text-muted">{{ exam_response_texts.d|safe }}</div>
{% endif %}
</div>
<div class="text-end">
<span class="me-2">{{ exam_response_counts.d|default:0 }}</span>
<small class="text-muted">{{ exam_response_pcts.d|default:0 }}%</small>
@@ -83,7 +103,12 @@
{# Choice E #}
<div class="list-group-item">
<div class="d-flex w-100 justify-content-between align-items-center">
<div>E</div>
<div>
<div class="fw-bold">E</div>
{% if exam_response_texts.e %}
<div class="small text-muted">{{ exam_response_texts.e|safe }}</div>
{% endif %}
</div>
<div class="text-end">
<span class="me-2">{{ exam_response_counts.e|default:0 }}</span>
<small class="text-muted">{{ exam_response_pcts.e|default:0 }}%</small>
@@ -96,6 +121,23 @@
</div>
</div>
</div>
{# Unanswered / other responses (blank, None, or unexpected labels) #}
{% if exam_response_counts.unanswered|default:0 %}
<div class="list-group-item">
<div class="d-flex w-100 justify-content-between align-items-center">
<div>No answer / Other</div>
<div class="text-end">
<span class="me-2">{{ exam_response_counts.unanswered|default:0 }}</span>
<small class="text-muted">{{ exam_response_pcts.unanswered|default:0 }}%</small>
</div>
</div>
<div class="progress mt-2" style="height:12px;">
<div class="progress-bar bg-secondary" role="progressbar"
style="width: {{ exam_response_pcts.unanswered|default:0 }}%;"
aria-valuenow="{{ exam_response_pcts.unanswered|default:0 }}" aria-valuemin="0" aria-valuemax="100"></div>
</div>
</div>
{% endif %}
{% else %}
<div class="small text-muted">No responses recorded for this question in the exam yet.</div>
{% endif %}