MDL-85787 course: Limit course index drag and drop to certain pages only

Only allow the drag and drop functionality in the course index on pages
that provide alternatives to move course items such as the course
homepage and the course section view pages.

This is to meet the WCAG 2.2 Level AA Success Criterion 2.5.7 for
dragging movements.
See: https://www.w3.org/WAI/WCAG22/Understanding/dragging-movements
This commit is contained in:
Jun Pataleta
2025-07-29 11:46:02 +08:00
parent 51662cb8ef
commit fde36bb49c
14 changed files with 32 additions and 18 deletions
+8 -2
View File
@@ -198,15 +198,21 @@ if (core_communication\api::is_available() && has_capability('moodle/course:upda
$communication->show_communication_room_status_notification();
}
// Display a warning if asynchronous backups are pending for this course.
$containerattributes = [];
if ($PAGE->user_is_editing()) {
require_once($CFG->dirroot . '/backup/util/helper/async_helper.class.php');
// Display a warning if asynchronous backups are pending for this course.
if (async_helper::is_async_pending($course->id, 'course', 'backup')) {
echo $OUTPUT->notification(get_string('pendingasyncedit', 'backup'), 'warning');
}
// Allow drag and drop in the course index.
$containerattributes = [
'data-courseindexdndallowed' => 'true',
];
}
echo $renderer->container_start('course-content');
echo $renderer->container_start('course-content', attributes: $containerattributes);
// Include course AJAX.
include_course_ajax($course, $modinfo->get_used_module_names());