diff --git a/assets/css/scss/_exercise.scss b/assets/css/scss/_exercise.scss index 3366aceb41..afdbb12a01 100644 --- a/assets/css/scss/_exercise.scss +++ b/assets/css/scss/_exercise.scss @@ -62,6 +62,16 @@ box-shadow: 0 1px 1px rgba(0, 0, 0, 0.075) inset, 0 0 8px rgba(102, 175, 233, 0.6); } +.ui-state-highlight { + height: 3.5em; + line-height: 2.2em; + background-color: #fafafa; + border: 1px dashed #ccc; + margin-top: 10px; + margin-bottom: 10px; + padding: 5px; +} + .question_menu { @apply p-4 flex flex-row gap-1; } @@ -232,4 +242,4 @@ @apply text-left; } } -} \ No newline at end of file +} diff --git a/public/main/exercise/question_list_admin.inc.php b/public/main/exercise/question_list_admin.inc.php index 4e1f8b174b..51eff76dc1 100644 --- a/public/main/exercise/question_list_admin.inc.php +++ b/public/main/exercise/question_list_admin.inc.php @@ -57,6 +57,7 @@ $ajax_url = api_get_path(WEB_AJAX_PATH).'exercise.ajax.php?'.api_get_cidreq().'& } }); + var isDragging = false; $("#question_list").accordion({ icons: null, heightStyle: "content", @@ -64,6 +65,10 @@ $ajax_url = api_get_path(WEB_AJAX_PATH).'exercise.ajax.php?'.api_get_cidreq().'& collapsible: true, header: ".header_operations", beforeActivate: function (e, ui) { + if (isDragging) { + e.preventDefault(); + isDragging = false; + } var data = ui.newHeader.data(); if (typeof data === 'undefined') { return; @@ -95,19 +100,29 @@ $ajax_url = api_get_path(WEB_AJAX_PATH).'exercise.ajax.php?'.api_get_cidreq().'& }) .sortable({ cursor: "move", // works? + axis: "y", + placeholder: "ui-state-highlight", //defines the yellow highlight + handle: ".moved", //only the class "moved" + start: function(event, ui) { + isDragging = true; + }, + stop: function(event, ui) { + stop = true; + setTimeout(function() { + isDragging = false; + }, 50); + }, update: function (event, ui) { var order = $(this).sortable("serialize") + "&a=update_question_order&exercise_id="; $.post("", order, function (result) { $("#message").html(result); }); - }, - axis: "y", - placeholder: "ui-state-highlight", //defines the yellow highlight - handle: ".moved", //only the class "moved" - stop: function () { - stop = true; } }); + + $(".moved").on('click', function(event) { + event.stopImmediatePropagation(); + }); }); $counter], [ - 'question_id = ? AND c_id = ? AND quiz_id = ? ' => [ + 'question_id = ? AND quiz_id = ? ' => [ (int) $new_order_id, - $course_id, $exercise_id, ], ]