Add question overview page with filtering options and counts by category

This commit is contained in:
Ross
2025-10-28 08:15:10 +00:00
parent 82ce6b0f93
commit 293b5b6682
4 changed files with 184 additions and 0 deletions
+2
View File
@@ -25,6 +25,8 @@
<li><a class="dropdown-item" href="{% url 'sbas:question_view' %}"><i class="bi bi-list-ul"></i> All Questions</a></li>
<li><a class="dropdown-item" href="{% url 'sbas:question_review_start' %}"><i class="bi bi-bookmarks-fill"></i> Review Questions</a></li>
<li><a class="dropdown-item" href="{% url 'sbas:generate_exam' %}"><i class="bi bi-journal-plus"></i> Generate Exam</a></li>
<li><a class="dropdown-item" href="{% url 'sbas:question_overview' %}"><i class="bi bi-journal-plus"></i> Questions Overview`</a></li>
<!-- Additional items can be added here -->
</ul>
</li>
@@ -0,0 +1,66 @@
{% extends 'base.html' %}
{% block content %}
<div class="py-3">
<div class="d-flex justify-content-between align-items-center mb-3">
<h2 class="h5">Question overview</h2>
<a class="btn btn-sm btn-outline-secondary" href="{% url 'sbas:question_view' %}">All questions</a>
</div>
<form method="get" class="row g-2 mb-3">
<div class="col-auto">
<label class="form-label small">Status</label>
<select name="status" class="form-select form-select-sm">
{% for v, label in status_options %}
<option value="{{ v }}" {% if selected_status == v %}selected{% endif %}>{{ label }}</option>
{% endfor %}
</select>
</div>
<div class="col-auto">
<label class="form-label small">Category</label>
<select name="category" class="form-select form-select-sm">
<option value="">(All)</option>
{% for c in categories %}
<option value="{{ c.id }}" {% if selected_category|default:'' == c.id|stringformat:"s" %}selected{% endif %}>{{ c.category }}</option>
{% endfor %}
</select>
</div>
<div class="col-auto">
<label class="form-label small">Open access</label>
<select name="open_access" class="form-select form-select-sm">
<option value="">(Any)</option>
<option value="1" {% if selected_open_access == '1' %}selected{% endif %}>Yes</option>
<option value="0" {% if selected_open_access == '0' %}selected{% endif %}>No</option>
</select>
</div>
<div class="col-auto align-self-end">
<button class="btn btn-sm btn-primary">Filter</button>
</div>
</form>
<div class="card">
<div class="card-body">
<h6 class="card-title">Counts by category <small class="text-muted">({{ total }} questions)</small></h6>
{% if counts %}
<ul class="list-group list-group-flush">
{% for name, count in counts %}
<li class="list-group-item d-flex justify-content-between align-items-center">
<div>{{ name }}</div>
<div class="text-muted">{{ count }}</div>
</li>
{% endfor %}
</ul>
{% else %}
<p class="small text-muted">No matching questions.</p>
{% endif %}
</div>
</div>
</div>
{% endblock %}
{% block js %}{% endblock %}