-
Bug
-
Resolution: Fixed
-
Major
-
2.3.7, 2.4.4, 2.5, 2.6
-
None
-
MOODLE_23_STABLE, MOODLE_24_STABLE, MOODLE_25_STABLE, MOODLE_26_STABLE
-
MOODLE_23_STABLE, MOODLE_24_STABLE, MOODLE_25_STABLE
-
wip-
MDL-39764_master_3 -
-
When editing a course you can add new sections using an icon at the bottom of the section list. Currently, this icon is shown even when the default max sections has been reached (as set up in Home /Site administration /Courses /Course default settings - moodlecourse | maxsections setting) which controls the population of the numsections combo-box in the course settings.
Therefore it is possible for the user to add new sections beyond the maximum and add activities / resources to them. But when they edit the course settings, the new number of sections in the course is greater than the maximum value populated in the combo-box so it reverts to '0'. Then the user only sees the '0' section, goes back to the course settings to set the number of sections to the maximum, which is still less than has been added previously through the icon, only to find that there are now orphaned activities at the bottom of the course.
Looking at the code in '/course/format/renderer.php' method 'print_multiple_section_page':
// Increase number of sections.
|
$straddsection = get_string('increasesections', 'moodle');
|
$url = new moodle_url('/course/changenumsections.php',
|
array('courseid' => $course->id,
|
'increase' => true,
|
'sesskey' => sesskey()));
|
$icon = $this->output->pix_icon('t/switch_plus', $straddsection);
|
echo html_writer::link($url, $icon.get_accesshide($straddsection), array('class' => 'increase-sections'));
|
there is no 'guard' to check the maxsections. Therefore the code should be:
$max = get_config('moodlecourse', 'maxsections');
|
if (!isset($max) || !is_numeric($max)) {
|
$max = 52;
|
}
|
if ($course->numsections < $max) {
|
// Increase number of sections.
|
$straddsection = get_string('increasesections', 'moodle');
|
$url = new moodle_url('/course/changenumsections.php',
|
array('courseid' => $course->id,
|
'increase' => true,
|
'sesskey' => sesskey()));
|
$icon = $this->output->pix_icon('t/switch_plus', $straddsection);
|
echo html_writer::link($url, $icon . get_accesshide($straddsection), array('class' => 'increase-sections'));
|
}
|
where I have borrowed the principle setting retrieval code of:
$max = get_config('moodlecourse', 'maxsections');
|
if (!isset($max) || !is_numeric($max)) {
|
$max = 52;
|
}
|
from 'admin_settings_num_course_sections' in '/lib/adminlib.php'.
This arose from this thread in the course formats forum: https://moodle.org/mod/forum/discuss.php?d=228468