Add option to reveal respondent identities in exam review responses
This commit is contained in:
@@ -1,13 +1,28 @@
|
|||||||
{# Responses partial for anatomy question within an exam. HTMX-loadable. #}
|
{# Responses partial for anatomy question within an exam. HTMX-loadable. #}
|
||||||
<div id="anatomy-responses-container">
|
<div id="anatomy-responses-container">
|
||||||
<h6>Responses in this exam</h6>
|
<div class="d-flex justify-content-between align-items-center mb-2">
|
||||||
<div class="small text-muted mb-2">List of candidate answers recorded for this question in the current exam.</div>
|
<div>
|
||||||
|
<h6 class="mb-0">Responses in this exam</h6>
|
||||||
|
<div class="small text-muted">List of candidate answers recorded for this question in the current exam.</div>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
{% if not reveal_respondents %}
|
||||||
|
<button class="btn btn-sm btn-outline-primary" hx-get="?reveal=1" hx-target="#anatomy-responses-container" hx-swap="outerHTML">Show respondents</button>
|
||||||
|
{% else %}
|
||||||
|
<button class="btn btn-sm btn-outline-secondary" hx-get="?" hx-target="#anatomy-responses-container" hx-swap="outerHTML">Hide 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 ua.user %}
|
{% if ua.user %}
|
||||||
|
{% if reveal_respondents %}
|
||||||
<strong>{{ ua.user.get_full_name|default:ua.user.username }}</strong>
|
<strong>{{ ua.user.get_full_name|default:ua.user.username }}</strong>
|
||||||
|
{% else %}
|
||||||
|
<strong>Respondent {{ forloop.counter }}</strong>
|
||||||
|
{% endif %}
|
||||||
{% else %}
|
{% else %}
|
||||||
<strong>Anonymous</strong>
|
<strong>Anonymous</strong>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|||||||
@@ -278,12 +278,17 @@ 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()
|
||||||
|
|
||||||
|
# Allow an HTMX-driven reveal of respondent names. Default: anonymised.
|
||||||
|
reveal = request.GET.get("reveal", "0")
|
||||||
|
reveal_respondents = str(reveal).lower() in ("1", "true", "yes", "on")
|
||||||
|
|
||||||
context = {
|
context = {
|
||||||
"exam": exam,
|
"exam": exam,
|
||||||
"question": question,
|
"question": question,
|
||||||
"q_index": q_index,
|
"q_index": q_index,
|
||||||
"app_name": "anatomy",
|
"app_name": "anatomy",
|
||||||
"exam_user_answers": exam_user_answers,
|
"exam_user_answers": exam_user_answers,
|
||||||
|
"reveal_respondents": reveal_respondents,
|
||||||
}
|
}
|
||||||
|
|
||||||
return render(request, "anatomy/partials/exam_review_question_responses_fragment.html", context)
|
return render(request, "anatomy/partials/exam_review_question_responses_fragment.html", context)
|
||||||
|
|||||||
Reference in New Issue
Block a user