From d22b5faae897ba430f2f6d62a759ea67af9a0ccc Mon Sep 17 00:00:00 2001 From: Adrian Greeve Date: Mon, 26 Nov 2012 15:53:30 +0800 Subject: [PATCH] MDL-36795 - lib / administration: maxsections now limits the default setting for numsections. In the default course settings, setting the maximum number topics / weeks to 0 would not change the default number of sections on the same page as any other number would. A more appropriate check has been put in place. This also incorporates a fix for MDL-28584. The course edit screen now also checks to see if maxsections is set or numeric. If it is not set or numeric then it defaults to 52. --- course/edit_form.php | 6 +++++- lib/adminlib.php | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/course/edit_form.php b/course/edit_form.php index 20a010ed86b..bcb237a8739 100644 --- a/course/edit_form.php +++ b/course/edit_form.php @@ -126,7 +126,11 @@ class course_edit_form extends moodleform { $mform->addHelpButton('coursedisplay', 'coursedisplay'); $mform->setDefault('coursedisplay', $courseconfig->coursedisplay); - for ($i = 0; $i <= $courseconfig->maxsections; $i++) { + $max = $courseconfig->maxsections; + if (!isset($max) || !is_numeric($max)) { + $max = 52; + } + for ($i = 0; $i <= $max; $i++) { $sectionmenu[$i] = "$i"; } $mform->addElement('select', 'numsections', get_string('numberweeks'), $sectionmenu); diff --git a/lib/adminlib.php b/lib/adminlib.php index c74e55717b1..2812fef006b 100644 --- a/lib/adminlib.php +++ b/lib/adminlib.php @@ -3626,7 +3626,7 @@ class admin_settings_num_course_sections extends admin_setting_configselect { /** Lazy-load the available choices for the select box */ public function load_choices() { $max = get_config('moodlecourse', 'maxsections'); - if (empty($max)) { + if (!isset($max) || !is_numeric($max)) { $max = 52; } for ($i = 0; $i <= $max; $i++) { -- 2.43.0