mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 08:26:37 +02:00
Bug #6093 - Removed course sections re-appear after moving existing sections
This commit is contained in:
parent
4e2b4b1bc2
commit
31c46027aa
1 changed files with 6 additions and 9 deletions
|
@ -1510,20 +1510,17 @@ function move_section($course, $section, $move) {
|
||||||
course_set_display($course->id, $sectiondest);
|
course_set_display($course->id, $sectiondest);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for duplicates.
|
// Check for duplicates and fix order if needed.
|
||||||
// There is a very rare case that some sections in the same course have the same section id.
|
// There is a very rare case that some sections in the same course have the same section id.
|
||||||
if (($count_section = count_records('course_sections', 'course', $course->id) - 1) != $course->numsections) {
|
$sections = get_records_select('course_sections', "course = $course->id", 'section ASC');
|
||||||
$sections = get_records_select('course_sections', "course = $course->id AND section > 0", 'section ASC');
|
$n = 0;
|
||||||
$n = 1;
|
foreach ($sections as $section) {
|
||||||
foreach ($sections as $section) {
|
if ($section->section != $n) {
|
||||||
if (!set_field('course_sections', 'section', $n, 'id', $section->id)) {
|
if (!set_field('course_sections', 'section', $n, 'id', $section->id)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$n++;
|
|
||||||
}
|
|
||||||
if (!set_field('course', 'numsections', $count_section, 'id', $course->id)) {
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
$n++;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue