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 e4592b2 commit 0ceb918
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion course/edit_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,11 @@ function definition() {
$mform->addHelpButton('format', 'format');
$mform->setDefault('format', $courseconfig->format);

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);
Expand Down
2 changes: 1 addition & 1 deletion lib/adminlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -3634,7 +3634,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++) {
Expand Down

0 comments on commit 0ceb918

Please sign in to comment.