Merge remote-tracking branch 'origin/master'

pull/5209/head
Angel Fernando Quiroz Campos 2 years ago
commit 84ec9057b7
  1. 10
      assets/css/scss/_exercise.scss
  2. 29
      public/main/exercise/question_list_admin.inc.php
  3. 3
      public/main/inc/ajax/exercise.ajax.php

@ -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); 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 { .question_menu {
@apply p-4 flex flex-row gap-1; @apply p-4 flex flex-row gap-1;
} }

@ -57,6 +57,7 @@ $ajax_url = api_get_path(WEB_AJAX_PATH).'exercise.ajax.php?'.api_get_cidreq().'&
} }
}); });
var isDragging = false;
$("#question_list").accordion({ $("#question_list").accordion({
icons: null, icons: null,
heightStyle: "content", heightStyle: "content",
@ -64,6 +65,10 @@ $ajax_url = api_get_path(WEB_AJAX_PATH).'exercise.ajax.php?'.api_get_cidreq().'&
collapsible: true, collapsible: true,
header: ".header_operations", header: ".header_operations",
beforeActivate: function (e, ui) { beforeActivate: function (e, ui) {
if (isDragging) {
e.preventDefault();
isDragging = false;
}
var data = ui.newHeader.data(); var data = ui.newHeader.data();
if (typeof data === 'undefined') { if (typeof data === 'undefined') {
return; return;
@ -95,19 +100,29 @@ $ajax_url = api_get_path(WEB_AJAX_PATH).'exercise.ajax.php?'.api_get_cidreq().'&
}) })
.sortable({ .sortable({
cursor: "move", // works? 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) { update: function (event, ui) {
var order = $(this).sortable("serialize") + "&a=update_question_order&exercise_id=<?php echo $exerciseId; ?>"; var order = $(this).sortable("serialize") + "&a=update_question_order&exercise_id=<?php echo $exerciseId; ?>";
$.post("<?php echo $ajax_url; ?>", order, function (result) { $.post("<?php echo $ajax_url; ?>", order, function (result) {
$("#message").html(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();
});
}); });
</script> </script>
<?php <?php
@ -246,7 +261,7 @@ if (!$inATest) {
$title = strip_tags($title); $title = strip_tags($title);
$move = '&nbsp;'; $move = '&nbsp;';
if ($allowQuestionOrdering) { if ($allowQuestionOrdering) {
$move = Display::getMdiIcon('cursor-move'); $move = Display::getMdiIcon('cursor-move', 'moved');
} }
// Question name // Question name

@ -347,9 +347,8 @@ switch ($action) {
$TBL_QUESTIONS, $TBL_QUESTIONS,
['question_order' => $counter], ['question_order' => $counter],
[ [
'question_id = ? AND c_id = ? AND quiz_id = ? ' => [ 'question_id = ? AND quiz_id = ? ' => [
(int) $new_order_id, (int) $new_order_id,
$course_id,
$exercise_id, $exercise_id,
], ],
] ]

Loading…
Cancel
Save