$formcourseformats[$courseformat] = get_string('pluginname', "format_$courseformat");
}
$temp->add(new admin_setting_configselect('moodlecourse/format', get_string('format'), get_string('coursehelpformat'), 'weeks',$formcourseformats));
- for ($i=1; $i<=52; $i++) {
- $sectionmenu[$i] = "$i";
- }
- $temp->add(new admin_setting_configselect('moodlecourse/numsections', get_string('numberweeks'), get_string('coursehelpnumberweeks'), 10,$sectionmenu));
+
+ $temp->add(new admin_setting_configtext('moodlecourse/maxsections', get_string('maxnumberweeks'), get_string('maxnumberweeks_desc'), 52));
+
+ $temp->add(new admin_settings_num_course_sections('moodlecourse/numsections', get_string('numberweeks'), get_string('coursehelpnumberweeks'), 10));
+
$choices = array();
$choices['0'] = get_string('hiddensectionscollapsed');
$choices['1'] = get_string('hiddensectionsinvisible');
$temp->add(new admin_setting_configselect('moodlecourse/newsitems', get_string('newsitemsnumber'), get_string('coursehelpnewsitemsnumber'), 5,$options));
$temp->add(new admin_setting_configselect('moodlecourse/showgrades', get_string('showgrades'), get_string('coursehelpshowgrades'), 1,array(0 => get_string('no'), 1 => get_string('yes'))));
$temp->add(new admin_setting_configselect('moodlecourse/showreports', get_string('showreports'), '', 0,array(0 => get_string('no'), 1 => get_string('yes'))));
+
if (isset($CFG->maxbytes)) {
$choices = get_max_upload_sizes($CFG->maxbytes);
} else {
$choices = get_max_upload_sizes();
}
-
$temp->add(new admin_setting_configselect('moodlecourse/maxbytes', get_string('maximumupload'), get_string('coursehelpmaximumupload'), key($choices), $choices));
-
if (!empty($CFG->legacyfilesinnewcourses)) {
$choices = array('0'=>get_string('no'), '2'=>get_string('yes'));
$temp->add(new admin_setting_configselect('moodlecourse/legacyfiles', get_string('courselegacyfiles'), get_string('courselegacyfiles_help'), key($choices), $choices));
}
}
}
- $moodleattributes['username'] = $this->config->user_attribute;
+ $moodleattributes['username'] = moodle_strtolower(trim($this->config->user_attribute));
return $moodleattributes;
}
abstract class backup_exception extends moodle_exception {
public function __construct($errorcode, $a=NULL, $debuginfo=null) {
- parent::__construct($errorcode, 'error', '', $a, null, $debuginfo);
+ parent::__construct($errorcode, 'error', '', $a, $debuginfo);
}
}
$mform->addHelpButton('format', 'format');
$mform->setDefault('format', $courseconfig->format);
- for ($i=1; $i<=52; $i++) {
- $sectionmenu[$i] = "$i";
+ for ($i = 0; $i <= $courseconfig->maxsections; $i++) {
+ $sectionmenu[$i] = "$i";
}
$mform->addElement('select', 'numsections', get_string('numberweeks'), $sectionmenu);
$mform->setDefault('numsections', $courseconfig->numsections);
$string['coursehelpformat'] = 'The course main page will be displayed in this format.';
$string['coursehelphiddensections'] = 'How the hidden sections in the course are displayed to students.';
$string['coursehelpmaximumupload'] = 'Define the largest size of file that can be uploaded in this course, limited by the site-wide setting.';
-$string['coursehelpnewsitemsnumber'] = 'Number of recent items appearing on the course home page, in a news box down the right-hand side <br/>(0 means the news box won\'t appear).';
+$string['coursehelpnewsitemsnumber'] = 'Number of recent items appearing on the course home page, in a news box down the right-hand side (0 means the news box won\'t appear).';
$string['coursehelpnumberweeks'] = 'Number of weeks/topics displayed on the course main page.';
$string['coursehelpshowgrades'] = 'Enable the display of the gradebook. It does not prevent grades from being displayed within the individual activities.';
$string['coursehidden'] = 'This course is currently unavailable to students';
$string['maximumshort'] = 'Max';
$string['maximumupload'] = 'Maximum upload size';
$string['maximumupload_help'] = 'This setting determines the largest size of file that can be uploaded to the course, limited by the site-wide setting set by an administrator. Activity modules also include a maximum upload size setting for further restricting the file size.';
+$string['maxnumberweeks'] = 'Maximum for number of weeks/topics';
+$string['maxnumberweeks_desc'] = 'This controls the maximum options that appears in the "Number of weeks/topics" setting for courses.';
$string['maxsize'] = 'Max size: {$a}';
$string['maxfilesize'] = 'Maximum size for new files: {$a}';
$string['maxnumcoursesincombo'] = 'Browse <a href="{$a->link}">{$a->numberofcourses} courses</a>.';
}
+/**
+ * admin_setting_configselect for the default number of sections in a course,
+ * simply so we can lazy-load the choices.
+ *
+ * @copyright 2011 The Open University
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+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;
+ }
+}
+
+
/**
* Course category selection
*
'contextid2' => $context->id,
'pagetype' => $this->page->pagetype,
);
+ if ($this->page->subpage === '') {
+ $params['subpage1'] = $DB->sql_empty();
+ $params['subpage2'] = $DB->sql_empty();
+ }
$sql = "SELECT
bi.id,
bp.id AS blockpositionid,
WHERE ctx.id = bi.contextid)
ELSE bi.pagetypepattern END,
CASE WHEN bi.subpagepattern IS NULL
- THEN ''
+ THEN '" . $DB->sql_empty() . "'
ELSE bi.subpagepattern END,
0, bi.defaultregion, bi.defaultweight
FROM {block_instances} bi