Merge branch 'wip-mdl-41843-m25' of git://github.com/rajeshtaneja/moodle into MOODLE_...
[moodle.git] / admin / settings / courses.php
blob377034be9c1d219c1267707c5e8959f452ebf4bf
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', new lang_string('coursemgmt', 'admin'), $CFG->wwwroot . '/course/manage.php',
12 array('moodle/category:manage', 'moodle/course:create')));
14 // Course Default Settings Page.
15 // 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', new lang_string('coursesettings'));
20 require_once($CFG->dirroot.'/course/lib.php');
22 $choices = array();
23 $choices['0'] = new lang_string('hide');
24 $choices['1'] = new lang_string('show');
25 $temp->add(new admin_setting_configselect('moodlecourse/visible', new lang_string('visible'), new lang_string('visible_help'),
26 1, $choices));
29 // Course format.
30 $temp->add(new admin_setting_heading('courseformathdr', new lang_string('type_format', 'plugin'), ''));
32 $courseformats = get_sorted_course_formats(true);
33 $formcourseformats = array();
34 foreach ($courseformats as $courseformat) {
35 $formcourseformats[$courseformat] = new lang_string('pluginname', "format_$courseformat");
37 $temp->add(new admin_setting_configselect('moodlecourse/format', new lang_string('format'), new lang_string('coursehelpformat'),
38 'weeks',$formcourseformats));
40 $temp->add(new admin_setting_configtext('moodlecourse/maxsections', new lang_string('maxnumberweeks'),
41 new lang_string('maxnumberweeks_desc'), 52));
43 $temp->add(new admin_settings_num_course_sections('moodlecourse/numsections', new lang_string('numberweeks'),
44 new lang_string('coursehelpnumberweeks'), 10));
46 $choices = array();
47 $choices['0'] = new lang_string('hiddensectionscollapsed');
48 $choices['1'] = new lang_string('hiddensectionsinvisible');
49 $temp->add(new admin_setting_configselect('moodlecourse/hiddensections', new lang_string('hiddensections'),
50 new lang_string('coursehelphiddensections'), 0, $choices));
52 $choices = array();
53 $choices[COURSE_DISPLAY_SINGLEPAGE] = new lang_string('coursedisplay_single');
54 $choices[COURSE_DISPLAY_MULTIPAGE] = new lang_string('coursedisplay_multi');
55 $temp->add(new admin_setting_configselect('moodlecourse/coursedisplay', new lang_string('coursedisplay'),
56 new lang_string('coursedisplay_help'), COURSE_DISPLAY_SINGLEPAGE, $choices));
59 // Appearance.
60 $temp->add(new admin_setting_heading('appearancehdr', new lang_string('appearance'), ''));
62 $languages = array();
63 $languages[''] = new lang_string('forceno');
64 $languages += get_string_manager()->get_list_of_translations();
65 $temp->add(new admin_setting_configselect('moodlecourse/lang', new lang_string('forcelanguage'), '', key($languages),
66 $languages));
68 $options = range(0, 10);
69 $temp->add(new admin_setting_configselect('moodlecourse/newsitems', new lang_string('newsitemsnumber'),
70 new lang_string('coursehelpnewsitemsnumber'), 5, $options));
71 $temp->add(new admin_setting_configselect('moodlecourse/showgrades', new lang_string('showgrades'),
72 new lang_string('coursehelpshowgrades'), 1, array(0 => new lang_string('no'), 1 => new lang_string('yes'))));
73 $temp->add(new admin_setting_configselect('moodlecourse/showreports', new lang_string('showreports'), '', 0,
74 array(0 => new lang_string('no'), 1 => new lang_string('yes'))));
77 // Files and uploads.
78 $temp->add(new admin_setting_heading('filesanduploadshdr', new lang_string('filesanduploads'), ''));
80 if (!empty($CFG->legacyfilesinnewcourses)) {
81 $choices = array('0'=>new lang_string('no'), '2'=>new lang_string('yes'));
82 $temp->add(new admin_setting_configselect('moodlecourse/legacyfiles', new lang_string('courselegacyfiles'),
83 new lang_string('courselegacyfiles_help'), key($choices), $choices));
86 $currentmaxbytes = get_config('moodlecourse', 'maxbytes');
87 if (isset($CFG->maxbytes)) {
88 $choices = get_max_upload_sizes($CFG->maxbytes, 0, 0, $currentmaxbytes);
89 } else {
90 $choices = get_max_upload_sizes(0, 0, 0, $currentmaxbytes);
92 $temp->add(new admin_setting_configselect('moodlecourse/maxbytes', new lang_string('maximumupload'),
93 new lang_string('coursehelpmaximumupload'), key($choices), $choices));
96 // Completion tracking.
97 $temp->add(new admin_setting_heading('progress', new lang_string('completion','completion'), ''));
98 $temp->add(new admin_setting_configselect('moodlecourse/enablecompletion', new lang_string('completion', 'completion'),
99 new lang_string('enablecompletion_help', 'completion'), 0, array(0 => new lang_string('no'), 1 => new lang_string('yes'))));
102 // Groups.
103 $temp->add(new admin_setting_heading('groups', new lang_string('groups', 'group'), ''));
104 $choices = array();
105 $choices[NOGROUPS] = new lang_string('groupsnone', 'group');
106 $choices[SEPARATEGROUPS] = new lang_string('groupsseparate', 'group');
107 $choices[VISIBLEGROUPS] = new lang_string('groupsvisible', 'group');
108 $temp->add(new admin_setting_configselect('moodlecourse/groupmode', new lang_string('groupmode'), '', key($choices),$choices));
109 $temp->add(new admin_setting_configselect('moodlecourse/groupmodeforce', new lang_string('force'), new lang_string('coursehelpforce'), 0,array(0 => new lang_string('no'), 1 => new lang_string('yes'))));
111 $ADMIN->add('courses', $temp);
114 // "courserequests" settingpage.
115 $temp = new admin_settingpage('courserequest', new lang_string('courserequest'));
116 $temp->add(new admin_setting_configcheckbox('enablecourserequests', new lang_string('enablecourserequests', 'admin'), new lang_string('configenablecourserequests', 'admin'), 0));
117 $temp->add(new admin_settings_coursecat_select('defaultrequestcategory', new lang_string('defaultrequestcategory', 'admin'), new lang_string('configdefaultrequestcategory', 'admin'), 1));
118 $temp->add(new admin_setting_configcheckbox('requestcategoryselection', new lang_string('requestcategoryselection', 'admin'), new lang_string('configrequestcategoryselection', 'admin'), 0));
119 $temp->add(new admin_setting_users_with_capability('courserequestnotify', new lang_string('courserequestnotify', 'admin'), new lang_string('configcourserequestnotify2', 'admin'), array(), 'moodle/site:approvecourse'));
120 $ADMIN->add('courses', $temp);
122 /// Pending course requests.
123 if (!empty($CFG->enablecourserequests)) {
124 $ADMIN->add('courses', new admin_externalpage('coursespending', new lang_string('pendingrequests'),
125 $CFG->wwwroot . '/course/pending.php', array('moodle/site:approvecourse')));
128 // Add a category for backups
129 $ADMIN->add('courses', new admin_category('backups', new lang_string('backups','admin')));
131 // Create a page for general backups configuration and defaults.
132 $temp = new admin_settingpage('backupgeneralsettings', new lang_string('generalbackdefaults', 'backup'), 'moodle/backup:backupcourse');
134 // General configuration section.
135 $temp->add(new admin_setting_configselect('backup/loglifetime', new lang_string('loglifetime', 'backup'), new lang_string('configloglifetime', 'backup'), 30, array(
136 1 => new lang_string('numdays', '', 1),
137 2 => new lang_string('numdays', '', 2),
138 3 => new lang_string('numdays', '', 3),
139 5 => new lang_string('numdays', '', 5),
140 7 => new lang_string('numdays', '', 7),
141 10 => new lang_string('numdays', '', 10),
142 14 => new lang_string('numdays', '', 14),
143 20 => new lang_string('numdays', '', 20),
144 30 => new lang_string('numdays', '', 30),
145 60 => new lang_string('numdays', '', 60),
146 90 => new lang_string('numdays', '', 90),
147 120 => new lang_string('numdays', '', 120),
148 180 => new lang_string('numdays', '', 180),
149 365 => new lang_string('numdays', '', 365)
150 )));
152 // General defaults section.
153 $temp->add(new admin_setting_heading('generalsettings', new lang_string('generalsettings', 'backup'), ''));
154 $temp->add(new admin_setting_configcheckbox_with_lock('backup/backup_general_users', new lang_string('generalusers','backup'), new lang_string('configgeneralusers','backup'), array('value'=>1, 'locked'=>0)));
155 $temp->add(new admin_setting_configcheckbox_with_lock('backup/backup_general_anonymize', new lang_string('generalanonymize','backup'), new lang_string('configgeneralanonymize','backup'), array('value'=>0, 'locked'=>0)));
156 $temp->add(new admin_setting_configcheckbox_with_lock('backup/backup_general_role_assignments', new lang_string('generalroleassignments','backup'), new lang_string('configgeneralroleassignments','backup'), array('value'=>1, 'locked'=>0)));
157 $temp->add(new admin_setting_configcheckbox_with_lock('backup/backup_general_activities', new lang_string('generalactivities','backup'), new lang_string('configgeneralactivities','backup'), array('value'=>1, 'locked'=>0)));
158 $temp->add(new admin_setting_configcheckbox_with_lock('backup/backup_general_blocks', new lang_string('generalblocks','backup'), new lang_string('configgeneralblocks','backup'), array('value'=>1, 'locked'=>0)));
159 $temp->add(new admin_setting_configcheckbox_with_lock('backup/backup_general_filters', new lang_string('generalfilters','backup'), new lang_string('configgeneralfilters','backup'), array('value'=>1, 'locked'=>0)));
160 $temp->add(new admin_setting_configcheckbox_with_lock('backup/backup_general_comments', new lang_string('generalcomments','backup'), new lang_string('configgeneralcomments','backup'), array('value'=>1, 'locked'=>0)));
161 $temp->add(new admin_setting_configcheckbox_with_lock('backup/backup_general_badges', new lang_string('generalbadges','backup'), new lang_string('configgeneralbadges','backup'), array('value'=>1,'locked'=>0)));
162 $temp->add(new admin_setting_configcheckbox_with_lock('backup/backup_general_userscompletion', new lang_string('generaluserscompletion','backup'), new lang_string('configgeneraluserscompletion','backup'), array('value'=>1, 'locked'=>0)));
163 $temp->add(new admin_setting_configcheckbox_with_lock('backup/backup_general_logs', new lang_string('generallogs','backup'), new lang_string('configgenerallogs','backup'), array('value'=>0, 'locked'=>0)));
164 $temp->add(new admin_setting_configcheckbox_with_lock('backup/backup_general_histories', new lang_string('generalhistories','backup'), new lang_string('configgeneralhistories','backup'), array('value'=>0, 'locked'=>0)));
165 $ADMIN->add('backups', $temp);
167 // Create a page for general import configuration and defaults.
168 $temp = new admin_settingpage('importgeneralsettings', new lang_string('importgeneralsettings', 'backup'), 'moodle/backup:backupcourse');
169 $temp->add(new admin_setting_configtext('backup/import_general_maxresults', new lang_string('importgeneralmaxresults', 'backup'), new lang_string('importgeneralmaxresults_desc', 'backup'), 10));
170 $ADMIN->add('backups', $temp);
172 // Create a page for automated backups configuration and defaults.
173 $temp = new admin_settingpage('automated', new lang_string('automatedsetup','backup'), 'moodle/backup:backupcourse');
175 // Automated configuration section.
176 $temp->add(new admin_setting_configselect('backup/backup_auto_active', new lang_string('active'), new lang_string('autoactivedescription', 'backup'), 0, array(
177 0 => new lang_string('autoactivedisabled', 'backup'),
178 1 => new lang_string('autoactiveenabled', 'backup'),
179 2 => new lang_string('autoactivemanual', 'backup')
180 )));
181 $temp->add(new admin_setting_special_backupdays());
182 $temp->add(new admin_setting_configtime('backup/backup_auto_hour', 'backup_auto_minute', new lang_string('executeat'),
183 new lang_string('backupexecuteathelp'), array('h' => 0, 'm' => 0)));
184 $storageoptions = array(
185 0 => new lang_string('storagecourseonly', 'backup'),
186 1 => new lang_string('storageexternalonly', 'backup'),
187 2 => new lang_string('storagecourseandexternal', 'backup')
189 $temp->add(new admin_setting_configselect('backup/backup_auto_storage', new lang_string('automatedstorage', 'backup'), new lang_string('automatedstoragehelp', 'backup'), 0, $storageoptions));
190 $temp->add(new admin_setting_configdirectory('backup/backup_auto_destination', new lang_string('saveto'), new lang_string('backupsavetohelp'), ''));
191 $keepoptoins = array(
192 0 => new lang_string('all'), 1 => '1',
193 2 => '2',
194 5 => '5',
195 10 => '10',
196 20 => '20',
197 30 => '30',
198 40 => '40',
199 50 => '50',
200 100 => '100',
201 200 => '200',
202 300 => '300',
203 400 => '400',
204 500 => '500');
205 $temp->add(new admin_setting_configselect('backup/backup_auto_keep', new lang_string('keep'), new lang_string('backupkeephelp'), 1, $keepoptoins));
206 $temp->add(new admin_setting_configcheckbox('backup/backup_shortname', new lang_string('backup_shortname', 'admin'), new lang_string('backup_shortnamehelp', 'admin'), 0));
207 $temp->add(new admin_setting_configcheckbox('backup/backup_auto_skip_hidden', new lang_string('skiphidden', 'backup'), new lang_string('skiphiddenhelp', 'backup'), 1));
208 $temp->add(new admin_setting_configselect('backup/backup_auto_skip_modif_days', new lang_string('skipmodifdays', 'backup'), new lang_string('skipmodifdayshelp', 'backup'), 30, array(
209 0 => new lang_string('never'),
210 1 => new lang_string('numdays', '', 1),
211 2 => new lang_string('numdays', '', 2),
212 3 => new lang_string('numdays', '', 3),
213 5 => new lang_string('numdays', '', 5),
214 7 => new lang_string('numdays', '', 7),
215 10 => new lang_string('numdays', '', 10),
216 14 => new lang_string('numdays', '', 14),
217 20 => new lang_string('numdays', '', 20),
218 30 => new lang_string('numdays', '', 30),
219 60 => new lang_string('numdays', '', 60),
220 90 => new lang_string('numdays', '', 90),
221 120 => new lang_string('numdays', '', 120),
222 180 => new lang_string('numdays', '', 180),
223 365 => new lang_string('numdays', '', 365)
224 )));
225 $temp->add(new admin_setting_configcheckbox('backup/backup_auto_skip_modif_prev', new lang_string('skipmodifprev', 'backup'), new lang_string('skipmodifprevhelp', 'backup'), 0));
227 // Automated defaults section.
228 $temp->add(new admin_setting_heading('automatedsettings', new lang_string('automatedsettings','backup'), ''));
229 $temp->add(new admin_setting_configcheckbox('backup/backup_auto_users', new lang_string('generalusers', 'backup'), new lang_string('configgeneralusers', 'backup'), 1));
230 $temp->add(new admin_setting_configcheckbox('backup/backup_auto_role_assignments', new lang_string('generalroleassignments','backup'), new lang_string('configgeneralroleassignments','backup'), 1));
231 $temp->add(new admin_setting_configcheckbox('backup/backup_auto_activities', new lang_string('generalactivities','backup'), new lang_string('configgeneralactivities','backup'), 1));
232 $temp->add(new admin_setting_configcheckbox('backup/backup_auto_blocks', new lang_string('generalblocks','backup'), new lang_string('configgeneralblocks','backup'), 1));
233 $temp->add(new admin_setting_configcheckbox('backup/backup_auto_filters', new lang_string('generalfilters','backup'), new lang_string('configgeneralfilters','backup'), 1));
234 $temp->add(new admin_setting_configcheckbox('backup/backup_auto_comments', new lang_string('generalcomments','backup'), new lang_string('configgeneralcomments','backup'), 1));
235 $temp->add(new admin_setting_configcheckbox('backup/backup_auto_badges', new lang_string('generalbadges','backup'), new lang_string('configgeneralbadges','backup'), 1));
236 $temp->add(new admin_setting_configcheckbox('backup/backup_auto_userscompletion', new lang_string('generaluserscompletion','backup'), new lang_string('configgeneraluserscompletion','backup'), 1));
237 $temp->add(new admin_setting_configcheckbox('backup/backup_auto_logs', new lang_string('generallogs', 'backup'), new lang_string('configgenerallogs', 'backup'), 0));
238 $temp->add(new admin_setting_configcheckbox('backup/backup_auto_histories', new lang_string('generalhistories','backup'), new lang_string('configgeneralhistories','backup'), 0));
241 //$temp->add(new admin_setting_configcheckbox('backup/backup_auto_messages', new lang_string('messages', 'message'), new lang_string('backupmessageshelp','message'), 0));
242 //$temp->add(new admin_setting_configcheckbox('backup/backup_auto_blogs', new lang_string('blogs', 'blog'), new lang_string('backupblogshelp','blog'), 0));
244 $ADMIN->add('backups', $temp);
246 } // end of speedup