3fe8dd6fc5c7dabb8b531be2e5ad3eeed03c0ba8
[moodle.git] / admin / settings / courses.php
1 <?php
3 // This file defines settingpages and externalpages under the "courses" category
5 if ($hassiteconfig
6  or has_capability('moodle/backup:backupcourse', $systemcontext)
7  or has_capability('moodle/category:manage', $systemcontext)
8  or has_capability('moodle/course:create', $systemcontext)
9  or has_capability('moodle/site:approvecourse', $systemcontext)) { // speedup for non-admins, add all caps used on this page
11     $ADMIN->add('courses', new admin_externalpage('coursemgmt', get_string('coursemgmt', 'admin'), $CFG->wwwroot . '/course/index.php?categoryedit=on',
12             array('moodle/category:manage', 'moodle/course:create')));
14     $ADMIN->add('courses', new admin_enrolment_page());
16 /// Course Default Settings Page
17 /// NOTE: these settings must be applied after all other settings because they depend on them
18     ///main course settings
19     $temp = new admin_settingpage('coursesettings', get_string('coursesettings'));
20     $courseformats = get_plugin_list('format');
21     $formcourseformats = array();
22     foreach ($courseformats as $courseformat => $courseformatdir) {
23         $formcourseformats[$courseformat] = get_string('pluginname', "format_$courseformat");
24     }
25     $temp->add(new admin_setting_configselect('moodlecourse/format', get_string('format'), get_string('coursehelpformat'), 'weeks',$formcourseformats));
26     for ($i=1; $i<=52; $i++) {
27         $sectionmenu[$i] = "$i";
28     }
29     $temp->add(new admin_setting_configselect('moodlecourse/numsections', get_string('numberweeks'), get_string('coursehelpnumberweeks'), 10,$sectionmenu));
30     $choices = array();
31     $choices['0'] = get_string('hiddensectionscollapsed');
32     $choices['1'] = get_string('hiddensectionsinvisible');
33     $temp->add(new admin_setting_configselect('moodlecourse/hiddensections', get_string('hiddensections'), get_string('coursehelphiddensections'), 0,$choices));
34     $options = range(0, 10);
35     $temp->add(new admin_setting_configselect('moodlecourse/newsitems', get_string('newsitemsnumber'), get_string('coursehelpnewsitemsnumber'), 5,$options));
36     $temp->add(new admin_setting_configselect('moodlecourse/showgrades', get_string('showgrades'), get_string('coursehelpshowgrades'), 1,array(0 => get_string('no'), 1 => get_string('yes'))));
37     $temp->add(new admin_setting_configselect('moodlecourse/showreports', get_string('showreports'), '', 0,array(0 => get_string('no'), 1 => get_string('yes'))));
38     if (isset($CFG->maxbytes)) {
39         $choices = get_max_upload_sizes($CFG->maxbytes);
40     } else {
41         $choices = get_max_upload_sizes();
42     }
43     $temp->add(new admin_setting_configselect('moodlecourse/maxbytes', get_string('maximumupload'), get_string('coursehelpmaximumupload'), key($choices), $choices));
44     $temp->add(new admin_setting_configselect('moodlecourse/metacourse', get_string('metacourse'), get_string('coursehelpmetacourse'), 0,array(0 => get_string('no'), 1 => get_string('yes'))));
46     ///enrolement course settings
47     $temp->add(new admin_setting_heading('enrolhdr', get_string('enrolments'), ''));
48     require_once($CFG->dirroot.'/enrol/enrol.class.php');
49     $choices = array();
50     $modules = explode(',', $CFG->enrol_plugins_enabled);
51     foreach ($modules as $module) {
52         $name = get_string('enrolname', "enrol_$module");
53         $plugin = enrolment_factory::factory($module);
54         if (method_exists($plugin, 'print_entry')) {
55             $choices[$name] = $module;
56         }
57     }
58     asort($choices);
59     $choices = array_flip($choices);
60     $choices = array_merge(array('' => get_string('sitedefault').' ('.get_string('enrolname', "enrol_$CFG->enrol").')'), $choices);
61     $temp->add(new admin_setting_configselect('moodlecourse/enrol', get_string('enrolmentplugins'), get_string('coursehelpenrolmentplugins'), key($choices),$choices));
62     $choices = array(0 => get_string('no'), 1 => get_string('yes'), 2 => get_string('enroldate'));
63     $temp->add(new admin_setting_configselect('moodlecourse/enrollable', get_string('enrollable'), get_string('coursehelpenrollable'), 1,$choices));
64     $periodmenu=array();
65     $periodmenu[0] = get_string('unlimited');
66     for ($i=1; $i<=365; $i++) {
67         $seconds = $i * 86400;
68         $periodmenu[$seconds] = get_string('numdays', '', $i);
69     }
70     $temp->add(new admin_setting_configselect('moodlecourse/enrolperiod', get_string('enrolperiod'), '', 0,$periodmenu));
72     ///
73     $temp->add(new admin_setting_heading('expirynotifyhdr', get_string('expirynotify'), ''));
74     $temp->add(new admin_setting_configselect('moodlecourse/expirynotify', get_string('notify'), get_string('coursehelpnotify'), 0,array(0 => get_string('no'), 1 => get_string('yes'))));
75     $temp->add(new admin_setting_configselect('moodlecourse/notifystudents', get_string('expirynotifystudents'), get_string('coursehelpexpirynotifystudents'), 0,array(0 => get_string('no'), 1 => get_string('yes'))));
76     $thresholdmenu=array();
77     for ($i=1; $i<=30; $i++) {
78         $seconds = $i * 86400;
79         $thresholdmenu[$seconds] = get_string('numdays', '', $i);
80     }
81     $temp->add(new admin_setting_configselect('moodlecourse/expirythreshold', get_string('expirythreshold'), get_string('coursehelpexpirythreshold'), 10 * 86400,$thresholdmenu));
84     $temp->add(new admin_setting_heading('groups', get_string('groups', 'group'), ''));
85     $choices = array();
86     $choices[NOGROUPS] = get_string('groupsnone', 'group');
87     $choices[SEPARATEGROUPS] = get_string('groupsseparate', 'group');
88     $choices[VISIBLEGROUPS] = get_string('groupsvisible', 'group');
89     $temp->add(new admin_setting_configselect('moodlecourse/groupmode', get_string('groupmode'), '', key($choices),$choices));
90     $temp->add(new admin_setting_configselect('moodlecourse/groupmodeforce', get_string('force'), get_string('coursehelpforce'), 0,array(0 => get_string('no'), 1 => get_string('yes'))));
93     $temp->add(new admin_setting_heading('availability', get_string('availability'), ''));
94     $choices = array();
95     $choices['0'] = get_string('courseavailablenot');
96     $choices['1'] = get_string('courseavailable');
97     $temp->add(new admin_setting_configselect('moodlecourse/visible', get_string('visible'), '', 1,$choices));
98     $temp->add(new admin_setting_configpasswordunmask('moodlecourse/enrolpassword', get_string('enrolmentkey'), get_string('coursehelpenrolmentkey'),''));
99     $choices = array();
100     $choices['0'] = get_string('guestsno');
101     $choices['1'] = get_string('guestsyes');
102     $choices['2'] = get_string('guestskey');
103     $temp->add(new admin_setting_configselect('moodlecourse/guest', get_string('opentoguests'), '', 0,$choices));
106     $temp->add(new admin_setting_heading('language', get_string('language'), ''));
107     $languages=array();
108     $languages[''] = get_string('forceno');
109     $languages += get_list_of_languages();
110     $temp->add(new admin_setting_configselect('moodlecourse/lang', get_string('forcelanguage'), '',key($languages),$languages));
112     if (!empty($CFG->enablecompletion)) {
113         $temp->add(new admin_setting_heading('progress', get_string('progress','completion'), ''));
114         $temp->add(new admin_setting_configselect('moodlecourse/enablecompletion', get_string('completion','completion'), '',
115             1, array(0 => get_string('completiondisabled','completion'), 1 => get_string('completionenabled','completion'))));
116     }
117     $ADMIN->add('courses', $temp);
119 /// "courserequests" settingpage
120     $temp = new admin_settingpage('courserequest', get_string('courserequest'));
121     $temp->add(new admin_setting_configcheckbox('enablecourserequests', get_string('enablecourserequests', 'admin'), get_string('configenablecourserequests', 'admin'), 0));
122     $temp->add(new admin_settings_coursecat_select('defaultrequestcategory', get_string('defaultrequestcategory', 'admin'), get_string('configdefaultrequestcategory', 'admin'), 1));
123     $temp->add(new admin_setting_users_with_capability('courserequestnotify', get_string('courserequestnotify', 'admin'), get_string('configcourserequestnotify2', 'admin'), array(), 'moodle/site:approvecourse'));
124     $ADMIN->add('courses', $temp);
126 /// Pending course requests.
127     if (!empty($CFG->enablecourserequests)) {
128         $ADMIN->add('courses', new admin_externalpage('coursespending', get_string('pendingrequests'),
129                 $CFG->wwwroot . '/course/pending.php', array('moodle/site:approvecourse')));
130     }
132 /// "backups" settingpage
133     $temp = new admin_settingpage('backups', get_string('backups','admin'), 'moodle/backup:backupcourse');
134     $temp->add(new admin_setting_configcheckbox('backup/backup_sche_modules', get_string('includemodules'), get_string('backupincludemoduleshelp'), 0));
135     $temp->add(new admin_setting_configcheckbox('backup/backup_sche_withuserdata', get_string('includemoduleuserdata'), get_string('backupincludemoduleuserdatahelp'), 0));
136     $temp->add(new admin_setting_configcheckbox('backup/backup_sche_metacourse', get_string('metacourse'), get_string('backupmetacoursehelp'), 0));
137     $temp->add(new admin_setting_configselect('backup/backup_sche_users', get_string('users'), get_string('backupusershelp'),
138             0, array(0 => get_string('all'), 1 => get_string('course'))));
139     $temp->add(new admin_setting_configcheckbox('backup/backup_sche_logs', get_string('logs'), get_string('backuplogshelp'), 0));
140     $temp->add(new admin_setting_configcheckbox('backup/backup_sche_userfiles', get_string('userfiles'), get_string('backupuserfileshelp'), 0));
141     $temp->add(new admin_setting_configcheckbox('backup/backup_sche_coursefiles', get_string('coursefiles'), get_string('backupcoursefileshelp'), 0));
142     $temp->add(new admin_setting_configcheckbox('backup/backup_sche_sitefiles', get_string('sitefiles'), get_string('backupsitefileshelp'), 0));
143     $temp->add(new admin_setting_configcheckbox('backup_sche_gradebook_history', get_string('gradebookhistories', 'grades'), get_string('backupgradebookhistoryhelp'), 0));
144     $temp->add(new admin_setting_configcheckbox('backup/backup_sche_messages', get_string('messages', 'message'), get_string('backupmessageshelp','message'), 0));
145     $temp->add(new admin_setting_configcheckbox('backup/backup_sche_blogs', get_string('blogs', 'blog'), get_string('backupblogshelp','blog'), 0));
147     $keepoptoins = array(
148         0 => get_string('all'), 1 => '1',
149         2 => '2',
150         5 => '5',
151         10 => '10',
152         20 => '20',
153         30 => '30',
154         40 => '40',
155         50 => '50',
156         100 => '100',
157         200 => '200',
158         300 => '300',
159         400 => '400',
160         500 => '500');
161     $temp->add(new admin_setting_configselect('backup/backup_sche_keep', get_string('keep'),
162             get_string('backupkeephelp'), 1, $keepoptoins));
163     $temp->add(new admin_setting_configcheckbox('backup/backup_sche_active', get_string('active'), get_string('backupactivehelp'), 0));
164     $temp->add(new admin_setting_special_backupdays());
165     $temp->add(new admin_setting_configtime('backup/backup_sche_hour', 'backup_sche_minute', get_string('executeat'),
166             get_string('backupexecuteathelp'), array('h' => 0, 'm' => 0)));
167     $temp->add(new admin_setting_configdirectory('backup/backup_sche_destination', get_string('saveto'), get_string('backupsavetohelp'), ''));
169     $ADMIN->add('courses', $temp);
171 } // end of speedup