Add option to reveal respondent identities in exam review responses
This commit is contained in:
@@ -1,30 +1,43 @@
|
||||
{# Partial: responses for a question within an exam. Rendered server-side or via HTMX. #}
|
||||
<div id="responses-container">
|
||||
<h6>Responses in this exam</h6>
|
||||
<div class="small text-muted mb-2">List of candidate answers recorded for this question in the current exam.</div>
|
||||
<div class="d-flex justify-content-between align-items-center mb-2">
|
||||
<div class="small text-muted">List of candidate answers recorded for this question in the current exam.</div>
|
||||
<div>
|
||||
{% if reveal_respondents %}
|
||||
<button class="btn btn-sm btn-outline-secondary" hx-get="{% url 'sbas:exam_review_question_responses' exam.pk q_index %}" hx-target="#responses-container" hx-swap="outerHTML">Hide respondents</button>
|
||||
{% else %}
|
||||
<button class="btn btn-sm btn-outline-primary" hx-get="{% url 'sbas:exam_review_question_responses' exam.pk q_index %}?reveal=1" hx-target="#responses-container" hx-swap="outerHTML">Show respondents</button>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<ul class="list-group">
|
||||
<ul class="list-group">
|
||||
{% for ua in exam_user_answers %}
|
||||
<li class="list-group-item d-flex justify-content-between align-items-start">
|
||||
<div>
|
||||
{% if ua.user %}
|
||||
<strong>{{ ua.user.get_full_name|default:ua.user.username }}</strong>
|
||||
{% else %}
|
||||
<strong>Anonymous</strong>
|
||||
{% endif %}
|
||||
<div>Answer: <strong>{{ ua.answer }}</strong></div>
|
||||
{% if ua.created_date %}
|
||||
<div class="small text-muted">Answered: {{ ua.created_date }}</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div>
|
||||
{% if ua.answer == question.best_answer %}
|
||||
<span class="badge bg-success">Correct</span>
|
||||
{% else %}
|
||||
<span class="badge bg-secondary">Incorrect</span>
|
||||
{% endif %}
|
||||
</div>
|
||||
</li>
|
||||
{% empty %}
|
||||
<li class="list-group-item">No responses recorded for this exam.</li>
|
||||
{% endfor %}
|
||||
{% for ua in exam_user_answers %}
|
||||
<li class="list-group-item d-flex justify-content-between align-items-start">
|
||||
<div>
|
||||
{% if reveal_respondents %}
|
||||
{% if ua.user %}
|
||||
<strong>{{ ua.user.get_full_name|default:ua.user.username }}</strong>
|
||||
{% else %}
|
||||
<strong>Anonymous</strong>
|
||||
{% endif %}
|
||||
{% else %}
|
||||
<strong>Respondent {{ forloop.counter }}</strong>
|
||||
{% endif %}
|
||||
<div>Answer: <strong>{{ ua.answer }}</strong></div>
|
||||
{% if ua.created_date %}
|
||||
<div class="small text-muted">Answered: {{ ua.created_date }}</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div>
|
||||
{% if ua.answer == question.best_answer %}
|
||||
<span class="badge bg-success">Correct</span>
|
||||
{% else %}
|
||||
<span class="badge bg-secondary">Incorrect</span>
|
||||
{% endif %}
|
||||
</div>
|
||||
</li>
|
||||
{% empty %}
|
||||
<li class="list-group-item">No responses recorded for this exam.</li>
|
||||
{% endfor %}
|
||||
|
||||
@@ -115,6 +115,12 @@ def exam_review_question_responses(request, pk: int, q_index: int):
|
||||
except Exception:
|
||||
exam_user_answers = question.cid_user_answers.all()
|
||||
|
||||
# Optionally reveal actual respondent identities when requested (HTMX or query param).
|
||||
# Default behaviour is anonymous listing; when `reveal=1` is present we'll include
|
||||
# the real user names in the fragment.
|
||||
reveal_flag = str(request.GET.get("reveal", "")).lower() in ("1", "true", "on")
|
||||
context["reveal_respondents"] = reveal_flag
|
||||
|
||||
context["exam_user_answers"] = exam_user_answers
|
||||
|
||||
return render(request, "sbas/partials/exam_review_question_responses_fragment.html", context)
|
||||
|
||||
Reference in New Issue
Block a user