MDL-12846: move course default settings into config_plugin table

This commit is contained in:
jerome 2008-09-25 07:33:22 +00:00
parent 2ca22c727b
commit cfec045442
2 changed files with 45 additions and 44 deletions

View File

@ -14,7 +14,7 @@ if ($hassiteconfig
/// Course Default Settings Page
///main course settings
$temp = new admin_settingpage('coursesettings', get_string('coursesettings'));
$temp->add(new admin_settings_coursecat_select('course_category', get_string('category'), '', 1));
$temp->add(new admin_settings_coursecat_select('moodlecourse/category', get_string('category'), '', 1));
$courseformats = get_list_of_plugins('course/format');
$formcourseformats = array();
foreach ($courseformats as $courseformat) {
@ -23,22 +23,22 @@ if ($hassiteconfig
$formcourseformats["$courseformat"] = get_string("format$courseformat");
}
}
$temp->add(new admin_setting_configselect('course_format', get_string('format'), get_string('courseformats'), key($formcourseformats),$formcourseformats));
$temp->add(new admin_setting_configselect('moodlecourse/format', get_string('format'), get_string('courseformats'), key($formcourseformats),$formcourseformats));
for ($i=1; $i<=52; $i++) {
$sectionmenu[$i] = "$i";
}
$temp->add(new admin_setting_configselect('course_numsections', get_string('numberweeks'), '', 1,$sectionmenu));
$temp->add(new admin_setting_configselect('moodlecourse/numsections', get_string('numberweeks'), '', 1,$sectionmenu));
$choices = array();
$choices['0'] = get_string('hiddensectionscollapsed');
$choices['1'] = get_string('hiddensectionsinvisible');
$temp->add(new admin_setting_configselect('course_hiddensections', get_string('hiddensections'), '', 0,$choices));
$temp->add(new admin_setting_configselect('moodlecourse/hiddensections', get_string('hiddensections'), '', 0,$choices));
$options = range(0, 10);
$temp->add(new admin_setting_configselect('course_newsitems', get_string('newsitemsnumber'), '', 5,$options));
$temp->add(new admin_setting_configselect('course_showgrades', get_string('showgrades'), get_string('grades'), 1,array(0 => get_string('no'), 1 => get_string('yes'))));
$temp->add(new admin_setting_configselect('course_showreports', get_string('showreports'), get_string('activityreport'), 0,array(0 => get_string('no'), 1 => get_string('yes'))));
$temp->add(new admin_setting_configselect('moodlecourse/newsitems', get_string('newsitemsnumber'), '', 5,$options));
$temp->add(new admin_setting_configselect('moodlecourse/showgrades', get_string('showgrades'), get_string('grades'), 1,array(0 => get_string('no'), 1 => get_string('yes'))));
$temp->add(new admin_setting_configselect('moodlecourse/showreports', get_string('showreports'), get_string('activityreport'), 0,array(0 => get_string('no'), 1 => get_string('yes'))));
$choices = get_max_upload_sizes($CFG->maxbytes);
$temp->add(new admin_setting_configselect('course_maxbytes', get_string('maximumupload'), '', key($choices),$choices));
$temp->add(new admin_setting_configselect('course_metacourse', get_string('metacourse'), '', 0,array(0 => get_string('no'), 1 => get_string('yes'))));
$temp->add(new admin_setting_configselect('moodlecourse/maxbytes', get_string('maximumupload'), '', key($choices),$choices));
$temp->add(new admin_setting_configselect('moodlecourse/metacourse', get_string('metacourse'), '', 0,array(0 => get_string('no'), 1 => get_string('yes'))));
///enrolement course settings
$temp->add(new admin_setting_heading('enrolhdr', get_string('enrolments'), ''));
@ -55,27 +55,27 @@ if ($hassiteconfig
asort($choices);
$choices = array_flip($choices);
$choices = array_merge(array('' => get_string('sitedefault').' ('.get_string('enrolname', "enrol_$CFG->enrol").')'), $choices);
$temp->add(new admin_setting_configselect('course_enrol', get_string('enrolmentplugins'), '', key($choices),$choices));
$temp->add(new admin_setting_configselect('moodlecourse/enrol', get_string('enrolmentplugins'), '', key($choices),$choices));
$choices = array(0 => get_string('no'), 1 => get_string('yes'), 2 => get_string('enroldate'));
$temp->add(new admin_setting_configselect('course_enrollable', get_string('enrollable'), '', 1,$choices));
$temp->add(new admin_setting_configselect('moodlecourse/enrollable', get_string('enrollable'), '', 1,$choices));
$periodmenu=array();
$periodmenu[0] = get_string('unlimited');
for ($i=1; $i<=365; $i++) {
$seconds = $i * 86400;
$periodmenu[$seconds] = get_string('numdays', '', $i);
}
$temp->add(new admin_setting_configselect('course_enrolperiod', get_string('enrolperiod'), '', 0,$periodmenu));
$temp->add(new admin_setting_configselect('moodlecourse/enrolperiod', get_string('enrolperiod'), '', 0,$periodmenu));
///
$temp->add(new admin_setting_heading('expirynotifyhdr', get_string('expirynotify'), ''));
$temp->add(new admin_setting_configselect('course_expirynotify', get_string('notify'), '', 0,array(0 => get_string('no'), 1 => get_string('yes'))));
$temp->add(new admin_setting_configselect('course_notifystudents', get_string('expirynotifystudents'), '', 0,array(0 => get_string('no'), 1 => get_string('yes'))));
$temp->add(new admin_setting_configselect('moodlecourse/expirynotify', get_string('notify'), '', 0,array(0 => get_string('no'), 1 => get_string('yes'))));
$temp->add(new admin_setting_configselect('moodlecourse/notifystudents', get_string('expirynotifystudents'), '', 0,array(0 => get_string('no'), 1 => get_string('yes'))));
$thresholdmenu=array();
for ($i=1; $i<=30; $i++) {
$seconds = $i * 86400;
$thresholdmenu[$seconds] = get_string('numdays', '', $i);
}
$temp->add(new admin_setting_configselect('course_expirythreshold', get_string('expirythreshold'), '', 10 * 86400,$thresholdmenu));
$temp->add(new admin_setting_configselect('moodlecourse/expirythreshold', get_string('expirythreshold'), '', 10 * 86400,$thresholdmenu));
$temp->add(new admin_setting_heading('groups', get_string('groups', 'group'), ''));
@ -83,32 +83,32 @@ if ($hassiteconfig
$choices[NOGROUPS] = get_string('groupsnone', 'group');
$choices[SEPARATEGROUPS] = get_string('groupsseparate', 'group');
$choices[VISIBLEGROUPS] = get_string('groupsvisible', 'group');
$temp->add(new admin_setting_configselect('course_groupmode', get_string('groupmode'), '', key($choices),$choices));
$temp->add(new admin_setting_configselect('course_groupmodeforce', get_string('force'), get_string('groupmodeforce'), 0,array(0 => get_string('no'), 1 => get_string('yes'))));
$temp->add(new admin_setting_configselect('moodlecourse/groupmode', get_string('groupmode'), '', key($choices),$choices));
$temp->add(new admin_setting_configselect('moodlecourse/groupmodeforce', get_string('force'), get_string('groupmodeforce'), 0,array(0 => get_string('no'), 1 => get_string('yes'))));
$temp->add(new admin_setting_heading('availability', get_string('availability'), ''));
$choices = array();
$choices['0'] = get_string('courseavailablenot');
$choices['1'] = get_string('courseavailable');
$temp->add(new admin_setting_configselect('course_visible', get_string('visible'), '', 1,$choices));
$temp->add(new admin_setting_configpasswordunmask('course_enrolpassword', get_string('enrolmentkey'), '',''));
$temp->add(new admin_setting_configselect('moodlecourse/visible', get_string('visible'), '', 1,$choices));
$temp->add(new admin_setting_configpasswordunmask('moodlecourse/enrolpassword', get_string('enrolmentkey'), '',''));
$choices = array();
$choices['0'] = get_string('guestsno');
$choices['1'] = get_string('guestsyes');
$choices['2'] = get_string('guestskey');
$temp->add(new admin_setting_configselect('course_guest', get_string('opentoguests'), '', 0,$choices));
$temp->add(new admin_setting_configselect('moodlecourse/guest', get_string('opentoguests'), '', 0,$choices));
$temp->add(new admin_setting_heading('language', get_string('language'), ''));
$languages=array();
$languages[''] = get_string('forceno');
$languages += get_list_of_languages();
$temp->add(new admin_setting_configselect('course_lang', get_string('forcelanguage'), '', 0,$languages));
$temp->add(new admin_setting_configselect('moodlecourse/lang', get_string('forcelanguage'), '', 0,$languages));
if(completion_info::is_enabled_for_site()) {
$temp->add(new admin_setting_heading('progress', get_string('progress','completion'), ''));
$temp->add(new admin_setting_configselect('course_enablecompletion', get_string('completion','completion'), '',
$temp->add(new admin_setting_configselect('moodlecourse/enablecompletion', get_string('completion','completion'), '',
1,array(0 => get_string('completiondisabled','completion'), 1 => get_string('completionenabled','completion'))));
}
$ADMIN->add('courses', $temp);

View File

@ -7,6 +7,7 @@ class course_edit_form extends moodleform {
function definition() {
global $USER, $CFG, $DB;
$courseconfig = get_config('moodlecourse');
$mform =& $this->_form;
$course = $this->_customdata['course'];
@ -71,7 +72,7 @@ class course_edit_form extends moodleform {
$mform->addElement('hidden', 'category', null);
}
$mform->setHelpButton('category', array('coursecategory', get_string('category')));
$mform->setDefault('category', $CFG->course_category);
$mform->setDefault('category', $courseconfig->category);
$mform->setType('category', PARAM_INT);
$mform->addElement('text','fullname', get_string('fullnamecourse'),'maxlength="254" size="50"');
@ -113,13 +114,13 @@ class course_edit_form extends moodleform {
}
$mform->addElement('select', 'format', get_string('format'), $formcourseformats);
$mform->setHelpButton('format', array('courseformats', get_string('courseformats')), true);
$mform->setDefault('format', $CFG->course_format);
$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', $CFG->course_numsections);
$mform->setDefault('numsections', $courseconfig->numsections);
$mform->addElement('date_selector', 'startdate', get_string('startdate'));
$mform->setHelpButton('startdate', array('coursestartdate', get_string('startdate')), true);
@ -130,25 +131,25 @@ class course_edit_form extends moodleform {
$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', $CFG->course_hiddensections);
$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', $CFG->course_newsitems);
$mform->setDefault('newsitems', $courseconfig->newsitems);
$mform->addElement('selectyesno', 'showgrades', get_string('showgrades'));
$mform->setHelpButton('showgrades', array('coursegrades', get_string('grades')), true);
$mform->setDefault('showgrades', $CFG->course_showgrades);
$mform->setDefault('showgrades', $courseconfig->showgrades);
$mform->addElement('selectyesno', 'showreports', get_string('showreports'));
$mform->setHelpButton('showreports', array('coursereports', get_string('activityreport')), true);
$mform->setDefault('showreports', $CFG->course_showreports);
$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', $CFG->course_maxbytes);
$mform->setDefault('maxbytes', $courseconfig->maxbytes);
if (!empty($CFG->allowcoursethemes)) {
$themes=array();
@ -163,7 +164,7 @@ class course_edit_form extends moodleform {
if ($disable_meta === false) {
$mform->addElement('select', 'metacourse', get_string('managemeta'), $meta);
$mform->setHelpButton('metacourse', array('metacourse', get_string('metacourse')), true);
$mform->setDefault('metacourse', $CFG->course_metacourse);
$mform->setDefault('metacourse', $courseconfig->metacourse);
} else {
// no metacourse element - we do not want to change it anyway!
$mform->addElement('static', 'nometacourse', get_string('managemeta'),
@ -188,7 +189,7 @@ class course_edit_form extends moodleform {
$choices = array_merge(array('' => get_string('sitedefault').' ('.get_string('enrolname', "enrol_$CFG->enrol").')'), $choices);
$mform->addElement('select', 'enrol', get_string('enrolmentplugins'), $choices);
$mform->setHelpButton('enrol', array('courseenrolmentplugins', get_string('enrolmentplugins')), true);
$mform->setDefault('enrol', $CFG->course_enrol);
$mform->setDefault('enrol', $courseconfig->enrol);
$roles = get_assignable_roles($context);
@ -221,7 +222,7 @@ class course_edit_form extends moodleform {
$radio[] = &MoodleQuickForm::createElement('radio', 'enrollable', null, get_string('enroldate'), 2);
$mform->addGroup($radio, 'enrollable', get_string('enrollable'), ' ', false);
$mform->setHelpButton('enrollable', array('courseenrollable2', get_string('enrollable')), true);
$mform->setDefault('enrollable', $CFG->course_enrollable);
$mform->setDefault('enrollable', $courseconfig->enrollable);
$enroldatestartgrp = array();
$enroldatestartgrp[] = &MoodleQuickForm::createElement('date_selector', 'enrolstartdate');
@ -246,7 +247,7 @@ class course_edit_form extends moodleform {
$periodmenu[$seconds] = get_string('numdays', '', $i);
}
$mform->addElement('select', 'enrolperiod', get_string('enrolperiod'), $periodmenu);
$mform->setDefault('enrolperiod', $CFG->course_enrolperiod);
$mform->setDefault('enrolperiod', $courseconfig->enrolperiod);
//--------------------------------------------------------------------------------
@ -257,11 +258,11 @@ class course_edit_form extends moodleform {
$choices['1'] = get_string('yes');
$mform->addElement('select', 'expirynotify', get_string('notify'), $choices);
$mform->setHelpButton('expirynotify', array('expirynotify', get_string('expirynotify')), true);
$mform->setDefault('expirynotify', $CFG->course_expirynotify);
$mform->setDefault('expirynotify', $courseconfig->expirynotify);
$mform->addElement('select', 'notifystudents', get_string('expirynotifystudents'), $choices);
$mform->setHelpButton('notifystudents', array('expirynotifystudents', get_string('expirynotifystudents')), true);
$mform->setDefault('notifystudents', $CFG->course_notifystudents);
$mform->setDefault('notifystudents', $courseconfig->notifystudents);
$thresholdmenu=array();
for ($i=1; $i<=30; $i++) {
@ -270,7 +271,7 @@ class course_edit_form extends moodleform {
}
$mform->addElement('select', 'expirythreshold', get_string('expirythreshold'), $thresholdmenu);
$mform->setHelpButton('expirythreshold', array('expirythreshold', get_string('expirythreshold')), true);
$mform->setDefault('expirythreshold', $CFG->course_expirythreshold);
$mform->setDefault('expirythreshold', $courseconfig->expirythreshold);
//--------------------------------------------------------------------------------
$mform->addElement('header','', get_string('groups', 'group'));
@ -281,14 +282,14 @@ class course_edit_form extends moodleform {
$choices[VISIBLEGROUPS] = get_string('groupsvisible', 'group');
$mform->addElement('select', 'groupmode', get_string('groupmode'), $choices);
$mform->setHelpButton('groupmode', array('groupmode', get_string('groupmode')), true);
$mform->setDefault('groupmode', $CFG->course_groupmode);
$mform->setDefault('groupmode', $courseconfig->groupmode);
$choices = array();
$choices['0'] = get_string('no');
$choices['1'] = get_string('yes');
$mform->addElement('select', 'groupmodeforce', get_string('force'), $choices);
$mform->setHelpButton('groupmodeforce', array('groupmodeforce', get_string('groupmodeforce')), true);
$mform->setDefault('groupmodeforce', $CFG->course_groupmodeforce);
$mform->setDefault('groupmodeforce', $courseconfig->groupmodeforce);
if (!empty($CFG->enablegroupings)) {
//default groupings selector
@ -305,12 +306,12 @@ class course_edit_form extends moodleform {
$choices['1'] = get_string('courseavailable');
$mform->addElement('select', 'visible', get_string('availability'), $choices);
$mform->setHelpButton('visible', array('courseavailability', get_string('availability')), true);
$mform->setDefault('visible', $CFG->course_visible);
$mform->setDefault('visible', $courseconfig->visible);
$mform->addElement('passwordunmask', 'enrolpassword', get_string('enrolmentkey'), 'size="25"');
$mform->setHelpButton('enrolpassword', array('enrolmentkey', get_string('enrolmentkey')), true);
$mform->setDefault('enrolpassword', '');
$mform->setDefault('enrolpassword', $CFG->course_enrolpassword);
$mform->setDefault('enrolpassword', $courseconfig->enrolpassword);
$mform->setType('enrolpassword', PARAM_RAW);
$choices = array();
@ -319,7 +320,7 @@ class course_edit_form extends moodleform {
$choices['2'] = get_string('guestskey');
$mform->addElement('select', 'guest', get_string('opentoguests'), $choices);
$mform->setHelpButton('guest', array('guestaccess', get_string('opentoguests')), true);
$mform->setDefault('guest', $CFG->course_guest);
$mform->setDefault('guest', $courseconfig->guest);
// If we are creating a course, its enrol method isn't yet chosen, BUT the site has a default enrol method which we can use here
$enrol_object = $CFG;
@ -352,7 +353,7 @@ class course_edit_form extends moodleform {
$languages[''] = get_string('forceno');
$languages += get_list_of_languages();
$mform->addElement('select', 'lang', get_string('forcelanguage'), $languages);
$mform->setDefault('lang', $CFG->course_lang);
$mform->setDefault('lang', $courseconfig->lang);
//--------------------------------------------------------------------------------
require_once($CFG->libdir.'/completionlib.php');
@ -360,7 +361,7 @@ class course_edit_form extends moodleform {
$mform->addElement('header','', get_string('progress','completion'));
$mform->addElement('select', 'enablecompletion', get_string('completion','completion'),
array(0=>get_string('completiondisabled','completion'), 1=>get_string('completionenabled','completion')));
$mform->setDefault('enablecompletion', $CFG->course_enablecompletion);
$mform->setDefault('enablecompletion', $courseconfig->enablecompletion);
} else {
$mform->addElement('hidden', 'enablecompletion');
$mform->setDefault('enablecompletion',0);