-
Improvement
-
Resolution: Fixed
-
Blocker
-
2.3.3
-
MOODLE_23_STABLE
-
MOODLE_22_STABLE, MOODLE_23_STABLE
-
wip-
MDL-36795-master -
When controlling the maximum number of sections allowed in a course and the default number of sections in a new course, the number of sections should be limited by the maximum value.
Reproduction steps:
- Log in as admin
- Navigate to "Course default settings" (Settings -> Site administration -> Courses -> Course default settings)
- Change "Maximum for number of weeks/topics moodlecourse | maxsections" to 0
- Click save changes
- Check "Number of weeks/topics moodlecourse | numsections" drop-down
Expected result: The number of weeks/topics should only show 0
Actual result: The number of weeks/topics shows numbers from 0 to 52
Currently the function that controls this value is in lib/adminlib.php...
lib/adminlib.php, lines 3813 to 3829 |
class admin_settings_num_course_sections extends admin_setting_configselect {
|
public function __construct($name, $visiblename, $description, $defaultsetting) {
|
parent::__construct($name, $visiblename, $description, $defaultsetting, array());
|
}
|
|
/** Lazy-load the available choices for the select box */
|
public function load_choices() {
|
$max = get_config('moodlecourse', 'maxsections');
|
if (empty($max)) {
|
$max = 52;
|
}
|
for ($i = 0; $i <= $max; $i++) {
|
$this->choices[$i] = "$i";
|
}
|
return true;
|
}
|
}
|
The check to see if the maximum value is set fails to allow for a value of zero. Changing the check to use !isset() instead of empty resolves this.
if (!isset($max)) {
|
- blocks
-
MDLQA-5078 CLONE - Maximum number of weeks/topics for course can be configured and not restricted to 52
- Passed
- has a non-specific relationship to
-
MDL-28584 Emtpy Value in moodlecourse | maxsections defaults to 0 when editing a course
- Closed
-
MDL-35138 Ensure default values for config settings are set
- Closed
- is a regression caused by
-
MDL-25357 Allow more than 52 sections or just a section 0 in a course
- Closed