courses.php 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327
  1. <?php
  2. // This file is part of Moodle - http://moodle.org/
  3. //
  4. // Moodle is free software: you can redistribute it and/or modify
  5. // it under the terms of the GNU General Public License as published by
  6. // the Free Software Foundation, either version 3 of the License, or
  7. // (at your option) any later version.
  8. //
  9. // Moodle is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU General Public License for more details.
  13. //
  14. // You should have received a copy of the GNU General Public License
  15. // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
  16. /**
  17. * This file defines settingpages and externalpages under the "courses" category
  18. *
  19. * @package core
  20. * @copyright 2002 onwards Martin Dougiamas (http://dougiamas.com)
  21. * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  22. */
  23. $capabilities = array(
  24. 'moodle/backup:backupcourse',
  25. 'moodle/category:manage',
  26. 'moodle/course:create',
  27. 'moodle/site:approvecourse',
  28. 'moodle/restore:restorecourse'
  29. );
  30. if ($hassiteconfig or has_any_capability($capabilities, $systemcontext)) {
  31. // Speedup for non-admins, add all caps used on this page.
  32. $ADMIN->add('courses',
  33. new admin_externalpage('coursemgmt', new lang_string('coursemgmt', 'admin'),
  34. $CFG->wwwroot . '/course/management.php',
  35. array('moodle/category:manage', 'moodle/course:create')
  36. )
  37. );
  38. $ADMIN->add('courses',
  39. new admin_externalpage('addcategory', new lang_string('addcategory', 'admin'),
  40. new moodle_url('/course/editcategory.php', array('parent' => 0)),
  41. array('moodle/category:manage')
  42. )
  43. );
  44. $ADMIN->add('courses',
  45. new admin_externalpage('restorecourse', new lang_string('restorecourse', 'admin'),
  46. new moodle_url('/backup/restorefile.php', array('contextid' => context_system::instance()->id)),
  47. array('moodle/restore:restorecourse')
  48. )
  49. );
  50. // Course Default Settings Page.
  51. // NOTE: these settings must be applied after all other settings because they depend on them.
  52. // Main course settings.
  53. $temp = new admin_settingpage('coursesettings', new lang_string('coursesettings'));
  54. require_once($CFG->dirroot.'/course/lib.php');
  55. $choices = array();
  56. $choices['0'] = new lang_string('hide');
  57. $choices['1'] = new lang_string('show');
  58. $temp->add(new admin_setting_configselect('moodlecourse/visible', new lang_string('visible'), new lang_string('visible_help'),
  59. 1, $choices));
  60. // Course format.
  61. $temp->add(new admin_setting_heading('courseformathdr', new lang_string('type_format', 'plugin'), ''));
  62. $courseformats = get_sorted_course_formats(true);
  63. $formcourseformats = array();
  64. foreach ($courseformats as $courseformat) {
  65. $formcourseformats[$courseformat] = new lang_string('pluginname', "format_$courseformat");
  66. }
  67. $temp->add(new admin_setting_configselect('moodlecourse/format', new lang_string('format'), new lang_string('coursehelpformat'),
  68. 'topics', $formcourseformats));
  69. $temp->add(new admin_setting_configtext('moodlecourse/maxsections', new lang_string('maxnumberweeks'),
  70. new lang_string('maxnumberweeks_desc'), 52));
  71. $temp->add(new admin_settings_num_course_sections('moodlecourse/numsections', new lang_string('numberweeks'),
  72. new lang_string('coursehelpnumberweeks'), 4));
  73. $choices = array();
  74. $choices['0'] = new lang_string('hiddensectionscollapsed');
  75. $choices['1'] = new lang_string('hiddensectionsinvisible');
  76. $temp->add(new admin_setting_configselect('moodlecourse/hiddensections', new lang_string('hiddensections'),
  77. new lang_string('coursehelphiddensections'), 0, $choices));
  78. $choices = array();
  79. $choices[COURSE_DISPLAY_SINGLEPAGE] = new lang_string('coursedisplay_single');
  80. $choices[COURSE_DISPLAY_MULTIPAGE] = new lang_string('coursedisplay_multi');
  81. $temp->add(new admin_setting_configselect('moodlecourse/coursedisplay', new lang_string('coursedisplay'),
  82. new lang_string('coursedisplay_help'), COURSE_DISPLAY_SINGLEPAGE, $choices));
  83. // Appearance.
  84. $temp->add(new admin_setting_heading('appearancehdr', new lang_string('appearance'), ''));
  85. $languages = array();
  86. $languages[''] = new lang_string('forceno');
  87. $languages += get_string_manager()->get_list_of_translations();
  88. $temp->add(new admin_setting_configselect('moodlecourse/lang', new lang_string('forcelanguage'), '', key($languages),
  89. $languages));
  90. $options = range(0, 10);
  91. $temp->add(new admin_setting_configselect('moodlecourse/newsitems', new lang_string('newsitemsnumber'),
  92. new lang_string('coursehelpnewsitemsnumber'), 5, $options));
  93. $temp->add(new admin_setting_configselect('moodlecourse/showgrades', new lang_string('showgrades'),
  94. new lang_string('coursehelpshowgrades'), 1, array(0 => new lang_string('no'), 1 => new lang_string('yes'))));
  95. $temp->add(new admin_setting_configselect('moodlecourse/showreports', new lang_string('showreports'), '', 0,
  96. array(0 => new lang_string('no'), 1 => new lang_string('yes'))));
  97. // Files and uploads.
  98. $temp->add(new admin_setting_heading('filesanduploadshdr', new lang_string('filesanduploads'), ''));
  99. if (!empty($CFG->legacyfilesinnewcourses)) {
  100. $choices = array('0'=>new lang_string('no'), '2'=>new lang_string('yes'));
  101. $temp->add(new admin_setting_configselect('moodlecourse/legacyfiles', new lang_string('courselegacyfiles'),
  102. new lang_string('courselegacyfiles_help'), key($choices), $choices));
  103. }
  104. $currentmaxbytes = get_config('moodlecourse', 'maxbytes');
  105. if (isset($CFG->maxbytes)) {
  106. $choices = get_max_upload_sizes($CFG->maxbytes, 0, 0, $currentmaxbytes);
  107. } else {
  108. $choices = get_max_upload_sizes(0, 0, 0, $currentmaxbytes);
  109. }
  110. $temp->add(new admin_setting_configselect('moodlecourse/maxbytes', new lang_string('maximumupload'),
  111. new lang_string('coursehelpmaximumupload'), key($choices), $choices));
  112. // Completion tracking.
  113. $temp->add(new admin_setting_heading('progress', new lang_string('completion','completion'), ''));
  114. $temp->add(new admin_setting_configselect('moodlecourse/enablecompletion', new lang_string('completion', 'completion'),
  115. new lang_string('enablecompletion_help', 'completion'), 0, array(0 => new lang_string('no'), 1 => new lang_string('yes'))));
  116. // Groups.
  117. $temp->add(new admin_setting_heading('groups', new lang_string('groups', 'group'), ''));
  118. $choices = array();
  119. $choices[NOGROUPS] = new lang_string('groupsnone', 'group');
  120. $choices[SEPARATEGROUPS] = new lang_string('groupsseparate', 'group');
  121. $choices[VISIBLEGROUPS] = new lang_string('groupsvisible', 'group');
  122. $temp->add(new admin_setting_configselect('moodlecourse/groupmode', new lang_string('groupmode'), '', key($choices),$choices));
  123. $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'))));
  124. $ADMIN->add('courses', $temp);
  125. // "courserequests" settingpage.
  126. $temp = new admin_settingpage('courserequest', new lang_string('courserequest'));
  127. $temp->add(new admin_setting_configcheckbox('enablecourserequests', new lang_string('enablecourserequests', 'admin'), new lang_string('configenablecourserequests', 'admin'), 0));
  128. $temp->add(new admin_settings_coursecat_select('defaultrequestcategory', new lang_string('defaultrequestcategory', 'admin'), new lang_string('configdefaultrequestcategory', 'admin'), 1));
  129. $temp->add(new admin_setting_configcheckbox('requestcategoryselection', new lang_string('requestcategoryselection', 'admin'), new lang_string('configrequestcategoryselection', 'admin'), 0));
  130. $temp->add(new admin_setting_users_with_capability('courserequestnotify', new lang_string('courserequestnotify', 'admin'), new lang_string('configcourserequestnotify2', 'admin'), array(), 'moodle/site:approvecourse'));
  131. $ADMIN->add('courses', $temp);
  132. // Pending course requests.
  133. if (!empty($CFG->enablecourserequests)) {
  134. $ADMIN->add('courses', new admin_externalpage('coursespending', new lang_string('pendingrequests'),
  135. $CFG->wwwroot . '/course/pending.php', array('moodle/site:approvecourse')));
  136. }
  137. // Add a category for backups.
  138. $ADMIN->add('courses', new admin_category('backups', new lang_string('backups','admin')));
  139. // Create a page for general backups configuration and defaults.
  140. $temp = new admin_settingpage('backupgeneralsettings', new lang_string('generalbackdefaults', 'backup'), 'moodle/backup:backupcourse');
  141. // General configuration section.
  142. $temp->add(new admin_setting_configselect('backup/loglifetime', new lang_string('loglifetime', 'backup'), new lang_string('configloglifetime', 'backup'), 30, array(
  143. 1 => new lang_string('numdays', '', 1),
  144. 2 => new lang_string('numdays', '', 2),
  145. 3 => new lang_string('numdays', '', 3),
  146. 5 => new lang_string('numdays', '', 5),
  147. 7 => new lang_string('numdays', '', 7),
  148. 10 => new lang_string('numdays', '', 10),
  149. 14 => new lang_string('numdays', '', 14),
  150. 20 => new lang_string('numdays', '', 20),
  151. 30 => new lang_string('numdays', '', 30),
  152. 60 => new lang_string('numdays', '', 60),
  153. 90 => new lang_string('numdays', '', 90),
  154. 120 => new lang_string('numdays', '', 120),
  155. 180 => new lang_string('numdays', '', 180),
  156. 365 => new lang_string('numdays', '', 365)
  157. )));
  158. // General defaults section.
  159. $temp->add(new admin_setting_heading('generalsettings', new lang_string('generalsettings', 'backup'), ''));
  160. $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)));
  161. $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)));
  162. $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)));
  163. $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)));
  164. $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)));
  165. $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)));
  166. $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)));
  167. $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)));
  168. $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)));
  169. $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)));
  170. $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)));
  171. $temp->add(new admin_setting_configcheckbox_with_lock('backup/backup_general_questionbank', new lang_string('generalquestionbank','backup'), new lang_string('configgeneralquestionbank','backup'), array('value'=>1, 'locked'=>0)));
  172. $temp->add(new admin_setting_configcheckbox_with_lock('backup/backup_general_groups',
  173. new lang_string('generalgroups', 'backup'), new lang_string('configgeneralgroups', 'backup'),
  174. array('value' => 1, 'locked' => 0)));
  175. $ADMIN->add('backups', $temp);
  176. // Create a page for general import configuration and defaults.
  177. $temp = new admin_settingpage('importgeneralsettings', new lang_string('importgeneralsettings', 'backup'), 'moodle/backup:backupcourse');
  178. $temp->add(new admin_setting_configtext('backup/import_general_maxresults', new lang_string('importgeneralmaxresults', 'backup'), new lang_string('importgeneralmaxresults_desc', 'backup'), 10));
  179. $temp->add(new admin_setting_configcheckbox('backup/import_general_duplicate_admin_allowed',
  180. new lang_string('importgeneralduplicateadminallowed', 'backup'),
  181. new lang_string('importgeneralduplicateadminallowed_desc', 'backup'), 0));
  182. $ADMIN->add('backups', $temp);
  183. // Create a page for automated backups configuration and defaults.
  184. $temp = new admin_settingpage('automated', new lang_string('automatedsetup','backup'), 'moodle/backup:backupcourse');
  185. // Automated configuration section.
  186. $temp->add(new admin_setting_configselect('backup/backup_auto_active', new lang_string('active'), new lang_string('autoactivedescription', 'backup'), 0, array(
  187. 0 => new lang_string('autoactivedisabled', 'backup'),
  188. 1 => new lang_string('autoactiveenabled', 'backup'),
  189. 2 => new lang_string('autoactivemanual', 'backup')
  190. )));
  191. $temp->add(new admin_setting_special_backupdays());
  192. $temp->add(new admin_setting_configtime('backup/backup_auto_hour', 'backup_auto_minute', new lang_string('executeat'),
  193. new lang_string('backupexecuteathelp'), array('h' => 0, 'm' => 0)));
  194. $storageoptions = array(
  195. 0 => new lang_string('storagecourseonly', 'backup'),
  196. 1 => new lang_string('storageexternalonly', 'backup'),
  197. 2 => new lang_string('storagecourseandexternal', 'backup')
  198. );
  199. $temp->add(new admin_setting_configselect('backup/backup_auto_storage', new lang_string('automatedstorage', 'backup'), new lang_string('automatedstoragehelp', 'backup'), 0, $storageoptions));
  200. $temp->add(new admin_setting_special_backup_auto_destination());
  201. $maxkeptoptions = array(
  202. 0 => new lang_string('all'), 1 => '1',
  203. 2 => '2',
  204. 5 => '5',
  205. 10 => '10',
  206. 20 => '20',
  207. 30 => '30',
  208. 40 => '40',
  209. 50 => '50',
  210. 100 => '100',
  211. 200 => '200',
  212. 300 => '300',
  213. 400 => '400',
  214. 500 => '500');
  215. $temp->add(new admin_setting_configselect('backup/backup_auto_max_kept', new lang_string('automatedmaxkept', 'backup'),
  216. new lang_string('automatedmaxkepthelp', 'backup'), 1, $maxkeptoptions));
  217. $automateddeletedaysoptions = array(
  218. 0 => new lang_string('never'),
  219. 1000 => new lang_string('numdays', '', 1000),
  220. 365 => new lang_string('numdays', '', 365),
  221. 180 => new lang_string('numdays', '', 180),
  222. 150 => new lang_string('numdays', '', 150),
  223. 120 => new lang_string('numdays', '', 120),
  224. 90 => new lang_string('numdays', '', 90),
  225. 60 => new lang_string('numdays', '', 60),
  226. 35 => new lang_string('numdays', '', 35),
  227. 10 => new lang_string('numdays', '', 10),
  228. 5 => new lang_string('numdays', '', 5),
  229. 2 => new lang_string('numdays', '', 2)
  230. );
  231. $temp->add(new admin_setting_configselect('backup/backup_auto_delete_days', new lang_string('automateddeletedays', 'backup'),
  232. '', 0, $automateddeletedaysoptions));
  233. $minkeptoptions = array(
  234. 0 => new lang_string('none'),
  235. 1 => '1',
  236. 2 => '2',
  237. 5 => '5',
  238. 10 => '10',
  239. 20 => '20',
  240. 30 => '30',
  241. 40 => '40',
  242. 50 => '50',
  243. 100 => '100',
  244. 200 => '200',
  245. 300 => '300',
  246. 400 => '400'
  247. );
  248. $temp->add(new admin_setting_configselect('backup/backup_auto_min_kept', new lang_string('automatedminkept', 'backup'),
  249. new lang_string('automatedminkepthelp', 'backup'), 0, $minkeptoptions));
  250. $temp->add(new admin_setting_configcheckbox('backup/backup_shortname', new lang_string('backup_shortname', 'admin'), new lang_string('backup_shortnamehelp', 'admin'), 0));
  251. $temp->add(new admin_setting_configcheckbox('backup/backup_auto_skip_hidden', new lang_string('skiphidden', 'backup'), new lang_string('skiphiddenhelp', 'backup'), 1));
  252. $temp->add(new admin_setting_configselect('backup/backup_auto_skip_modif_days', new lang_string('skipmodifdays', 'backup'), new lang_string('skipmodifdayshelp', 'backup'), 30, array(
  253. 0 => new lang_string('never'),
  254. 1 => new lang_string('numdays', '', 1),
  255. 2 => new lang_string('numdays', '', 2),
  256. 3 => new lang_string('numdays', '', 3),
  257. 5 => new lang_string('numdays', '', 5),
  258. 7 => new lang_string('numdays', '', 7),
  259. 10 => new lang_string('numdays', '', 10),
  260. 14 => new lang_string('numdays', '', 14),
  261. 20 => new lang_string('numdays', '', 20),
  262. 30 => new lang_string('numdays', '', 30),
  263. 60 => new lang_string('numdays', '', 60),
  264. 90 => new lang_string('numdays', '', 90),
  265. 120 => new lang_string('numdays', '', 120),
  266. 180 => new lang_string('numdays', '', 180),
  267. 365 => new lang_string('numdays', '', 365)
  268. )));
  269. $temp->add(new admin_setting_configcheckbox('backup/backup_auto_skip_modif_prev', new lang_string('skipmodifprev', 'backup'), new lang_string('skipmodifprevhelp', 'backup'), 0));
  270. // Automated defaults section.
  271. $temp->add(new admin_setting_heading('automatedsettings', new lang_string('automatedsettings','backup'), ''));
  272. $temp->add(new admin_setting_configcheckbox('backup/backup_auto_users', new lang_string('generalusers', 'backup'), new lang_string('configgeneralusers', 'backup'), 1));
  273. $temp->add(new admin_setting_configcheckbox('backup/backup_auto_role_assignments', new lang_string('generalroleassignments','backup'), new lang_string('configgeneralroleassignments','backup'), 1));
  274. $temp->add(new admin_setting_configcheckbox('backup/backup_auto_activities', new lang_string('generalactivities','backup'), new lang_string('configgeneralactivities','backup'), 1));
  275. $temp->add(new admin_setting_configcheckbox('backup/backup_auto_blocks', new lang_string('generalblocks','backup'), new lang_string('configgeneralblocks','backup'), 1));
  276. $temp->add(new admin_setting_configcheckbox('backup/backup_auto_filters', new lang_string('generalfilters','backup'), new lang_string('configgeneralfilters','backup'), 1));
  277. $temp->add(new admin_setting_configcheckbox('backup/backup_auto_comments', new lang_string('generalcomments','backup'), new lang_string('configgeneralcomments','backup'), 1));
  278. $temp->add(new admin_setting_configcheckbox('backup/backup_auto_badges', new lang_string('generalbadges','backup'), new lang_string('configgeneralbadges','backup'), 1));
  279. $temp->add(new admin_setting_configcheckbox('backup/backup_auto_userscompletion', new lang_string('generaluserscompletion','backup'), new lang_string('configgeneraluserscompletion','backup'), 1));
  280. $temp->add(new admin_setting_configcheckbox('backup/backup_auto_logs', new lang_string('generallogs', 'backup'), new lang_string('configgenerallogs', 'backup'), 0));
  281. $temp->add(new admin_setting_configcheckbox('backup/backup_auto_histories', new lang_string('generalhistories','backup'), new lang_string('configgeneralhistories','backup'), 0));
  282. $temp->add(new admin_setting_configcheckbox('backup/backup_auto_questionbank', new lang_string('generalquestionbank','backup'), new lang_string('configgeneralquestionbank','backup'), 1));
  283. $temp->add(new admin_setting_configcheckbox('backup/backup_auto_groups', new lang_string('generalgroups', 'backup'),
  284. new lang_string('configgeneralgroups', 'backup'), 1));
  285. //$temp->add(new admin_setting_configcheckbox('backup/backup_auto_messages', new lang_string('messages', 'message'), new lang_string('backupmessageshelp','message'), 0));
  286. //$temp->add(new admin_setting_configcheckbox('backup/backup_auto_blogs', new lang_string('blogs', 'blog'), new lang_string('backupblogshelp','blog'), 0));
  287. $ADMIN->add('backups', $temp);
  288. }