Index: admin/settings/courses.php =================================================================== RCS file: /cvsroot/moodle/moodle/admin/settings/courses.php,v retrieving revision 1.14.2.9 diff -u -r1.14.2.9 courses.php --- admin/settings/courses.php 8 Jan 2009 07:05:32 -0000 1.14.2.9 +++ admin/settings/courses.php 5 Feb 2009 17:44:26 -0000 @@ -13,6 +13,43 @@ $ADMIN->add('courses', new admin_enrolment_page()); +/// Course Default Settings Page +/// NOTE: these settings must be applied after all other settings because they depend on them +/// NOTE: these are a subset of the complete defaults available in 2.0 + ///general course settings + $temp = new admin_settingpage('coursesettings', get_string('coursesettings')); + $temp->add(new admin_settings_coursecat_select('moodlecourse/category', get_string('category'), get_string('coursehelpcategory'), 1)); + $courseformats = get_list_of_plugins('course/format'); + $formcourseformats = array(); + foreach ($courseformats as $courseformat) { + $formcourseformats["$courseformat"] = get_string("format$courseformat","format_$courseformat"); + if ($formcourseformats["$courseformat"]=="[[format$courseformat]]") { + $formcourseformats["$courseformat"] = get_string("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'), 3,$sectionmenu)); + $choices = array(); + $choices['0'] = get_string('hiddensectionscollapsed'); + $choices['1'] = get_string('hiddensectionsinvisible'); + $temp->add(new admin_setting_configselect('moodlecourse/hiddensections', get_string('hiddensections'), get_string('coursehelphiddensections'), 0,$choices)); + $options = range(0, 10); + $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)); + $temp->add(new admin_setting_configselect('moodlecourse/metacourse', get_string('metacourse'), get_string('coursehelpmetacourse'), 0,array(0 => get_string('no'), 1 => get_string('yes')))); + + $ADMIN->add('courses', $temp); + // "courserequests" settingpage $temp = new admin_settingpage('courserequest', get_string('courserequest')); $temp->add(new admin_setting_configcheckbox('enablecourserequests', get_string('enablecourserequests', 'admin'), get_string('configenablecourserequests', 'admin'), 0)); Index: lang/en_utf8/moodle.php =================================================================== RCS file: /cvsroot/moodle/moodle/lang/en_utf8/moodle.php,v retrieving revision 1.141.2.55 diff -u -r1.141.2.55 moodle.php --- lang/en_utf8/moodle.php 27 Jan 2009 06:35:44 -0000 1.141.2.55 +++ lang/en_utf8/moodle.php 5 Feb 2009 17:44:28 -0000 @@ -278,6 +278,15 @@ $string['courseformatdata'] = 'Course format data'; $string['courseformats'] = 'Course formats'; $string['coursegrades'] = 'Course grades'; +$string['coursehelpcategory'] = 'Position the course on the course listing and may make it easier for students to find it.'; +$string['coursehelpformat'] = 'The course main page will be displayed in this format.'; +$string['coursehelpnumberweeks'] = 'Number of weeks/topics displayed on the course main page.'; +$string['coursehelphiddensections'] = 'How the hidden sections in the course are displayed to students.'; +$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['coursehelpshowgrades'] = 'Enable the display of the gradebook. It does not prevent grades from being displayed within the individual activities.'; +$string['coursehelpmaximumupload'] = 'Define the largest size of file that can be uploaded by students in this course, limited by the site wide setting.'; +$string['coursehelpmetacourse'] = 'Set the course a metacourse. A meta course takes enrolments (and other role assignments) from a \"child\" course or courses.'; $string['coursehidden'] = 'This course is currently unavailable to students'; $string['courseimportnotaught'] = 'You don\'t seem to be an editing teacher in any other courses, there are no courses for you to import from.'; $string['courseinfo'] = 'Course info'; @@ -306,6 +315,7 @@ $string['courserestore'] = 'Course restore'; $string['courses'] = 'Courses'; $string['coursescategory'] = 'Courses in the same category'; +$string['coursesettings'] = 'Course default settings'; $string['coursesmovedout'] = 'Courses moved out from $a'; $string['coursespending'] = 'Courses pending approval'; $string['coursestaught'] = 'Courses I have taught'; Index: lang/en_utf8/error.php =================================================================== RCS file: /cvsroot/moodle/moodle/lang/en_utf8/error.php,v retrieving revision 1.26.2.20 diff -u -r1.26.2.20 error.php --- lang/en_utf8/error.php 13 Jan 2009 06:03:37 -0000 1.26.2.20 +++ lang/en_utf8/error.php 5 Feb 2009 17:44:28 -0000 @@ -51,6 +51,7 @@ $string['guestnoeditprofile'] = 'The guest user cannot edit their profile'; $string['guestnoeditprofileother'] = 'The guest user profile cannot be edited'; $string['guestsarenotallowed'] = 'The guest user is not allowed to do this'; +$string['invalidadminsettingname'] = 'Invalid admin setting ($a)'; $string['invalidcontext'] = 'Invalid context'; $string['invalidcourse'] = 'Invalid course'; $string['invalidcourseid'] = 'You are trying to use an invalid course ID ($a)'; Index: lib/adminlib.php =================================================================== RCS file: /cvsroot/moodle/moodle/lib/adminlib.php,v retrieving revision 1.153.2.62 diff -u -r1.153.2.62 adminlib.php --- lib/adminlib.php 16 Jan 2009 08:34:21 -0000 1.153.2.62 +++ lib/adminlib.php 5 Feb 2009 17:44:31 -0000 @@ -1616,12 +1616,39 @@ * @param mixed $defaultsetting string or array depending on implementation */ function admin_setting($name, $visiblename, $description, $defaultsetting) { - $this->name = $name; + $this->parse_setting_name($name); $this->visiblename = $visiblename; $this->description = $description; $this->defaultsetting = $defaultsetting; } + /** + * Set up $this->name and possibly $this->plugin based on whether $name looks + * like 'settingname' or 'plugin/settingname'. Also, do some sanity checking + * on the names, that is, output a developer debug warning if the name + * contains anything other than [a-zA-Z0-9_]+. + * + * @param string $name the setting name passed in to the constructor. + */ + function parse_setting_name($name) { + $bits = explode('/', $name); + if (count($bits) > 2) { + print_error('invalidadminsettingname', '', '', $name); + } + $this->name = array_pop($bits); + if (!preg_match('/^[a-zA-Z0-9_]+$/', $this->name)) { + print_error('invalidadminsettingname', '', '', $name); + } + if (!empty($bits)) { + $this->plugin = array_pop($bits); + if ($this->plugin === 'moodle') { + $this->plugin = null; + } else if (!preg_match('/^[a-zA-Z0-9_]+$/', $this->plugin)) { + print_error('invalidadminsettingname', '', '', $name); + } + } + } + function get_full_name() { return 's_'.$this->plugin.'_'.$this->name; } Index: course/edit_form.php =================================================================== RCS file: /cvsroot/moodle/moodle/course/edit_form.php,v retrieving revision 1.37.2.15 diff -u -r1.37.2.15 edit_form.php --- course/edit_form.php 8 Dec 2008 02:30:57 -0000 1.37.2.15 +++ course/edit_form.php 5 Feb 2009 17:44:31 -0000 @@ -7,6 +7,7 @@ function definition() { global $USER, $CFG; + $courseconfig = get_config('moodlecourse'); $mform =& $this->_form; $course = $this->_customdata['course']; @@ -66,7 +67,7 @@ $mform->addElement('hidden', 'category', null); } $mform->setHelpButton('category', array('coursecategory', get_string('category'))); - $mform->setDefault('category', $category->id); + $mform->setDefault('category', $courseconfig->category); $mform->setType('category', PARAM_INT); $mform->addElement('text','fullname', get_string('fullname'),'maxlength="254" size="50"'); @@ -111,13 +112,13 @@ } $mform->addElement('select', 'format', get_string('format'), $formcourseformats); $mform->setHelpButton('format', array('courseformats', get_string('courseformats')), true); - $mform->setDefault('format', 'weeks'); + $mform->setDefault('format', $courseconfig->format); for ($i=1; $i<=52; $i++) { $sectionmenu[$i] = "$i"; } $mform->addElement('select', 'numsections', get_string('numberweeks'), $sectionmenu); - $mform->setDefault('numsections', 10); + $mform->setDefault('numsections', $courseconfig->numsections); $mform->addElement('date_selector', 'startdate', get_string('startdate')); $mform->setHelpButton('startdate', array('coursestartdate', get_string('startdate')), true); @@ -128,24 +129,25 @@ $choices['1'] = get_string('hiddensectionsinvisible'); $mform->addElement('select', 'hiddensections', get_string('hiddensections'), $choices); $mform->setHelpButton('hiddensections', array('coursehiddensections', get_string('hiddensections')), true); - $mform->setDefault('hiddensections', 0); + $mform->setDefault('hiddensections', $courseconfig->hiddensections); $options = range(0, 10); $mform->addElement('select', 'newsitems', get_string('newsitemsnumber'), $options); $mform->setHelpButton('newsitems', array('coursenewsitems', get_string('newsitemsnumber')), true); - $mform->setDefault('newsitems', 5); + $mform->setDefault('newsitems', $courseconfig->newsitems); $mform->addElement('selectyesno', 'showgrades', get_string('showgrades')); $mform->setHelpButton('showgrades', array('coursegrades', get_string('grades')), true); - $mform->setDefault('showgrades', 1); + $mform->setDefault('showgrades', $courseconfig->showgrades); $mform->addElement('selectyesno', 'showreports', get_string('showreports')); $mform->setHelpButton('showreports', array('coursereports', get_string('activityreport')), true); - $mform->setDefault('showreports', 0); + $mform->setDefault('showreports', $courseconfig->showreports); $choices = get_max_upload_sizes($CFG->maxbytes); $mform->addElement('select', 'maxbytes', get_string('maximumupload'), $choices); $mform->setHelpButton('maxbytes', array('courseuploadsize', get_string('maximumupload')), true); + $mform->setDefault('maxbytes', $courseconfig->maxbytes); if (!empty($CFG->allowcoursethemes)) { $themes=array(); @@ -160,7 +162,7 @@ if ($disable_meta === false) { $mform->addElement('select', 'metacourse', get_string('managemeta'), $meta); $mform->setHelpButton('metacourse', array('metacourse', get_string('metacourse')), true); - $mform->setDefault('metacourse', 0); + $mform->setDefault('metacourse', $courseconfig->metacourse); } else { // no metacourse element - we do not want to change it anyway! $mform->addElement('static', 'nometacourse', get_string('managemeta'),