Add option to reveal respondent identities in exam review responses
This commit is contained in:
@@ -1,17 +1,30 @@
|
|||||||
{# Partial: responses for a question within an exam. Rendered server-side or via HTMX. #}
|
{# Partial: responses for a question within an exam. Rendered server-side or via HTMX. #}
|
||||||
<div id="responses-container">
|
<div id="responses-container">
|
||||||
<h6>Responses in this exam</h6>
|
<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">
|
||||||
<ul class="list-group">
|
<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 %}
|
{% for ua in exam_user_answers %}
|
||||||
<li class="list-group-item d-flex justify-content-between align-items-start">
|
<li class="list-group-item d-flex justify-content-between align-items-start">
|
||||||
<div>
|
<div>
|
||||||
|
{% if reveal_respondents %}
|
||||||
{% if ua.user %}
|
{% if ua.user %}
|
||||||
<strong>{{ ua.user.get_full_name|default:ua.user.username }}</strong>
|
<strong>{{ ua.user.get_full_name|default:ua.user.username }}</strong>
|
||||||
{% else %}
|
{% else %}
|
||||||
<strong>Anonymous</strong>
|
<strong>Anonymous</strong>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% else %}
|
||||||
|
<strong>Respondent {{ forloop.counter }}</strong>
|
||||||
|
{% endif %}
|
||||||
<div>Answer: <strong>{{ ua.answer }}</strong></div>
|
<div>Answer: <strong>{{ ua.answer }}</strong></div>
|
||||||
{% if ua.created_date %}
|
{% if ua.created_date %}
|
||||||
<div class="small text-muted">Answered: {{ ua.created_date }}</div>
|
<div class="small text-muted">Answered: {{ ua.created_date }}</div>
|
||||||
|
|||||||
@@ -115,6 +115,12 @@ def exam_review_question_responses(request, pk: int, q_index: int):
|
|||||||
except Exception:
|
except Exception:
|
||||||
exam_user_answers = question.cid_user_answers.all()
|
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
|
context["exam_user_answers"] = exam_user_answers
|
||||||
|
|
||||||
return render(request, "sbas/partials/exam_review_question_responses_fragment.html", context)
|
return render(request, "sbas/partials/exam_review_question_responses_fragment.html", context)
|
||||||
|
|||||||
Reference in New Issue
Block a user