MDL-31216 Create dragdrop course module

This commit is contained in:
Ruslan Kabalin 2012-01-18 10:53:23 +00:00 committed by Andrew Robert Nicols
parent ae2afddcd6
commit 15e2552f00
4 changed files with 418 additions and 4 deletions

View file

@ -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