.
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
</td>
|
||||
{% for cid in cids %}
|
||||
{% with by_question|get_item:question|get_item:cid as ans_score %}
|
||||
<td class="user-answer-score-{{ans_score.1}}" title="answer score: {{ans_score.1}} [{{ans_score.2}}]">{{ans_score.0}}</td>
|
||||
<td class="user-answer-score-{{ans_score.1}} col-cid-cell col-cid-{{ cid|slugify }}" title="answer score: {{ans_score.1}} [{{ans_score.2}}]" data-cid-name="{{ cids_user_id_map|get_item:cid|lower }}" data-cid-val="{{ cid|lower }}">{{ans_score.0}}</td>
|
||||
{% endwith %}
|
||||
{% endfor %}
|
||||
</tr>
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
<li class="nav-item"><a class="nav-link" href="{% url 'rapids:exam_overview' pk=exam.pk %}">Overview</a></li>
|
||||
{% if exam.exam_mode %}
|
||||
<li class="nav-item"><a class="nav-link" href="{% url 'rapids:mark_overview' pk=exam.pk %}">Mark</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="{% url 'rapids:mark2_overview' pk=exam.pk %}">Mark2</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="{% url 'rapids:exam_scores_all' pk=exam.pk %}">Scores</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="{% url 'rapids:exam_cids' exam_id=exam.pk %}">Candidates</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="{% url 'rapids:exam_stats' exam_id=exam.pk %}">Stats</a></li>
|
||||
|
||||
@@ -0,0 +1,314 @@
|
||||
{% extends 'rapids/exams.html' %}
|
||||
|
||||
{% block content %}
|
||||
<div class="row">
|
||||
<div class="col-md-6" id="main-col">
|
||||
<div class="card mb-3 bg-dark text-light border-secondary">
|
||||
<div class="card-body">
|
||||
<div class="d-flex justify-content-between align-items-start">
|
||||
<div>
|
||||
<h5 class="card-title mb-1">Marking question {{ question_details.current }} of {{ question_details.total }}</h5>
|
||||
<div class="mb-2">
|
||||
<a class="btn btn-sm btn-outline-secondary me-1" href="{% url 'rapids:question_detail' question.id %}" title="View the Question">View</a>
|
||||
<a class="btn btn-sm btn-outline-secondary me-1" href="{% url 'rapids:rapid_update' question.id %}" title="Edit the Question">Edit</a>
|
||||
{% if request.user.is_superuser %}
|
||||
<a class="btn btn-sm btn-outline-secondary me-1" href="{% url 'admin:rapids_rapid_change' question.id %}" title="Admin Edit">Admin Edit</a>
|
||||
{% endif %}
|
||||
<a class="btn btn-sm btn-outline-secondary" href="{% url 'rapids:mark' exam.id question_number %}">Classic mark</a>
|
||||
</div>
|
||||
<h6 class="mb-1 text-info">{% if question.normal %}Normal film{% else %}Abnormal film{% endif %}</h6>
|
||||
{% if not question.normal %}
|
||||
<div class="small text-muted">Region: {{ question.get_regions }} | Abnormalities: {{ question.get_abnormalities }}</div>
|
||||
<div class="mt-2">Primary answer: <span id="primary-answer" class="text-warning fw-semibold" title="The primary answer of the question">{{ question.get_primary_answer }}</span></div>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="text-end">
|
||||
<button class="btn btn-sm btn-outline-primary" type="button" id="toggle-images">Toggle images</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mt-3">
|
||||
<form method="POST" class="post-form">{% csrf_token %}
|
||||
<p class="small text-muted">Click each answer to toggle through marks awarded (as per colour). This UI writes marks immediately.</p>
|
||||
<div class="d-flex justify-content-between align-items-center mb-2">
|
||||
<div></div>
|
||||
<div>
|
||||
{% if question_details.current > 1 %}
|
||||
<button type="submit" name="previous" class="btn btn-outline-secondary btn-sm me-1">Previous</button>
|
||||
{% endif %}
|
||||
<button type="submit" name="save" class="btn btn-primary btn-sm me-1">Save</button>
|
||||
{% if question_details.current < question_details.total %}
|
||||
<button type="submit" name="next" class="btn btn-outline-primary btn-sm me-1">Next</button>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="mb-2">
|
||||
<button class="btn btn-sm btn-outline-info me-1" hx-get="{% url 'rapids:mark2_exam_marked' exam.id question_number %}" hx-target="#exam-marked-container" hx-swap="innerHTML">Show exam-submitted answers</button>
|
||||
<button class="btn btn-sm btn-outline-info" hx-get="{% url 'rapids:mark2_question_marked' question.pk %}" hx-target="#question-marked-container" hx-swap="innerHTML">Show all stored answers for question</button>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<h6 class="mb-2">Answers</h6>
|
||||
<ul id="answer-list" class="list-group answer-list mb-3">
|
||||
{% include 'rapids/partials/_mark2_marked_list_fragment.html' %}
|
||||
{% include 'rapids/partials/_mark2_unmarked_list_fragment.html' %}
|
||||
</ul>
|
||||
<div id="exam-marked-container" class="mt-2"></div>
|
||||
<div id="question-marked-container" class="mt-2"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mt-3">
|
||||
<div class="small text-muted key">Key: <span class="key-item correct text-success fw-semibold">2 Marks</span>, <span class="key-item half-correct text-warning fw-semibold">1 Mark</span>, <span class="key-item incorrect text-danger fw-semibold">0 Marks</span></div>
|
||||
</div>
|
||||
|
||||
<span class="visually-hidden">{{ form.as_p }}</span>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-6" id="dicom-col">
|
||||
<div id="single-dicom-viewer" class="marking-dicom" data-images="{{ question.get_image_url_array }}" data-annotations='{{ question.get_image_annotations }}'></div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
{% block css %}
|
||||
<style>
|
||||
.answer { cursor: pointer; }
|
||||
.answer.correct { color: #2a9d3f !important; background-color: transparent; }
|
||||
.answer.half-correct { color: #ffb020 !important; background-color: transparent; }
|
||||
.answer.incorrect { color: #d3413a !important; background-color: transparent; }
|
||||
.answer.not-marked { color: inherit; background-color: transparent; }
|
||||
.answer-list .list-group-item pre { margin: 0; font-family: monospace; white-space: pre-wrap; }
|
||||
.mark-controls { display:flex; gap:0.25rem; }
|
||||
.mark-btn { padding: 0.15rem 0.4rem; font-size: 0.8rem; }
|
||||
|
||||
.marked-correct { border-left: 4px solid #2a9d3f; }
|
||||
.marked-half-correct { border-left: 4px solid #ffb020; }
|
||||
.marked-incorrect { border-left: 4px solid #d3413a; }
|
||||
|
||||
.key .key-item { display:inline-block; padding-left:8px; margin-left:6px; }
|
||||
.key .key-item.correct { border-left: 8px solid #2a9d3f; }
|
||||
.key .key-item.half-correct { border-left: 8px solid #ffb020; }
|
||||
.key .key-item.incorrect { border-left: 8px solid #d3413a; }
|
||||
.answer-actions { min-width: 6rem; }
|
||||
.answer-actions .action-icon { margin-left: 0.5rem; }
|
||||
.answer-actions .copy-to-clipboard { cursor: pointer; }
|
||||
.mark-btn.active { background-color: #0d6efd; color: #fff; border-color: #0d6efd; }
|
||||
</style>
|
||||
{% endblock %}
|
||||
|
||||
{% block js %}
|
||||
<script>
|
||||
(function(){
|
||||
function getCookie(name) {
|
||||
let cookieValue = null;
|
||||
if (document.cookie && document.cookie !== '') {
|
||||
const cookies = document.cookie.split(';');
|
||||
for (let i = 0; i < cookies.length; i++) {
|
||||
const cookie = cookies[i].trim();
|
||||
if (cookie.substring(0, name.length + 1) === (name + '=')) {
|
||||
cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return cookieValue;
|
||||
}
|
||||
const csrftoken = getCookie('csrftoken');
|
||||
|
||||
// Delegated click handler for answers
|
||||
document.addEventListener('click', function(e){
|
||||
if (e.target.closest('.answer-actions') || e.target.closest('.mark-controls') || e.target.closest('.copy-to-clipboard')) return;
|
||||
|
||||
let spanEl = e.target.closest('span.answer');
|
||||
if (!spanEl) {
|
||||
const li = e.target.closest('#answer-list li');
|
||||
if (!li) return;
|
||||
spanEl = li.querySelector('span.answer');
|
||||
if (!spanEl) return;
|
||||
}
|
||||
|
||||
if (!spanEl.classList.contains('correct') && !spanEl.classList.contains('half-correct') && !spanEl.classList.contains('incorrect') && !spanEl.classList.contains('not-marked')) {
|
||||
spanEl.classList.add('not-marked');
|
||||
}
|
||||
|
||||
const states = ['not-marked', 'correct', 'half-correct', 'incorrect'];
|
||||
let currentState = 'not-marked';
|
||||
for (let p of spanEl.classList) {
|
||||
if (states.includes(p)) { currentState = p; break; }
|
||||
}
|
||||
let idx = (states.indexOf(currentState) + 1) % states.length;
|
||||
const newState = states[idx];
|
||||
|
||||
let numeric = null;
|
||||
if (newState === 'correct') numeric = 2;
|
||||
else if (newState === 'half-correct') numeric = 1;
|
||||
else if (newState === 'incorrect') numeric = 0;
|
||||
|
||||
setMarkForSpan(spanEl, numeric);
|
||||
}, false);
|
||||
|
||||
function updateMarkedAnswersField() {
|
||||
const marked = { 'correct': [], 'half-correct': [], 'incorrect': [] };
|
||||
document.querySelectorAll('#answer-list span.answer').forEach(function(el) {
|
||||
if (el.classList.contains('correct')) marked.correct.push((el.title || el.textContent).trim());
|
||||
else if (el.classList.contains('half-correct')) marked['half-correct'].push((el.title || el.textContent).trim());
|
||||
else if (el.classList.contains('incorrect')) marked.incorrect.push((el.title || el.textContent).trim());
|
||||
});
|
||||
|
||||
let hidden = document.getElementById('id_marked_answers');
|
||||
if (!hidden) {
|
||||
hidden = document.createElement('input');
|
||||
hidden.type = 'hidden';
|
||||
hidden.name = 'marked_answers';
|
||||
hidden.id = 'id_marked_answers';
|
||||
const form = document.querySelector('form.post-form');
|
||||
if (form) form.appendChild(hidden);
|
||||
}
|
||||
hidden.value = JSON.stringify(marked);
|
||||
}
|
||||
|
||||
function attachNumericControls() {
|
||||
function makeButton(label, cls) {
|
||||
const b = document.createElement('button');
|
||||
b.type = 'button';
|
||||
b.className = 'btn btn-sm btn-outline-secondary me-1 mark-btn ' + cls;
|
||||
b.textContent = label;
|
||||
return b;
|
||||
}
|
||||
|
||||
document.querySelectorAll('.answer-list li').forEach(function(li) {
|
||||
if (li.querySelector('.mark-controls')) return;
|
||||
const span = li.querySelector('span.answer');
|
||||
if (!span) return;
|
||||
if (!span.classList.contains('correct') && !span.classList.contains('half-correct') && !span.classList.contains('incorrect') && !span.classList.contains('not-marked')) {
|
||||
span.classList.add('not-marked');
|
||||
}
|
||||
const controls = document.createElement('div');
|
||||
controls.className = 'mark-controls mt-2';
|
||||
const b2 = makeButton('2', 'mark-2');
|
||||
const b1 = makeButton('1', 'mark-1');
|
||||
const b0 = makeButton('0', 'mark-0');
|
||||
const bClear = makeButton('⨯', 'mark-clear');
|
||||
|
||||
controls.appendChild(b2);
|
||||
controls.appendChild(b1);
|
||||
controls.appendChild(b0);
|
||||
controls.appendChild(bClear);
|
||||
li.appendChild(controls);
|
||||
|
||||
b2.addEventListener('click', function(){ setMarkForSpan(span, 2); });
|
||||
b1.addEventListener('click', function(){ setMarkForSpan(span, 1); });
|
||||
b0.addEventListener('click', function(){ setMarkForSpan(span, 0); });
|
||||
bClear.addEventListener('click', function(){ setMarkForSpan(span, null); });
|
||||
|
||||
(function(){
|
||||
let state = null;
|
||||
if (span.classList.contains('correct')) state = 2;
|
||||
else if (span.classList.contains('half-correct')) state = 1;
|
||||
else if (span.classList.contains('incorrect')) state = 0;
|
||||
[b2, b1, b0, bClear].forEach(b => b.classList.remove('active'));
|
||||
if (state === 2) b2.classList.add('active');
|
||||
else if (state === 1) b1.classList.add('active');
|
||||
else if (state === 0) b0.classList.add('active');
|
||||
else bClear.classList.add('active');
|
||||
})();
|
||||
});
|
||||
}
|
||||
|
||||
function setMarkForSpan(el, numeric) {
|
||||
const li = el.closest('li');
|
||||
let state = 'not-marked';
|
||||
if (numeric === 2) state = 'correct';
|
||||
else if (numeric === 1) state = 'half-correct';
|
||||
else if (numeric === 0) state = 'incorrect';
|
||||
el.className = 'answer ' + state;
|
||||
if (li) {
|
||||
li.classList.remove('marked-correct','marked-half-correct','marked-incorrect','marked-item');
|
||||
if (state === 'correct') {
|
||||
li.classList.add('marked-item','marked-correct');
|
||||
} else if (state === 'half-correct') {
|
||||
li.classList.add('marked-item','marked-half-correct');
|
||||
} else if (state === 'incorrect') {
|
||||
li.classList.add('marked-item','marked-incorrect');
|
||||
}
|
||||
}
|
||||
try {
|
||||
if (li) {
|
||||
const btn2 = li.querySelector('.mark-2');
|
||||
const btn1 = li.querySelector('.mark-1');
|
||||
const btn0 = li.querySelector('.mark-0');
|
||||
const btnClear = li.querySelector('.mark-clear');
|
||||
[btn2, btn1, btn0, btnClear].forEach(b => { if (b) { b.classList.remove('active'); } });
|
||||
if (numeric === 2 && btn2) btn2.classList.add('active');
|
||||
else if (numeric === 1 && btn1) btn1.classList.add('active');
|
||||
else if (numeric === 0 && btn0) btn0.classList.add('active');
|
||||
else if (numeric === null && btnClear) btnClear.classList.add('active');
|
||||
}
|
||||
} catch (err) {}
|
||||
|
||||
updateMarkedAnswersField();
|
||||
}
|
||||
|
||||
function initMark2() {
|
||||
attachNumericControls();
|
||||
}
|
||||
|
||||
if (document.readyState === 'loading') {
|
||||
document.addEventListener('DOMContentLoaded', initMark2);
|
||||
} else {
|
||||
initMark2();
|
||||
}
|
||||
|
||||
document.addEventListener('htmx:afterSwap', function(evt) {
|
||||
initMark2();
|
||||
});
|
||||
|
||||
const postForm = document.querySelector('form.post-form');
|
||||
if (postForm) {
|
||||
postForm.addEventListener('submit', function(e){
|
||||
try { updateMarkedAnswersField(); } catch (err) {}
|
||||
});
|
||||
}
|
||||
|
||||
document.addEventListener('click', function(e){
|
||||
const btn = e.target.closest('.copy-to-clipboard');
|
||||
if (!btn) return;
|
||||
const text = btn.getAttribute('data-text');
|
||||
if (!text) return;
|
||||
try {
|
||||
navigator.clipboard.writeText(text);
|
||||
const prev = btn.textContent;
|
||||
btn.textContent = 'Copied';
|
||||
setTimeout(function(){ btn.textContent = prev; }, 1200);
|
||||
} catch (err) {
|
||||
console.warn('copy failed', err);
|
||||
}
|
||||
});
|
||||
|
||||
// Toggle images handler matching classic mode
|
||||
const toggleBtn = document.getElementById("toggle-images");
|
||||
if (toggleBtn) {
|
||||
toggleBtn.addEventListener('click', function() {
|
||||
const dicomCol = document.getElementById("dicom-col");
|
||||
const mainCol = document.getElementById("main-col");
|
||||
if (dicomCol && mainCol) {
|
||||
if (dicomCol.style.display === "none") {
|
||||
dicomCol.style.display = "";
|
||||
mainCol.className = "col-md-6";
|
||||
} else {
|
||||
dicomCol.style.display = "none";
|
||||
mainCol.className = "col-md-12";
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
})();
|
||||
</script>
|
||||
{% endblock %}
|
||||
@@ -0,0 +1,79 @@
|
||||
{% extends 'rapids/exams.html' %}
|
||||
|
||||
{% block content %}
|
||||
<div class="container my-4 rapids">
|
||||
<div class="d-flex justify-content-between align-items-start mb-3">
|
||||
<div>
|
||||
<h2 class="h4 mb-1">Mark2 — Marking: {{ exam }}</h2>
|
||||
</div>
|
||||
<div class="text-end">
|
||||
<div class="btn-group me-2" role="group" aria-label="listing actions">
|
||||
<button class="btn btn-sm btn-outline-secondary show-all-button">Show all</button>
|
||||
<button class="btn btn-sm btn-outline-secondary show-unmarked-button">Show unmarked</button>
|
||||
</div>
|
||||
<a href="{% url 'rapids:mark2' exam_pk=exam.pk sk=0 %}" class="btn btn-sm btn-primary">Start mark2</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card bg-dark text-light border-secondary">
|
||||
<div class="card-body p-2">
|
||||
<ul class="list-group list-group-flush" id="question-mark-list">
|
||||
{% for question, unmarked_count, unmarked_count2 in question_unmarked_map %}
|
||||
<li class="list-group-item bg-dark text-light border-secondary d-flex justify-content-between align-items-start" data-unmarked="{{ unmarked_count }}">
|
||||
<div class="me-3">
|
||||
<a href="{% url 'rapids:mark2' exam_pk=exam.pk sk=forloop.counter0 %}" class="fw-semibold text-info">Question {{ forloop.counter }}:</a>
|
||||
<div class="small text-truncate" style="max-width:60vw;">{{ question }}</div>
|
||||
</div>
|
||||
<div class="text-end">
|
||||
<div class="small text-muted">Unmarked</div>
|
||||
{% if unmarked_count > 0 %}
|
||||
<span class="badge bg-danger">{{ unmarked_count }}</span>
|
||||
{% else %}
|
||||
<span class="badge bg-secondary">{{ unmarked_count }}</span>
|
||||
{% endif %}
|
||||
</div>
|
||||
</li>
|
||||
{% empty %}
|
||||
<li class="list-group-item bg-dark text-muted small">No questions found.</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
(function(){
|
||||
function $(sel, ctx){ return (ctx||document).querySelector(sel); }
|
||||
function $all(sel, ctx){ return Array.from((ctx||document).querySelectorAll(sel)); }
|
||||
|
||||
var showAllBtn = $('.show-all-button');
|
||||
var showUnmarkedBtn = $('.show-unmarked-button');
|
||||
var list = $('#question-mark-list');
|
||||
if (!list) return;
|
||||
|
||||
function showAll(){
|
||||
$all('#question-mark-list .list-group-item').forEach(function(li){ li.classList.remove('d-none'); });
|
||||
showAllBtn && showAllBtn.classList.add('active');
|
||||
showUnmarkedBtn && showUnmarkedBtn.classList.remove('active');
|
||||
}
|
||||
|
||||
function showUnmarked(){
|
||||
$all('#question-mark-list .list-group-item').forEach(function(li){
|
||||
var u = parseInt(li.getAttribute('data-unmarked') || '0', 10);
|
||||
if (u > 0) li.classList.remove('d-none'); else li.classList.add('d-none');
|
||||
});
|
||||
showUnmarkedBtn && showUnmarkedBtn.classList.add('active');
|
||||
showAllBtn && showAllBtn.classList.remove('active');
|
||||
}
|
||||
|
||||
if (showAllBtn) showAllBtn.addEventListener('click', function(e){ e.preventDefault(); showAll(); });
|
||||
if (showUnmarkedBtn) showUnmarkedBtn.addEventListener('click', function(e){ e.preventDefault(); showUnmarked(); });
|
||||
|
||||
// Initialize to show all
|
||||
showAll();
|
||||
})();
|
||||
</script>
|
||||
<style>
|
||||
.show-all-button.active, .show-unmarked-button.active { box-shadow: inset 0 -2px 0 rgba(0,0,0,0.2); }
|
||||
</style>
|
||||
{% endblock %}
|
||||
@@ -0,0 +1,35 @@
|
||||
<div class="card mt-2 bg-dark text-light border-secondary">
|
||||
<div class="card-body">
|
||||
<h6 class="card-title">Edit stored answer</h6>
|
||||
<form hx-post="{% url 'rapids:mark2_edit_answer' %}" hx-target="closest .card" hx-swap="outerHTML">
|
||||
{% csrf_token %}
|
||||
<input type="hidden" name="question_pk" value="{{ question.pk }}">
|
||||
<input type="hidden" name="original" value="{{ original }}">
|
||||
{% if exam_pk %}
|
||||
<input type="hidden" name="exam_pk" value="{{ exam_pk }}">
|
||||
{% endif %}
|
||||
{% if sk is not None %}
|
||||
<input type="hidden" name="sk" value="{{ sk }}">
|
||||
{% endif %}
|
||||
|
||||
<div class="mb-2">
|
||||
<label class="form-label">Original</label>
|
||||
<pre class="small bg-secondary text-light p-2">{{ original }}</pre>
|
||||
</div>
|
||||
|
||||
<div class="mb-2">
|
||||
<label class="form-label">New answer text</label>
|
||||
<textarea class="form-control bg-dark text-light border-secondary" name="new_answer" rows="3">{% if existing %}{{ existing.answer }}{% else %}{{ original }}{% endif %}</textarea>
|
||||
</div>
|
||||
|
||||
<div class="d-flex justify-content-end gap-2">
|
||||
<button type="submit" class="btn btn-primary btn-sm">Save</button>
|
||||
{% if exam_pk and sk is not None %}
|
||||
<button type="button" class="btn btn-outline-secondary btn-sm" hx-get="{% url 'rapids:mark2_exam_marked' exam_pk sk %}" hx-swap="outerHTML" hx-target="closest .card">Cancel</button>
|
||||
{% else %}
|
||||
<button type="button" class="btn btn-outline-secondary btn-sm" _="on click remove .card">Cancel</button>
|
||||
{% endif %}
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,78 @@
|
||||
{% comment %}List of distinct answers submitted within this exam for the question, with counts and mark badges{% endcomment %}
|
||||
<div class="card mt-2 bg-dark text-light border-secondary">
|
||||
<div class="card-body">
|
||||
<style>
|
||||
/* Hide edit buttons and mark-action forms by default; show only when card has editing-enabled */
|
||||
.card .edit-btn { display: none !important; }
|
||||
.card.editing-enabled .edit-btn { display: inline-block !important; }
|
||||
.card .mark-actions { display: none !important; }
|
||||
.card.editing-enabled .mark-actions { display: inline-block !important; }
|
||||
</style>
|
||||
<div class="d-flex justify-content-between align-items-center mb-2">
|
||||
<h6 class="card-title mb-0">Answers submitted in this exam</h6>
|
||||
<div class="d-flex gap-2 align-items-center">
|
||||
<div class="btn-group btn-group-sm" role="group" aria-label="Order">
|
||||
<button class="btn btn-sm btn-outline-primary{% if request.GET.order == 'count' or not request.GET.order %} active{% endif %}" hx-get="{{ request.path }}?order=count" hx-swap="outerHTML" hx-target="closest .card">By count</button>
|
||||
<button class="btn btn-sm btn-outline-primary{% if request.GET.order == 'mark' %} active{% endif %}" hx-get="{{ request.path }}?order=mark" hx-swap="outerHTML" hx-target="closest .card">By score</button>
|
||||
</div>
|
||||
<button type="button" class="btn btn-sm btn-outline-secondary" onclick="this.closest('.card').classList.toggle('editing-enabled'); this.textContent = this.closest('.card').classList.contains('editing-enabled') ? 'Disable editing' : 'Enable editing'">Enable editing</button>
|
||||
</div>
|
||||
</div>
|
||||
{% if not items %}
|
||||
<div class="small text-muted">No answers submitted in this exam.</div>
|
||||
{% else %}
|
||||
<ul class="list-group">
|
||||
{% for it in items %}
|
||||
<li class="list-group-item bg-dark text-light border-secondary d-flex justify-content-between align-items-center">
|
||||
<div class="flex-grow-1 me-3"><pre class="mb-0 text-light">{{ it.answer }}</pre></div>
|
||||
<div class="text-end d-flex align-items-center gap-2">
|
||||
{# Stored mark badge #}
|
||||
{% if it.mark == 'correct' %}
|
||||
<span class="badge bg-success me-1" title="Stored answer marked as correct (2)">2</span>
|
||||
{% elif it.mark == 'half-correct' %}
|
||||
<span class="badge bg-warning text-dark me-1" title="Stored answer marked as half-correct (1)">1</span>
|
||||
{% elif it.mark == 'incorrect' %}
|
||||
<span class="badge bg-danger me-1" title="Stored answer marked as incorrect (0)">0</span>
|
||||
{% else %}
|
||||
<span class="badge bg-secondary me-1" title="No stored mark for this answer">-</span>
|
||||
{% endif %}
|
||||
|
||||
{# Submission count badge #}
|
||||
<span class="badge bg-light text-dark me-2" title="Submitted {{ it.count }} times">{{ it.count }}</span>
|
||||
|
||||
<form hx-post="{% url 'rapids:mark2_toggle_answer' %}" hx-target="closest .card" hx-swap="outerHTML" class="d-inline mark-actions">
|
||||
{% csrf_token %}
|
||||
<input type="hidden" name="question_pk" value="{{ question.pk }}">
|
||||
<input type="hidden" name="answer" value="{{ it.answer }}">
|
||||
<input type="hidden" name="exam_pk" value="{{ exam.pk }}">
|
||||
<input type="hidden" name="sk" value="{{ sk }}">
|
||||
<button class="btn btn-sm btn-outline-success" name="newmark" value="correct" title="Mark as correct (2)">2</button>
|
||||
<button class="btn btn-sm btn-outline-warning text-dark" name="newmark" value="half-correct" title="Mark as half-correct (1)">1</button>
|
||||
<button class="btn btn-sm btn-outline-danger" name="newmark" value="incorrect" title="Mark as incorrect (0)">0</button>
|
||||
<button class="btn btn-sm btn-outline-secondary" name="newmark" value="clear" title="Clear stored mark">⨯</button>
|
||||
</form>
|
||||
|
||||
<button class="btn btn-sm btn-outline-secondary edit-btn" hx-get="{% url 'rapids:mark2_edit_answer' %}?question_pk={{ question.pk }}&original={{ it.answer|urlencode }}&exam_pk={{ exam.pk }}&sk={{ sk }}" hx-target="closest .card" hx-swap="outerHTML" title="Edit stored answer">Edit</button>
|
||||
</div>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
(function(){
|
||||
document.querySelectorAll('.card').forEach(function(card){
|
||||
function update(){
|
||||
const enable = card.classList.contains('editing-enabled');
|
||||
card.querySelectorAll('.edit-btn').forEach(function(b){
|
||||
b.classList.toggle('d-none', !enable);
|
||||
});
|
||||
}
|
||||
update();
|
||||
const obs = new MutationObserver(update);
|
||||
obs.observe(card, { attributes: true, attributeFilter: ['class'] });
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
@@ -0,0 +1,43 @@
|
||||
{% comment %}Renders only the list items for already-marked answers (used as a partial){% endcomment %}
|
||||
{% for answer in correct_answers %}
|
||||
{% with answer_url=answer|urlencode:'' %}
|
||||
<li class="list-group-item bg-dark text-light border-secondary d-flex flex-column">
|
||||
<div class="d-flex align-items-center justify-content-between">
|
||||
<pre class="mb-0 me-3 flex-grow-1"><span class="answer correct text-success" title="{{ answer }}" data-answerurl="{% url 'rapids:question_user_answers_by_compare' question.pk answer_url %}">{{ answer }}</span></pre>
|
||||
<div class="answer-actions text-end">
|
||||
<a class="action-icon text-muted" href="https://www.google.com/search?q={{ answer_url }}" target="_blank" title="Search Google">🔍</a>
|
||||
<button type="button" class="action-icon btn btn-link p-0 copy-to-clipboard text-muted" data-text="{{ answer|escapejs }}" title="Copy to clipboard">📋</button>
|
||||
<a class="action-icon text-muted" href="{% url 'rapids:question_user_answers_by_compare' question.pk answer_url %}" target="_blank" title="View answers">🔗</a>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
{% endwith %}
|
||||
{% endfor %}
|
||||
{% for answer in half_mark_answers %}
|
||||
{% with answer_url=answer|urlencode:'' %}
|
||||
<li class="list-group-item bg-dark text-light border-secondary d-flex flex-column">
|
||||
<div class="d-flex align-items-center justify-content-between">
|
||||
<pre class="mb-0 me-3 flex-grow-1"><span class="answer half-correct text-warning" title="{{ answer }}" data-answerurl="{% url 'rapids:question_user_answers_by_compare' question.pk answer_url %}">{{ answer }}</span></pre>
|
||||
<div class="answer-actions text-end">
|
||||
<a class="action-icon text-muted" href="https://www.google.com/search?q={{ answer_url }}" target="_blank" title="Search Google">🔍</a>
|
||||
<button type="button" class="action-icon btn btn-link p-0 copy-to-clipboard text-muted" data-text="{{ answer|escapejs }}" title="Copy to clipboard">📋</button>
|
||||
<a class="action-icon text-muted" href="{% url 'rapids:question_user_answers_by_compare' question.pk answer_url %}" target="_blank" title="View answers">🔗</a>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
{% endwith %}
|
||||
{% endfor %}
|
||||
{% for answer in incorrect_answers %}
|
||||
{% with answer_url=answer|urlencode:'' %}
|
||||
<li class="list-group-item bg-dark text-light border-secondary d-flex flex-column">
|
||||
<div class="d-flex align-items-center justify-content-between">
|
||||
<pre class="mb-0 me-3 flex-grow-1"><span class="answer incorrect text-danger" title="{{ answer }}" data-answerurl="{% url 'rapids:question_user_answers_by_compare' question.pk answer_url %}">{{ answer }}</span></pre>
|
||||
<div class="answer-actions text-end">
|
||||
<a class="action-icon text-muted" href="https://www.google.com/search?q={{ answer_url }}" target="_blank" title="Search Google">🔍</a>
|
||||
<button type="button" class="action-icon btn btn-link p-0 copy-to-clipboard text-muted" data-text="{{ answer|escapejs }}" title="Copy to clipboard">📋</button>
|
||||
<a class="action-icon text-muted" href="{% url 'rapids:question_user_answers_by_compare' question.pk answer_url %}" target="_blank" title="View answers">🔗</a>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
{% endwith %}
|
||||
{% endfor %}
|
||||
@@ -0,0 +1,41 @@
|
||||
{% comment %}All stored Answer choices for this question grouped by status{% endcomment %}
|
||||
<div class="card mt-2 bg-dark text-light border-secondary">
|
||||
<div class="card-body">
|
||||
<h6 class="card-title">All stored answers for this question</h6>
|
||||
<style>
|
||||
.card .list-group-item pre { margin: 0; white-space: pre-wrap; word-break: break-word; }
|
||||
</style>
|
||||
<div class="row">
|
||||
<div class="col-12 col-lg-4">
|
||||
<h6>2 marks</h6>
|
||||
<ul class="list-group mb-2">
|
||||
{% for answer in correct_answers %}
|
||||
<li class="list-group-item bg-dark text-light border-secondary"><pre class="mb-0 text-light">{{ answer.answer }}</pre></li>
|
||||
{% empty %}
|
||||
<li class="list-group-item bg-dark text-muted border-secondary small">None</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
<div class="col-12 col-lg-4">
|
||||
<h6>1 mark</h6>
|
||||
<ul class="list-group mb-2">
|
||||
{% for answer in half_mark_answers %}
|
||||
<li class="list-group-item bg-dark text-light border-secondary"><pre class="mb-0 text-light">{{ answer.answer }}</pre></li>
|
||||
{% empty %}
|
||||
<li class="list-group-item bg-dark text-muted border-secondary small">None</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
<div class="col-12 col-lg-4">
|
||||
<h6>0 marks</h6>
|
||||
<ul class="list-group mb-2">
|
||||
{% for answer in incorrect_answers %}
|
||||
<li class="list-group-item bg-dark text-light border-secondary"><pre class="mb-0 text-light">{{ answer.answer }}</pre></li>
|
||||
{% empty %}
|
||||
<li class="list-group-item bg-dark text-muted border-secondary small">None</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,15 @@
|
||||
{% comment %}Renders only the list items for unmarked answers (used as a partial){% endcomment %}
|
||||
{% for answer in user_answers %}
|
||||
{% with answer_url=answer|urlencode:'' %}
|
||||
<li class="list-group-item bg-dark text-light border-secondary d-flex flex-column">
|
||||
<div class="d-flex align-items-center justify-content-between">
|
||||
<pre class="mb-0 me-3 flex-grow-1"><span class="answer not-marked text-light" title="{{ answer }}" data-answerurl="{% url 'rapids:question_user_answers_by_compare' question.pk answer_url %}">{{ answer }}</span></pre>
|
||||
<div class="answer-actions text-end">
|
||||
<a class="action-icon text-muted" href="https://www.google.com/search?q={{ answer_url }}" target="_blank" title="Search Google">🔍</a>
|
||||
<button type="button" class="action-icon btn btn-link p-0 copy-to-clipboard text-muted" data-text="{{ answer|escapejs }}" title="Copy to clipboard">📋</button>
|
||||
<a class="action-icon text-muted" href="{% url 'rapids:question_user_answers_by_compare' question.pk answer_url %}" target="_blank" title="View answers">🔗</a>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
{% endwith %}
|
||||
{% endfor %}
|
||||
Reference in New Issue
Block a user