Enhance exam order editing: hide edit button during editing, improve save button attributes, and clean up controls after saving

This commit is contained in:
Ross
2025-11-16 23:06:33 +00:00
parent 9760be8f27
commit 8c8d484dce
+17 -2
View File
@@ -143,7 +143,8 @@
})
})
$("#button-edit-order").click(function (evt) {
$(this).remove();
// hide the edit button while in edit mode so we can restore it after saving
$(this).addClass('d-none').prop('disabled', true);
sortable('.sortable');
$("#full-question-list").addClass('sorting');
@@ -215,7 +216,7 @@
});
$("#full-question-list").after($(
"<button title='click and drag questions to change order'>Save exam order</button>"
"<button id='save-order-button' class='btn btn-primary btn-sm' title='click and drag questions to change order'>Save exam order</button>"
).click(() => {
new_order = [];
$("#full-question-list li").each((n, el) => {
@@ -237,6 +238,20 @@
if (data.status == "success") {
toastr.info('Exam order changed.')
renumber();
// cleanup ordering controls and restore edit button
$('#random-order-button').remove();
$('#save-order-button').remove();
$('#cancel-order-button').remove();
// remove per-item move controls
$('#full-question-list .move-up, #full-question-list .move-down').remove();
// remove fallback delete buttons if desired (keep server-side removes intact)
$('#full-question-list .exam-question-delete').remove();
// remove visual sorting state
$('#full-question-list').removeClass('sorting');
// restore the edit button so the user can re-enter edit mode
$('#button-edit-order').removeClass('d-none').prop('disabled', false);
}
})
.always(function () {