Permalink
Browse files

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.
  • Loading branch information...
abgreeve committed Nov 23, 2012
1 parent f42c34a commit 341bfedf9039bb5b9577291da4569219f892dfef
Showing with 11 additions and 3 deletions.
  1. +5 −1 course/format/topics/lib.php
  2. +5 −1 course/format/weeks/lib.php
  3. +1 −1 lib/adminlib.php
@@ -213,8 +213,12 @@ public function course_format_options($foreditform = false) {
}
if ($foreditform && !isset($courseformatoptions['coursedisplay']['label'])) {
$courseconfig = get_config('moodlecourse');
+ $max = $courseconfig->maxsections;
+ if (!isset($max) || !is_numeric($max)) {
+ $max = 52;
+ }
$sectionmenu = array();
- for ($i = 0; $i <= $courseconfig->maxsections; $i++) {
+ for ($i = 0; $i <= $max; $i++) {
$sectionmenu[$i] = "$i";
}
$courseformatoptionsedit = array(
@@ -219,7 +219,11 @@ public function course_format_options($foreditform = false) {
if ($foreditform && !isset($courseformatoptions['coursedisplay']['label'])) {
$courseconfig = get_config('moodlecourse');
$sectionmenu = array();
- 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";
}
$courseformatoptionsedit = array(
View
@@ -3818,7 +3818,7 @@ public function __construct($name, $visiblename, $description, $defaultsetting)
/** 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++) {

0 comments on commit 341bfed

Please sign in to comment.