Implement question review flow with category and status filters; add templates for review start, question display, and completion

This commit is contained in:
Ross
2025-10-27 10:21:07 +00:00
parent ec45464e58
commit 8380ca1dd9
8 changed files with 236 additions and 34 deletions
@@ -0,0 +1,9 @@
{% extends 'sbas/base.html' %}
{% block content %}
<h2>Review complete</h2>
<p>There are no more questions matching your filters.</p>
{% endblock %}
@@ -0,0 +1,40 @@
{# Generic question display used in review UI. Tries to be resilient across apps. #}
<div class="question-review-question mb-3">
{% if question.title %}
<h5 class="mb-1">{{ question.title }}</h5>
{% endif %}
<div class="mb-2">
{% if question.get_stem_stripped %}
<div class="question-stem">{{ question.get_stem_stripped|safe }}</div>
{% elif question.stem %}
<div class="question-stem">{{ question.stem|safe }}</div>
{% endif %}
</div>
{# Multiple-choice answers (SBA style) #}
{% if question.get_answers is defined or question.a_answer is defined %}
<div class="list-group mb-2">
{% for code,label in (('a','A'),('b','B'),('c','C'),('d','D'),('e','E')) %}
{% with ans=getattr(question, code|add:'_answer', None) %}
{% if ans %}
<div class="list-group-item d-flex justify-content-between align-items-start">
<div>
<strong>{{ label }}.</strong>
<span class="ms-2">{{ ans|safe }}</span>
</div>
{% if question.best_answer and question.best_answer == code %}
<span class="badge bg-success">Correct</span>
{% endif %}
</div>
{% endif %}
{% endwith %}
{% endfor %}
</div>
{% endif %}
{# Generic feedback text if present #}
{% if question.feedback %}
<div class="mt-2"><strong>Feedback:</strong> {{ question.feedback|safe }}</div>
{% endif %}
</div>
@@ -0,0 +1,39 @@
{% extends 'sbas/base.html' %}
{% load partials %}
{% block content %}
<h2>Review Questions</h2>
<p>Filter questions to review. Choose a category and/or a review status, then click Start to open the first matching question.</p>
<form method="post" action="{% url 'sbas:question_review_next' %}">
{% csrf_token %}
<div class="mb-3">
<label for="id_category" class="form-label">Category</label>
{% if categories %}
<select name="category" id="id_category" class="form-select">
<option value="">Any</option>
{% for c in categories %}
<option value="{{ c.pk }}">{{ c }}</option>
{% endfor %}
</select>
{% else %}
<p><em>No category choices available for this question type.</em></p>
{% endif %}
</div>
<div class="mb-3">
<label for="id_status" class="form-label">Review status</label>
<select name="status" id="id_status" class="form-select">
{% for code,label in status_options %}
<option value="{{ code }}">{{ label }}</option>
{% endfor %}
</select>
</div>
<button type="submit" class="btn btn-primary">Start review</button>
</form>
{% endblock %}