Add exam review question responses and summary views with HTMX support
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
{# Responses partial for physics question within an exam. HTMX-loadable. #}
|
||||
<div id="physics-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">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 'physics:exam_review_question_responses' exam.pk q_index %}" hx-target="#physics-responses-container" hx-swap="outerHTML">Hide respondents</button>
|
||||
{% else %}
|
||||
<button class="btn btn-sm btn-outline-primary" hx-get="{% url 'physics:exam_review_question_responses' exam.pk q_index %}?reveal=1" hx-target="#physics-responses-container" hx-swap="outerHTML">Show respondents</button>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<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 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>
|
||||
{# Physics scoring may be numeric; show a simple badge if fully correct according to score field where present #}
|
||||
{% if ua.score %}
|
||||
{% if ua.score|stringformat:'s' == '5' %}
|
||||
<span class="badge bg-success">Correct</span>
|
||||
{% else %}
|
||||
<span class="badge bg-secondary">Score: {{ ua.score }}</span>
|
||||
{% endif %}
|
||||
{% else %}
|
||||
<span class="badge bg-light text-muted">Unmarked</span>
|
||||
{% endif %}
|
||||
</div>
|
||||
</li>
|
||||
{% empty %}
|
||||
<li class="list-group-item">No responses recorded for this exam.</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
@@ -0,0 +1,52 @@
|
||||
{# Aggregated response summary partial for physics questions (HTMX-loadable) #}
|
||||
<div id="physics-response-summary-content">
|
||||
{% if exam_response_total %}
|
||||
<div class="small text-muted mb-2">Total responses: {{ exam_response_total }}</div>
|
||||
<div class="row mb-2">
|
||||
<div class="col-auto">Correct:</div>
|
||||
<div class="col">
|
||||
{% if exam_response_correct_count is not None %}
|
||||
<strong>{{ exam_response_correct_count }}</strong>
|
||||
{% if exam_response_correct_pct is not None %}
|
||||
<span class="text-muted">({{ exam_response_correct_pct }}%)</span>
|
||||
{% endif %}
|
||||
{% else %}
|
||||
<span class="text-muted">N/A</span>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="list-group mb-2">
|
||||
{# Render top-level answer breakdown from exam_response_counts and pcts #}
|
||||
{% for key, count in exam_response_counts.items %}
|
||||
<div class="list-group-item">
|
||||
<div class="d-flex w-100 justify-content-between align-items-center">
|
||||
<div>{{ key }}</div>
|
||||
<div class="text-end"><strong>{{ count }}</strong> <small class="text-muted">{{ exam_response_pcts|get_item:key|default:0 }}%</small></div>
|
||||
</div>
|
||||
<div class="progress mt-2" style="height:12px;">
|
||||
<div class="progress-bar bg-primary" role="progressbar" style="width: {{ exam_response_pcts|get_item:key|default:0 }}%;" aria-valuenow="{{ exam_response_pcts|get_item:key|default:0 }}" aria-valuemin="0" aria-valuemax="100"></div>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<div class="d-flex justify-content-between align-items-center">
|
||||
<h6 class="mb-1">Correct answer</h6>
|
||||
<button class="btn btn-sm btn-outline-primary" type="button" data-bs-toggle="collapse" data-bs-target="#correct-answer-{{ q_index }}" aria-expanded="false" aria-controls="correct-answer-{{ q_index }}">
|
||||
Show
|
||||
</button>
|
||||
</div>
|
||||
<div class="collapse mt-2" id="correct-answer-{{ q_index }}">
|
||||
{% if correct_answer %}
|
||||
<div class="small">{{ correct_answer }}</div>
|
||||
{% else %}
|
||||
<div class="small text-muted">No correct answer available.</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="small text-muted">No responses recorded for this question in the exam yet.</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
Reference in New Issue
Block a user