mirror of
https://github.com/moodle/moodle.git
synced 2025-08-08 10:26:40 +02:00
MDL-31216 Create dragdrop course module
This commit is contained in:
parent
ae2afddcd6
commit
15e2552f00
4 changed files with 418 additions and 4 deletions
|
@ -3065,6 +3065,23 @@ function move_section_to($course, $section, $destination) {
|
|||
$DB->set_field('course_sections', 'section', $position, array('id' => $id));
|
||||
}
|
||||
|
||||
// Adjust destination to reflect the actual section
|
||||
$moveup = false;
|
||||
if ($section > $destination) {
|
||||
$destination++;
|
||||
$moveup = true;
|
||||
}
|
||||
|
||||
// If we move the highlighted section itself, then just highlight the destination.
|
||||
// Adjust the higlighted section location if we move something over it either direction.
|
||||
if ($section == $course->marker) {
|
||||
course_set_marker($course, $destination);
|
||||
} elseif ($moveup && $section > $course->marker && $course->marker >= $destination) {
|
||||
course_set_marker($course, $course->marker+1);
|
||||
} elseif (!$moveup && $section < $course->marker && $course->marker <= $destination) {
|
||||
course_set_marker($course, $course->marker-1);
|
||||
}
|
||||
|
||||
// if the focus is on the section that is being moved, then move the focus along
|
||||
if (course_get_display($course->id) == $section) {
|
||||
course_set_display($course->id, $destination);
|
||||
|
@ -4470,6 +4487,23 @@ function include_course_ajax($course, $modules = array(), $config = null) {
|
|||
))
|
||||
);
|
||||
|
||||
// Include course dragdrop
|
||||
$PAGE->requires->yui_module('moodle-course-dragdrop',
|
||||
'M.core_course.init_resource_dragdrop',
|
||||
array(array(
|
||||
'courseid' => $course->id,
|
||||
'ajaxurl' => $config->resourceurl,
|
||||
'config' => $config,
|
||||
)), null, true);
|
||||
|
||||
$PAGE->requires->yui_module('moodle-course-dragdrop',
|
||||
'M.core_course.init_section_dragdrop',
|
||||
array(array(
|
||||
'courseid' => $course->id,
|
||||
'ajaxurl' => $config->sectionurl,
|
||||
'config' => $config,
|
||||
)), null, true);
|
||||
|
||||
// Require various strings for the command toolbox
|
||||
$PAGE->requires->strings_for_js(array(
|
||||
'moveleft',
|
||||
|
@ -4483,6 +4517,8 @@ function include_course_ajax($course, $modules = array(), $config = null) {
|
|||
'clicktochangeinbrackets',
|
||||
'markthistopic',
|
||||
'markedthistopic',
|
||||
'move',
|
||||
'movesection',
|
||||
), 'moodle');
|
||||
|
||||
// Include format-specific strings
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue