From b3304b6113186187c4ba27816d766b0755a48823 Mon Sep 17 00:00:00 2001 From: Ross Date: Mon, 4 Aug 2025 12:59:42 +0100 Subject: [PATCH] Enhance case collection update form with additional instructions and improve case detail links with icons --- .../atlas/casecollection_update_case.html | 1 + atlas/templates/atlas/collection_detail.html | 9 +- templates/exam_overview_js.html | 207 ++++++++++++------ 3 files changed, 147 insertions(+), 70 deletions(-) diff --git a/atlas/templates/atlas/casecollection_update_case.html b/atlas/templates/atlas/casecollection_update_case.html index cbd3dfea..d3a9d58e 100644 --- a/atlas/templates/atlas/casecollection_update_case.html +++ b/atlas/templates/atlas/casecollection_update_case.html @@ -3,6 +3,7 @@ {% load static %} {% block content %}

Update Cases for Case: {{ object.title }}

+ This form allows you to update the cases associated with this collection. You can add, remove, or reorder cases as needed. This functionality is also available on the collection overview page (which is likely easier to use).
{% csrf_token %} {% crispy form form.helper %} diff --git a/atlas/templates/atlas/collection_detail.html b/atlas/templates/atlas/collection_detail.html index ac40d30a..71a075f4 100644 --- a/atlas/templates/atlas/collection_detail.html +++ b/atlas/templates/atlas/collection_detail.html @@ -21,25 +21,26 @@
  • Case {{forloop.counter}} : {{casedetail.case.title}} - (setup default display + ( {% if casedetail.default_viewerstate %} {% endif %} ) {% if collection.collection_type == "QUE" %} - (edit questions -   + ( {% if casedetail.question_schema %} {% else %} {% endif %} + ) {% endif %} {% if casedetail.case.previous_case %} - (manage priors) + ( + ) {% endif %}
  • diff --git a/templates/exam_overview_js.html b/templates/exam_overview_js.html index 7592d3e1..6ce7f31a 100644 --- a/templates/exam_overview_js.html +++ b/templates/exam_overview_js.html @@ -13,22 +13,22 @@ }) // $.ajax().done(), $.ajax().fail(), $ajax().always() are upto you. Add/change accordingly .done(function (data) { - console.log(data); + console.log(data); - if (data.status == "success") { - toastr.info(`Exam: ${data.name} [${data.id}] + if (data.status == "success") { + toastr.info(`Exam: ${data.name} [${data.id}] Active state changed to: ${data.active}.`) - } + } // show some message according to the response. // For eg. A message box showing that the status has been changed - }) + }) .fail(function (data) { - console.log(data) - toastr.error(`Failed to change state
    ${data.responseJSON.status}`); - }) + console.log(data) + toastr.error(`Failed to change state
    ${data.responseJSON.status}`); + }) .always(function () { - console.log('[Done]'); - }) + console.log('[Done]'); + }) }) $("#exam-publish-results-switch, .exam-publish-results-switch").on("change", function (evt) { $.ajax({ @@ -42,21 +42,21 @@ }) // $.ajax().done(), $.ajax().fail(), $ajax().always() are upto you. Add/change accordingly .done(function (data) { - console.log(data); + console.log(data); - if (data.status == "success") { - toastr.info(`Exam: ${data.name} [${data.id}] + if (data.status == "success") { + toastr.info(`Exam: ${data.name} [${data.id}] Published state changed to: ${data.publish_results}.`) - } + } // show some message according to the response. // For eg. A message box showing that the status has been changed - }) + }) .fail(function (data) { - toastr.error(`Failed to change state`); - }) + toastr.error(`Failed to change state`); + }) .always(function () { - console.log('[Done]'); - }) + console.log('[Done]'); + }) }) $(".exam-archived-switch").on("change", function (evt) { $.ajax({ @@ -70,21 +70,21 @@ }) // $.ajax().done(), $.ajax().fail(), $ajax().always() are upto you. Add/change accordingly .done(function (data) { - console.log(data); + console.log(data); - if (data.status == "success") { - toastr.info(`Exam: ${data.name} [${data.id}] + if (data.status == "success") { + toastr.info(`Exam: ${data.name} [${data.id}] Archived state changed to: ${data.archive}.`) - } + } // show some message according to the response. // For eg. A message box showing that the status has been changed - }) + }) .fail(function (data) { - toastr.error(`Failed to change state`); - }) + toastr.error(`Failed to change state`); + }) .always(function () { - console.log('[Done]'); - }) + console.log('[Done]'); + }) }) $("#button-open-access").click(function (evt) { $.ajax({ @@ -98,21 +98,21 @@ }) // $.ajax().done(), $.ajax().fail(), $ajax().always() are upto you. Add/change accordingly .done(function (data) { - console.log(data); + console.log(data); - if (data.status == "success") { - toastr.info('Question access state changed.'); - } else { - toastr.warning("Error"); - toastr.info(data.status); - } - }) + if (data.status == "success") { + toastr.info('Question access state changed.'); + } else { + toastr.warning("Error"); + toastr.info(data.status); + } + }) .fail((e) => { - toastr.warning(`Error, ${e}`); - }) + toastr.warning(`Error, ${e}`); + }) .always(function () { - console.log('[Done]'); - }) + console.log('[Done]'); + }) }) $("#button-closed-access").click(function (evt) { $.ajax({ @@ -126,42 +126,65 @@ }) // $.ajax().done(), $.ajax().fail(), $ajax().always() are upto you. Add/change accordingly .done(function (data) { - console.log(data); + console.log(data); - if (data.status == "success") { - toastr.info('Question access state changed.'); - } else { - toastr.warning("Error"); - toastr.info(data.status); - } - }) + if (data.status == "success") { + toastr.info('Question access state changed.'); + } else { + toastr.warning("Error"); + toastr.info(data.status); + } + }) .fail((e) => { - toastr.warning(`Error, ${e}`); - }) + toastr.warning(`Error, ${e}`); + }) .always(function () { - console.log('[Done]'); - }) + console.log('[Done]'); + }) }) $("#button-edit-order").click(function (evt) { $(this).remove(); sortable('.sortable'); + $("#full-question-list").addClass('sorting'); + + // Add tooltip to each li to indicate drag-to-reorder + $("#full-question-list li").attr("title", "Drag to reorder"); $("#full-question-list").after($("").click(() =>{ - var ul = document.getElementById("full-question-list"); - for (var i = ul.children.length; i >= 0; i--) { - ul.appendChild(ul.children[Math.random() * i | 0]); - } + var ul = document.getElementById("full-question-list"); + for (var i = ul.children.length; i >= 0; i--) { + ul.appendChild(ul.children[Math.random() * i | 0]); + } })) $("#full-question-list li").each((n, el) => { + // Add up/down arrows at the start of each
  • + const upBtn = $("").click(function(e){ + e.preventDefault(); + const li = $(this).closest("li"); + const prev = li.prev(); + if (prev.length) { + prev.before(li); + } + }); + const downBtn = $("").click(function(e){ + e.preventDefault(); + const li = $(this).closest("li"); + const next = li.next(); + if (next.length) { + next.after(li); + } + }); + $(el).prepend(downBtn).prepend(upBtn); + + // Existing delete button logic $(el).append($( "" ).click(() => { el.remove(); })); - }) - + }); $("#full-question-list").after($( "" @@ -181,18 +204,70 @@ }) // $.ajax().done(), $.ajax().fail(), $ajax().always() are upto you. Add/change accordingly .done(function (data) { - console.log(data); + console.log(data); - if (data.status == "success") { - toastr.info('Exam order changed.') - } - }) + if (data.status == "success") { + toastr.info('Exam order changed.') + } + }) .always(function () { - console.log('[Done]'); - }) + console.log('[Done]'); + }) + })); +// Add cancel button + $("#full-question-list").after($( + "" + ).click(() => { + location.reload(); })); }); + }); - \ No newline at end of file + + + \ No newline at end of file