Skip to content

Commit

Permalink
MDL-36795 - lib / administration: maxsections now limits the default …
Browse files Browse the repository at this point in the history
…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 26, 2012
1 parent f42c34a commit 341bfed
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
6 changes: 5 additions & 1 deletion course/format/topics/lib.php
Expand Up @@ -213,8 +213,12 @@ public function course_format_options($foreditform = false) {
} }
if ($foreditform && !isset($courseformatoptions['coursedisplay']['label'])) { if ($foreditform && !isset($courseformatoptions['coursedisplay']['label'])) {
$courseconfig = get_config('moodlecourse'); $courseconfig = get_config('moodlecourse');
$max = $courseconfig->maxsections;
if (!isset($max) || !is_numeric($max)) {
$max = 52;
}
$sectionmenu = array(); $sectionmenu = array();
for ($i = 0; $i <= $courseconfig->maxsections; $i++) { for ($i = 0; $i <= $max; $i++) {
$sectionmenu[$i] = "$i"; $sectionmenu[$i] = "$i";
} }
$courseformatoptionsedit = array( $courseformatoptionsedit = array(
Expand Down
6 changes: 5 additions & 1 deletion course/format/weeks/lib.php
Expand Up @@ -219,7 +219,11 @@ public function course_format_options($foreditform = false) {
if ($foreditform && !isset($courseformatoptions['coursedisplay']['label'])) { if ($foreditform && !isset($courseformatoptions['coursedisplay']['label'])) {
$courseconfig = get_config('moodlecourse'); $courseconfig = get_config('moodlecourse');
$sectionmenu = array(); $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"; $sectionmenu[$i] = "$i";
} }
$courseformatoptionsedit = array( $courseformatoptionsedit = array(
Expand Down
2 changes: 1 addition & 1 deletion lib/adminlib.php
Expand Up @@ -3818,7 +3818,7 @@ public function __construct($name, $visiblename, $description, $defaultsetting)
/** Lazy-load the available choices for the select box */ /** Lazy-load the available choices for the select box */
public function load_choices() { public function load_choices() {
$max = get_config('moodlecourse', 'maxsections'); $max = get_config('moodlecourse', 'maxsections');
if (empty($max)) { if (!isset($max) || !is_numeric($max)) {
$max = 52; $max = 52;
} }
for ($i = 0; $i <= $max; $i++) { for ($i = 0; $i <= $max; $i++) {
Expand Down

0 comments on commit 341bfed

Please sign in to comment.