Implement hiding and showing functionality for user exams and collections

This commit is contained in:
Ross
2026-06-15 11:23:00 +01:00
parent 35ab7443d2
commit c50ace771e
11 changed files with 400 additions and 50 deletions
+50 -11
View File
@@ -5,7 +5,20 @@
<div class="container py-4">
<div class="row mb-3">
<div class="col-md-8">
<h2 class="mb-1">User: {{ cid_user.username }}</h2>
<div class="d-flex justify-content-between align-items-center mb-1">
<h2 class="mb-0">User: {{ cid_user.username }}</h2>
<div>
{% if show_hidden %}
<a class="btn btn-sm btn-outline-secondary" href="?">
<i class="bi bi-eye-slash me-1"></i>Hide Hidden
</a>
{% else %}
<a class="btn btn-sm btn-outline-info" href="?show_hidden=true">
<i class="bi bi-eye me-1"></i>Show Hidden
</a>
{% endif %}
</div>
</div>
{% help "Help" %}
<div class="card mt-2">
<div class="card-body small">
@@ -32,18 +45,31 @@
<h6 class="mt-3">{{ exam_type|title }}</h6>
<ul class="list-group">
{% for exam in exams %}
<li class="list-group-item d-flex justify-content-between align-items-center">
<li class="list-group-item d-flex justify-content-between align-items-center {% if exam.is_hidden %}opacity-50 bg-secondary bg-opacity-10{% endif %}">
<div>
{{ exam }}
{% if exam.active %}<span class="badge bg-success ms-2">Active</span>{% endif %}
{% if exam.publish_results %}<span class="badge bg-info text-dark ms-2">Results Published</span>{% endif %}
{% if exam.is_hidden %}<span class="badge bg-warning text-dark ms-2">Hidden</span>{% endif %}
</div>
<div class="btn-group btn-group-sm" role="group">
{% if exam.active %}
<a class="btn btn-primary" href="{{ exam.get_take_url }}" target="_blank" title="Click to take exam">Start</a>
{% endif %}
{% if exam.publish_results %}
<a class="btn btn-outline-secondary" href="{% url exam_type|lower|add:':exam_scores_user' pk=exam.pk %}" title="Click to view results">Results</a>
<div class="d-flex align-items-center gap-2">
<div class="btn-group btn-group-sm" role="group">
{% if exam.active %}
<a class="btn btn-primary" href="{{ exam.get_take_url }}" target="_blank" title="Click to take exam">Start</a>
{% endif %}
{% if exam.publish_results %}
<a class="btn btn-outline-secondary" href="{% url exam_type|lower|add:':exam_scores_user' pk=exam.pk %}" title="Click to view results">Results</a>
{% endif %}
</div>
{% if not admin %}
<form method="post" action="{% url 'generic:toggle_hide_item' %}" hx-post="{% url 'generic:toggle_hide_item' %}" class="d-inline">
{% csrf_token %}
<input type="hidden" name="content_type_id" value="{{ exam.content_type_id }}">
<input type="hidden" name="object_id" value="{{ exam.id }}">
<button type="submit" class="btn btn-sm btn-link text-muted p-0 ms-1" title="{% if exam.is_hidden %}Unhide exam{% else %}Hide exam{% endif %}">
<i class="bi {% if exam.is_hidden %}bi-eye-slash-fill text-warning{% else %}bi-eye{% endif %}" style="font-size: 1.15rem;"></i>
</button>
</form>
{% endif %}
</div>
</li>
@@ -66,7 +92,7 @@
<h6 class="mt-3">{{ exam_type|title }}</h6>
<ul class="list-group">
{% for exam in exams %}
<li class="list-group-item d-flex justify-content-between align-items-center">
<li class="list-group-item d-flex justify-content-between align-items-center {% if exam.is_hidden %}opacity-50 bg-secondary bg-opacity-10{% endif %}">
<div>
{% if admin %}
<a href="{% url exam_type|add:':exam_scores_user_admin' pk=exam.pk user_id=user.pk %}">{{ exam }}</a>
@@ -75,8 +101,21 @@
{% endif %}
{% if exam.active %}<span class="badge bg-success ms-2">Active</span>{% endif %}
{% if exam.publish_results %}<span class="badge bg-info text-dark ms-2">Results Published</span>{% endif %}
{% if exam.is_hidden %}<span class="badge bg-warning text-dark ms-2">Hidden</span>{% endif %}
</div>
<div class="d-flex align-items-center gap-2">
{% if not admin %}
<form method="post" action="{% url 'generic:toggle_hide_item' %}" hx-post="{% url 'generic:toggle_hide_item' %}" class="d-inline">
{% csrf_token %}
<input type="hidden" name="content_type_id" value="{{ exam.content_type_id }}">
<input type="hidden" name="object_id" value="{{ exam.id }}">
<button type="submit" class="btn btn-sm btn-link text-muted p-0 ms-1" title="{% if exam.is_hidden %}Unhide exam{% else %}Hide exam{% endif %}">
<i class="bi {% if exam.is_hidden %}bi-eye-slash-fill text-warning{% else %}bi-eye{% endif %}" style="font-size: 1.15rem;"></i>
</button>
</form>
{% endif %}
<div class="small text-muted">&nbsp;</div>
</div>
<div class="small text-muted">&nbsp;</div>
</li>
{% endfor %}
</ul>
@@ -94,7 +133,7 @@
<p class="text-muted mb-2">Available, in-progress, and completed Atlas collections for this user.</p>
<div
id="atlas-collections-scores"
hx-get="{% url 'atlas:user_collections' %}?user_id={{ cid_user.id }}"
hx-get="{% url 'atlas:user_collections' %}?user_id={{ cid_user.id }}{% if show_hidden %}&show_hidden=1{% endif %}"
hx-trigger="load"
hx-target="this"
hx-swap="innerHTML">