infocours.php 31 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Code to display the course settings form (for the course admin)
  5. * and activate the changes.
  6. *
  7. * See ./inc/conf/course_info.conf.php for settings
  8. *
  9. * @todo Take those config settings into account in this script
  10. *
  11. * @author Patrick Cool <patrick.cool@UGent.be>
  12. * @author Roan Embrechts, refactoring and improved course visibility|subscribe|unsubscribe options
  13. * @author Julio Montoya <gugli100@gmail.com> Jquery support + lots of fixes
  14. *
  15. * @package chamilo.course_info
  16. */
  17. require_once __DIR__.'/../inc/global.inc.php';
  18. $current_course_tool = TOOL_COURSE_SETTING;
  19. $this_section = SECTION_COURSES;
  20. $nameTools = get_lang('ModifInfo');
  21. api_protect_course_script(true);
  22. api_block_anonymous_users();
  23. $_course = api_get_course_info();
  24. /* Constants and variables */
  25. define('MODULE_HELP_NAME', 'Settings');
  26. $currentCourseRepository = $_course['path'];
  27. $is_allowedToEdit = api_is_course_admin() || api_is_platform_admin();
  28. $course_code = api_get_course_id();
  29. $courseId = api_get_course_int_id();
  30. function is_settings_editable()
  31. {
  32. return isset($GLOBALS['course_info_is_editable']) && $GLOBALS['course_info_is_editable'];
  33. }
  34. /* MAIN CODE */
  35. if (!$is_allowedToEdit) {
  36. api_not_allowed(true);
  37. }
  38. $htmlHeadXtra[] = api_get_css_asset('cropper/dist/cropper.min.css');
  39. $htmlHeadXtra[] = api_get_asset('cropper/dist/cropper.min.js');
  40. $show_delete_watermark_text_message = false;
  41. if (api_get_setting('pdf_export_watermark_by_course') == 'true') {
  42. if (isset($_GET['delete_watermark'])) {
  43. PDF::delete_watermark($course_code);
  44. $show_delete_watermark_text_message = true;
  45. }
  46. }
  47. $categories = CourseCategory::getCategoriesCanBeAddedInCourse($_course['categoryCode']);
  48. // Build the form
  49. $form = new FormValidator(
  50. 'update_course',
  51. 'post',
  52. api_get_self().'?'.api_get_cidreq()
  53. );
  54. $form->addHtml('<div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">');
  55. // COURSE SETTINGS
  56. $form->addHtml('<div class="panel panel-default">');
  57. $form->addHtml('
  58. <div class="panel-heading" role="tab" id="heading-course-settings">
  59. <h4 class="panel-title">
  60. <a role="button" data-toggle="collapse" data-parent="#accordion" href="#collapse-course-settings"
  61. aria-expanded="true" aria-controls="collapse-course-settings">
  62. ');
  63. $form->addHtml(
  64. Display::return_icon('settings.png', get_lang('CourseSettings')).' '.get_lang('CourseSettings')
  65. );
  66. $form->addHtml('
  67. </a>
  68. </h4>
  69. </div>
  70. ');
  71. $form->addHtml('
  72. <div id="collapse-course-settings" class="panel-collapse collapse in" role="tabpanel"
  73. aria-labelledby="heading-course-settings">
  74. <div class="panel-body">
  75. ');
  76. $image = '';
  77. // Display course picture
  78. $course_path = api_get_path(SYS_COURSE_PATH).$currentCourseRepository; // course path
  79. if (file_exists($course_path.'/course-pic85x85.png')) {
  80. $course_web_path = api_get_path(WEB_COURSE_PATH).$currentCourseRepository; // course web path
  81. $course_medium_image = $course_web_path.'/course-pic85x85.png?'.rand(1, 1000); // redimensioned image 85x85
  82. $image = '<div class="row"><label class="col-md-2 control-label">'.get_lang('Image').'</label>
  83. <div class="col-md-8"><img src="'.$course_medium_image.'" /></div></div>';
  84. }
  85. $form->addHtml($image);
  86. $form->addText('title', get_lang('Title'), true);
  87. $form->applyFilter('title', 'html_filter');
  88. $form->applyFilter('title', 'trim');
  89. $form->addElement(
  90. 'select',
  91. 'category_code',
  92. get_lang('Fac'),
  93. $categories,
  94. ['style' => 'width:350px', 'id' => 'category_code']
  95. );
  96. $form->addSelectLanguage(
  97. 'course_language',
  98. [get_lang('Ln'), get_lang('TipLang')]
  99. );
  100. $group = [
  101. $form->createElement('radio', 'show_course_in_user_language', null, get_lang('Yes'), 1),
  102. $form->createElement('radio', 'show_course_in_user_language', null, get_lang('No'), 2),
  103. ];
  104. $form->addGroup($group, '', [get_lang('ShowCourseInUserLanguage')]);
  105. $form->addText('department_name', get_lang('Department'), false);
  106. $form->applyFilter('department_name', 'html_filter');
  107. $form->applyFilter('department_name', 'trim');
  108. $form->addText('department_url', get_lang('DepartmentUrl'), false);
  109. $form->applyFilter('department_url', 'html_filter');
  110. // Extra fields
  111. $extra_field = new ExtraField('course');
  112. $extraFieldAdminPermissions = false;
  113. $showOnlyTheseFields = ['tags', 'video_url', 'course_hours_duration', 'max_subscribed_students'];
  114. $extra = $extra_field->addElements(
  115. $form,
  116. $courseId,
  117. [],
  118. false,
  119. false,
  120. $showOnlyTheseFields
  121. );
  122. //Tags ExtraField
  123. $htmlHeadXtra[] = '
  124. <script>
  125. $(function() {
  126. '.$extra['jquery_ready_content'].'
  127. });
  128. </script>';
  129. // Picture
  130. $form->addFile(
  131. 'picture',
  132. get_lang('AddPicture'),
  133. ['id' => 'picture', 'class' => 'picture-form', 'crop_image' => true]
  134. );
  135. $allowed_picture_types = api_get_supported_image_extensions(false);
  136. $form->addRule(
  137. 'picture',
  138. get_lang('OnlyImagesAllowed').' ('.implode(',', $allowed_picture_types).')',
  139. 'filetype',
  140. $allowed_picture_types
  141. );
  142. $form->addElement('checkbox', 'delete_picture', null, get_lang('DeletePicture'));
  143. if (api_get_setting('pdf_export_watermark_by_course') == 'true') {
  144. $url = PDF::get_watermark($course_code);
  145. $form->addText('pdf_export_watermark_text', get_lang('PDFExportWatermarkTextTitle'), false, ['size' => '60']);
  146. $form->addElement('file', 'pdf_export_watermark_path', get_lang('AddWaterMark'));
  147. if ($url != false) {
  148. $delete_url = '<a href="?delete_watermark">'.Display::return_icon('delete.png', get_lang('DelImage')).'</a>';
  149. $form->addElement(
  150. 'html',
  151. '<div class="row"><div class="formw"><a href="'.$url.'">'.$url.' '.$delete_url.'</a></div></div>'
  152. );
  153. }
  154. $form->addRule(
  155. 'pdf_export_watermark_path',
  156. get_lang('OnlyImagesAllowed').' ('.implode(',', $allowed_picture_types).')',
  157. 'filetype',
  158. $allowed_picture_types
  159. );
  160. }
  161. if (api_get_setting('allow_course_theme') == 'true') {
  162. $group = [];
  163. $group[] = $form->createElement(
  164. 'SelectTheme',
  165. 'course_theme',
  166. null,
  167. ['id' => 'course_theme_id']
  168. );
  169. $form->addGroup($group, '', [get_lang('Stylesheets')]);
  170. }
  171. $form->addElement('label', get_lang('DocumentQuota'), format_file_size(DocumentManager::get_course_quota()));
  172. $scoreModels = ExerciseLib::getScoreModels();
  173. if (!empty($scoreModels)) {
  174. $options = ['' => get_lang('None')];
  175. foreach ($scoreModels['models'] as $item) {
  176. $options[$item['id']] = get_lang($item['name']);
  177. }
  178. $form->addSelect('score_model_id', get_lang('ScoreModel'), $options);
  179. }
  180. $form->addButtonSave(get_lang('SaveSettings'), 'submit_save');
  181. $form->addHtml('
  182. </div>
  183. </div>
  184. ');
  185. $form->addHtml('</div>');
  186. // COURSE ACCESS
  187. $group = [];
  188. $group[] = $form->createElement(
  189. 'radio',
  190. 'visibility',
  191. get_lang('CourseAccess'),
  192. get_lang('OpenToTheWorld'),
  193. COURSE_VISIBILITY_OPEN_WORLD
  194. );
  195. $group[] = $form->createElement(
  196. 'radio',
  197. 'visibility',
  198. null,
  199. get_lang('OpenToThePlatform'),
  200. COURSE_VISIBILITY_OPEN_PLATFORM
  201. );
  202. $group[] = $form->createElement('radio', 'visibility', null, get_lang('Private'), COURSE_VISIBILITY_REGISTERED);
  203. $group[] = $form->createElement(
  204. 'radio',
  205. 'visibility',
  206. null,
  207. get_lang('CourseVisibilityClosed'),
  208. COURSE_VISIBILITY_CLOSED
  209. );
  210. // The "hidden" visibility is only available to portal admins
  211. if (api_is_platform_admin()) {
  212. $group[] = $form->createElement(
  213. 'radio',
  214. 'visibility',
  215. null,
  216. get_lang('CourseVisibilityHidden'),
  217. COURSE_VISIBILITY_HIDDEN
  218. );
  219. }
  220. $groupElement = $form->addGroup(
  221. $group,
  222. '',
  223. [get_lang('CourseAccess'), get_lang('CourseAccessConfigTip')],
  224. null,
  225. null,
  226. true
  227. );
  228. $url = api_get_path(WEB_CODE_PATH)."auth/inscription.php?c=$course_code&e=1";
  229. $url = Display::url($url, $url);
  230. $label = $form->addLabel(get_lang('DirectLink'), sprintf(get_lang('CourseSettingsRegisterDirectLink'), $url), true);
  231. $group2 = [];
  232. $group2[] = $form->createElement('radio', 'subscribe', get_lang('Subscription'), get_lang('Allowed'), 1);
  233. $group2[] = $form->createElement('radio', 'subscribe', null, get_lang('Denied'), 0);
  234. $myButton = $form->addButtonSave(get_lang('SaveSettings'), 'submit_save', true);
  235. $group3[] = $form->createElement(
  236. 'radio',
  237. 'unsubscribe',
  238. get_lang('Unsubscription'),
  239. get_lang('AllowedToUnsubscribe'),
  240. 1
  241. );
  242. $group3[] = $form->createElement('radio', 'unsubscribe', null, get_lang('NotAllowedToUnsubscribe'), 0);
  243. $text = $form->createElement(
  244. 'text',
  245. 'course_registration_password',
  246. get_lang('CourseRegistrationPassword'),
  247. false,
  248. ['size' => '60']
  249. );
  250. $checkBoxActiveLegal = $form->createElement(
  251. 'checkbox',
  252. 'activate_legal',
  253. [null, get_lang('ShowALegalNoticeWhenEnteringTheCourse')],
  254. get_lang('ActivateLegal')
  255. );
  256. $textAreaLegal = $form->createElement('textarea', 'legal', get_lang('CourseLegalAgreement'), ['rows' => 8]);
  257. $elements = [
  258. $groupElement,
  259. $label,
  260. get_lang('Subscription') => $group2,
  261. get_lang('Unsubscription') => $group3,
  262. $text,
  263. $checkBoxActiveLegal,
  264. $textAreaLegal,
  265. $myButton,
  266. ];
  267. $form->addPanelOption(
  268. 'course-access',
  269. Display::return_icon('course.png', get_lang('CourseAccess')).' '.get_lang('CourseAccess'),
  270. $elements
  271. );
  272. // Documents
  273. $globalGroup = [];
  274. if (api_get_setting('documents_default_visibility_defined_in_course') == 'true') {
  275. $group = [
  276. $form->createElement('radio', 'documents_default_visibility', null, get_lang('Visible'), 'visible'),
  277. $form->createElement('radio', 'documents_default_visibility', null, get_lang('Invisible'), 'invisible'),
  278. ];
  279. $globalGroup[get_lang('DocumentsDefaultVisibility')] = $group;
  280. }
  281. $group = [
  282. $form->createElement('radio', 'show_system_folders', null, get_lang('Yes'), 1),
  283. $form->createElement('radio', 'show_system_folders', null, get_lang('No'), 2),
  284. ];
  285. $globalGroup[get_lang('ShowSystemFolders')] = $group;
  286. $myButton = $form->addButtonSave(get_lang('SaveSettings'), 'submit_save', true);
  287. $group = [];
  288. $group[] = $form->createElement(
  289. 'radio',
  290. 'enable_document_auto_launch',
  291. get_lang('DocumentAutoLaunch'),
  292. get_lang('RedirectToTheDocumentList'),
  293. 1
  294. );
  295. $group[] = $form->createElement('radio', 'enable_document_auto_launch', null, get_lang('Deactivate'), 0);
  296. $globalGroup[get_lang('DocumentAutoLaunch')] = $group;
  297. $globalGroup[] = $myButton;
  298. $form->addPanelOption(
  299. 'documents',
  300. Display::return_icon('folder.png', get_lang('Documents')).' '.get_lang('Documents'),
  301. $globalGroup
  302. );
  303. // EMAIL NOTIFICATIONS
  304. $form->addHtml('<div class="panel panel-default">');
  305. $form->addHtml('
  306. <div class="panel-heading" role="tab" id="heading-email-notifications">
  307. <h4 class="panel-title">
  308. <a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion"
  309. href="#collapse-email-notifications" aria-expanded="false" aria-controls="collapse-email-notifications">
  310. ');
  311. $form->addHtml(
  312. Display::return_icon('mail.png', get_lang('EmailNotifications')).' '.get_lang('EmailNotifications')
  313. );
  314. $form->addHtml('
  315. </a>
  316. </h4>
  317. </div>
  318. ');
  319. $form->addHtml('
  320. <div id="collapse-email-notifications" class="panel-collapse collapse" role="tabpanel"
  321. aria-labelledby="heading-email-notifications">
  322. <div class="panel-body">
  323. ');
  324. $group = [];
  325. $group[] = $form->createElement(
  326. 'radio',
  327. 'email_alert_to_teacher_on_new_user_in_course',
  328. get_lang('NewUserEmailAlert'),
  329. get_lang('NewUserEmailAlertEnable'),
  330. 1
  331. );
  332. $group[] = $form->createElement(
  333. 'radio',
  334. 'email_alert_to_teacher_on_new_user_in_course',
  335. null,
  336. get_lang('NewUserEmailAlertToTeacharAndTutor'),
  337. 2
  338. );
  339. $group[] = $form->createElement(
  340. 'radio',
  341. 'email_alert_to_teacher_on_new_user_in_course',
  342. null,
  343. get_lang('NewUserEmailAlertDisable'),
  344. 0
  345. );
  346. $form->addGroup($group, '', [get_lang("NewUserEmailAlert")]);
  347. $group = [];
  348. $group[] = $form->createElement(
  349. 'radio',
  350. 'email_alert_students_on_new_homework',
  351. get_lang('NewHomeworkEmailAlert'),
  352. get_lang('NewHomeworkEmailAlertEnable'),
  353. 1
  354. );
  355. $group[] = $form->createElement(
  356. 'radio',
  357. 'email_alert_students_on_new_homework',
  358. null,
  359. get_lang('NewHomeworkEmailAlertToHrmEnable'),
  360. 2
  361. );
  362. $group[] = $form->createElement(
  363. 'radio',
  364. 'email_alert_students_on_new_homework',
  365. null,
  366. get_lang('NewHomeworkEmailAlertDisable'),
  367. 0
  368. );
  369. $form->addGroup($group, '', [get_lang("NewHomeworkEmailAlert")]);
  370. $group = [];
  371. $group[] = $form->createElement(
  372. 'radio',
  373. 'email_alert_manager_on_new_doc',
  374. get_lang('WorkEmailAlert'),
  375. get_lang('WorkEmailAlertActivate'),
  376. 1
  377. );
  378. $group[] = $form->createElement(
  379. 'radio',
  380. 'email_alert_manager_on_new_doc',
  381. null,
  382. get_lang('WorkEmailAlertActivateOnlyForTeachers'),
  383. 3
  384. );
  385. $group[] = $form->createElement(
  386. 'radio',
  387. 'email_alert_manager_on_new_doc',
  388. null,
  389. get_lang('WorkEmailAlertActivateOnlyForStudents'),
  390. 2
  391. );
  392. $group[] = $form->createElement(
  393. 'radio',
  394. 'email_alert_manager_on_new_doc',
  395. null,
  396. get_lang('WorkEmailAlertDeactivate'),
  397. 0
  398. );
  399. $form->addGroup($group, '', [get_lang("WorkEmailAlert")]);
  400. $group = [];
  401. $group[] = $form->createElement(
  402. 'radio',
  403. 'email_alert_on_new_doc_dropbox',
  404. get_lang('DropboxEmailAlert'),
  405. get_lang('DropboxEmailAlertActivate'),
  406. 1
  407. );
  408. $group[] = $form->createElement(
  409. 'radio',
  410. 'email_alert_on_new_doc_dropbox',
  411. null,
  412. get_lang('DropboxEmailAlertDeactivate'),
  413. 0
  414. );
  415. $form->addGroup($group, '', [get_lang("DropboxEmailAlert")]);
  416. // Exercises notifications
  417. $emailAlerts = ExerciseLib::getNotificationSettings();
  418. $group = [];
  419. foreach ($emailAlerts as $itemId => $label) {
  420. $group[] = $form->createElement(
  421. 'checkbox',
  422. 'email_alert_manager_on_new_quiz[]',
  423. null,
  424. $label,
  425. ['value' => $itemId]
  426. );
  427. }
  428. $form->addGroup($group, '', [get_lang('Exercises')]);
  429. $group = [];
  430. $group[] = $form->createElement(
  431. 'radio',
  432. 'email_to_teachers_on_new_work_feedback',
  433. get_lang('EmailToTeachersWhenNewWorkFeedback'),
  434. get_lang('Yes'),
  435. 1
  436. );
  437. $group[] = $form->createElement(
  438. 'radio',
  439. 'email_to_teachers_on_new_work_feedback',
  440. null,
  441. get_lang('No'),
  442. 2
  443. );
  444. $form->addGroup($group, '', [get_lang("EmailToTeachersWhenNewWorkFeedback")]);
  445. $form->addButtonSave(get_lang('SaveSettings'), 'submit_save');
  446. $form->addHtml('
  447. </div>
  448. </div>
  449. ');
  450. $form->addHtml('</div>');
  451. // USER RIGHTS
  452. $group = [];
  453. $group[] = $form->createElement(
  454. 'radio',
  455. 'allow_user_edit_agenda',
  456. get_lang('AllowUserEditAgenda'),
  457. get_lang('AllowUserEditAgendaActivate'),
  458. 1
  459. );
  460. $group[] = $form->createElement('radio', 'allow_user_edit_agenda', null, get_lang('AllowUserEditAgendaDeactivate'), 0);
  461. $group2 = [];
  462. $group2[] = $form->createElement(
  463. 'radio',
  464. 'allow_user_edit_announcement',
  465. get_lang('AllowUserEditAnnouncement'),
  466. get_lang('AllowUserEditAnnouncementActivate'),
  467. 1
  468. );
  469. $group2[] = $form->createElement(
  470. 'radio',
  471. 'allow_user_edit_announcement',
  472. null,
  473. get_lang('AllowUserEditAnnouncementDeactivate'),
  474. 0
  475. );
  476. $group3 = [];
  477. $group3[] = $form->createElement(
  478. 'radio',
  479. 'allow_user_image_forum',
  480. get_lang('AllowUserImageForum'),
  481. get_lang('AllowUserImageForumActivate'),
  482. 1
  483. );
  484. $group3[] = $form->createElement('radio', 'allow_user_image_forum', null, get_lang('AllowUserImageForumDeactivate'), 0);
  485. $group4 = [];
  486. $group4[] = $form->createElement(
  487. 'radio',
  488. 'allow_user_view_user_list',
  489. get_lang('AllowUserViewUserList'),
  490. get_lang('AllowUserViewUserListActivate'),
  491. 1
  492. );
  493. $group4[] = $form->createElement(
  494. 'radio',
  495. 'allow_user_view_user_list',
  496. null,
  497. get_lang('AllowUserViewUserListDeactivate'),
  498. 0
  499. );
  500. $myButton = $form->addButtonSave(get_lang('SaveSettings'), 'submit_save', true);
  501. $globalGroup = [
  502. get_lang('AllowUserEditAgenda') => $group,
  503. get_lang('AllowUserEditAnnouncement') => $group2,
  504. get_lang('AllowUserImageForum') => $group3,
  505. get_lang('AllowUserViewUserList') => $group4,
  506. '' => $myButton,
  507. ];
  508. $form->addPanelOption(
  509. 'users',
  510. Display::return_icon('user.png', get_lang('UserRights')).' '.get_lang('UserRights'),
  511. $globalGroup
  512. );
  513. // CHAT SETTINGS
  514. $group = [];
  515. $group[] = $form->createElement(
  516. 'radio',
  517. 'allow_open_chat_window',
  518. get_lang('AllowOpenchatWindow'),
  519. get_lang('AllowOpenChatWindowActivate'),
  520. 1
  521. );
  522. $group[] = $form->createElement('radio', 'allow_open_chat_window', null, get_lang('AllowOpenChatWindowDeactivate'), 0);
  523. $myButton = $form->addButtonSave(get_lang('SaveSettings'), 'submit_save', true);
  524. $globalGroup = [
  525. get_lang('AllowOpenchatWindow') => $group,
  526. '' => $myButton,
  527. ];
  528. $form->addPanelOption(
  529. 'chat',
  530. Display::return_icon('chat.png', get_lang('ConfigChat'), '', ICON_SIZE_SMALL).' '.get_lang('ConfigChat'),
  531. $globalGroup
  532. );
  533. // LEARNING PATH
  534. $form->addHtml('<div class="panel panel-default">');
  535. $form->addHtml('
  536. <div class="panel-heading" role="tab" id="heading-learning-path">
  537. <h4 class="panel-title">
  538. <a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion"
  539. href="#collapse-learning-path" aria-expanded="false" aria-controls="collapse-learning-path">
  540. ');
  541. $form->addHtml(
  542. Display::return_icon('scorms.png', get_lang('ConfigLearnpath')).' '.get_lang('ConfigLearnpath')
  543. );
  544. $form->addHtml('
  545. </a>
  546. </h4>
  547. </div>
  548. ');
  549. $form->addHtml('
  550. <div id="collapse-learning-path" class="panel-collapse collapse" role="tabpanel"
  551. aria-labelledby="heading-learning-path">
  552. <div class="panel-body">
  553. ');
  554. // Auto launch LP
  555. $group = [];
  556. $group[] = $form->createElement(
  557. 'radio',
  558. 'enable_lp_auto_launch',
  559. get_lang('LPAutoLaunch'),
  560. get_lang('RedirectToALearningPath'),
  561. 1
  562. );
  563. $group[] = $form->createElement(
  564. 'radio',
  565. 'enable_lp_auto_launch',
  566. get_lang('LPAutoLaunch'),
  567. get_lang('RedirectToTheLearningPathList'),
  568. 2
  569. );
  570. $group[] = $form->createElement('radio', 'enable_lp_auto_launch', null, get_lang('Deactivate'), 0);
  571. $form->addGroup($group, '', [get_lang('LPAutoLaunch')]);
  572. if (api_get_setting('allow_course_theme') == 'true') {
  573. // Allow theme into Learning path
  574. $group = [];
  575. $group[] = $form->createElement(
  576. 'radio',
  577. 'allow_learning_path_theme',
  578. get_lang('AllowLearningPathTheme'),
  579. get_lang('AllowLearningPathThemeAllow'),
  580. 1
  581. );
  582. $group[] = $form->createElement(
  583. 'radio',
  584. 'allow_learning_path_theme',
  585. null,
  586. get_lang('AllowLearningPathThemeDisallow'),
  587. 0
  588. );
  589. $form->addGroup($group, '', [get_lang("AllowLearningPathTheme")]);
  590. }
  591. $allowLPReturnLink = api_get_setting('allow_lp_return_link');
  592. if ($allowLPReturnLink === 'true') {
  593. $group = [
  594. $form->createElement(
  595. 'radio',
  596. 'lp_return_link',
  597. get_lang('LpReturnLink'),
  598. get_lang('RedirectToTheLearningPathList'),
  599. 1
  600. ),
  601. $form->createElement(
  602. 'radio',
  603. 'lp_return_link',
  604. null,
  605. get_lang('RedirectToCourseHome'),
  606. 0
  607. ),
  608. $form->createElement(
  609. 'radio',
  610. 'lp_return_link',
  611. null,
  612. get_lang('MyCourses'),
  613. 2
  614. ),
  615. ];
  616. $form->addGroup($group, '', [get_lang("LpReturnLink")]);
  617. }
  618. $exerciseInvisible = api_get_setting('exercise_invisible_in_session');
  619. $configureExerciseVisibility = api_get_setting('configure_exercise_visibility_in_course');
  620. if ($exerciseInvisible === 'true' &&
  621. $configureExerciseVisibility === 'true'
  622. ) {
  623. $group = [
  624. $form->createElement(
  625. 'radio',
  626. 'exercise_invisible_in_session',
  627. get_lang('ExerciseInvisibleInSession'),
  628. get_lang('Yes'),
  629. 1
  630. ),
  631. $form->createElement(
  632. 'radio',
  633. 'exercise_invisible_in_session',
  634. null,
  635. get_lang('No'),
  636. 0
  637. ),
  638. ];
  639. $form->addGroup($group, '', [get_lang("ExerciseInvisibleInSession")]);
  640. }
  641. if (is_settings_editable()) {
  642. $form->addButtonSave(get_lang('SaveSettings'), 'submit_save');
  643. } else {
  644. // Is it allowed to edit the course settings?
  645. if (!is_settings_editable()) {
  646. $disabled_output = "disabled";
  647. }
  648. $form->freeze();
  649. }
  650. $form->addHtml('
  651. </div>
  652. </div>
  653. ');
  654. $form->addHtml('</div>');
  655. // Exercise
  656. $form->addHtml('<div class="panel panel-default">');
  657. $form->addHtml('
  658. <div class="panel-heading" role="tab" id="heading-exercise">
  659. <h4 class="panel-title">
  660. <a class="collapsed"
  661. role="button" data-toggle="collapse"
  662. data-parent="#accordion"
  663. href="#collapse-exercise" aria-expanded="false" aria-controls="collapse-exercise">
  664. ');
  665. $form->addHtml(
  666. Display::return_icon('quiz.png', get_lang('Exercises')).' '.get_lang('Exercises')
  667. );
  668. $form->addHtml('
  669. </a>
  670. </h4>
  671. </div>
  672. ');
  673. $form->addHtml('
  674. <div id="collapse-exercise" class="panel-collapse collapse" role="tabpanel" aria-labelledby="heading-exercise">
  675. <div class="panel-body">
  676. ');
  677. if (api_get_configuration_value('allow_exercise_auto_launch')) {
  678. // Auto launch exercise
  679. $group = [];
  680. $group[] = $form->createElement(
  681. 'radio',
  682. 'enable_exercise_auto_launch',
  683. get_lang('ExerciseAutoLaunch'),
  684. get_lang('RedirectToExercise'),
  685. 1
  686. );
  687. $group[] = $form->createElement(
  688. 'radio',
  689. 'enable_exercise_auto_launch',
  690. get_lang('ExerciseAutoLaunch'),
  691. get_lang('RedirectToTheExerciseList'),
  692. 2
  693. );
  694. $group[] = $form->createElement('radio', 'enable_exercise_auto_launch', null, get_lang('Deactivate'), 0);
  695. $form->addGroup($group, '', [get_lang('ExerciseAutoLaunch')]);
  696. }
  697. $form->addElement(
  698. 'number',
  699. 'quiz_question_limit_per_day',
  700. [get_lang('QuizQuestionsLimitPerDay'), get_lang('QuizQuestionsLimitPerDayComment')],
  701. ['step' => 1, 'min' => 0]
  702. );
  703. if (is_settings_editable()) {
  704. $form->addButtonSave(get_lang('SaveSettings'), 'submit_save');
  705. } else {
  706. // Is it allowed to edit the course settings?
  707. if (!is_settings_editable()) {
  708. $disabled_output = "disabled";
  709. }
  710. $form->freeze();
  711. }
  712. $form->addHtml('
  713. </div>
  714. </div>
  715. ');
  716. $form->addHtml('</div>');
  717. // THEMATIC ADVANCE SETTINGS
  718. $group = [];
  719. $group[] = $form->createElement(
  720. 'radio',
  721. 'display_info_advance_inside_homecourse',
  722. get_lang('InfoAboutAdvanceInsideHomeCourse'),
  723. get_lang('DisplayAboutLastDoneAdvance'),
  724. 1
  725. );
  726. $group[] = $form->createElement(
  727. 'radio',
  728. 'display_info_advance_inside_homecourse',
  729. null,
  730. get_lang('DisplayAboutNextAdvanceNotDone'),
  731. 2
  732. );
  733. $group[] = $form->createElement(
  734. 'radio',
  735. 'display_info_advance_inside_homecourse',
  736. null,
  737. get_lang('DisplayAboutNextAdvanceNotDoneAndLastDoneAdvance'),
  738. 3
  739. );
  740. $group[] = $form->createElement(
  741. 'radio',
  742. 'display_info_advance_inside_homecourse',
  743. null,
  744. get_lang('DoNotDisplayAnyAdvance'),
  745. 0
  746. );
  747. $myButton = $form->addButtonSave(get_lang('SaveSettings'), 'submit_save', true);
  748. $globalGroup = [
  749. get_lang('InfoAboutAdvanceInsideHomeCourse') => $group,
  750. '' => $myButton,
  751. ];
  752. $form->addPanelOption(
  753. 'thematic',
  754. Display::return_icon(
  755. 'course_progress.png',
  756. get_lang('ThematicAdvanceConfiguration')
  757. )
  758. .' '
  759. .get_lang('ThematicAdvanceConfiguration'),
  760. $globalGroup
  761. );
  762. // Certificate settings
  763. if (api_get_setting('allow_public_certificates') === 'true') {
  764. $group = [];
  765. $group[] = $form->createElement(
  766. 'radio',
  767. 'allow_public_certificates',
  768. get_lang('AllowPublicCertificates'),
  769. get_lang('Yes'),
  770. 1
  771. );
  772. $group[] = $form->createElement('radio', 'allow_public_certificates', null, get_lang('No'), 0);
  773. $myButton = $form->addButtonSave(get_lang('SaveSettings'), 'submit_save', true);
  774. $globalGroup = [
  775. get_lang('AllowPublicCertificates') => $group,
  776. '' => $myButton,
  777. ];
  778. $form->addPanelOption(
  779. 'certificate',
  780. Display::return_icon('certificate.png', get_lang('Certificates')).' '.get_lang('Certificates'),
  781. $globalGroup
  782. );
  783. }
  784. // Forum settings
  785. $group = [
  786. $form->createElement('radio', 'enable_forum_auto_launch', null, get_lang('RedirectToForumList'), 1),
  787. $form->createElement('radio', 'enable_forum_auto_launch', null, get_lang('Disabled'), 2),
  788. ];
  789. $myButton = $form->addButtonSave(get_lang('SaveSettings'), 'submit_save', true);
  790. // Forum settings
  791. $groupNotification = [
  792. $form->createElement('radio', 'hide_forum_notifications', null, get_lang('Yes'), 1),
  793. $form->createElement('radio', 'hide_forum_notifications', null, get_lang('No'), 2),
  794. ];
  795. $addUsers = [
  796. $form->createElement('radio', 'subscribe_users_to_forum_notifications', null, get_lang('Yes'), 1),
  797. $form->createElement('radio', 'subscribe_users_to_forum_notifications', null, get_lang('No'), 2),
  798. ];
  799. $globalGroup = [
  800. get_lang('EnableForumAutoLaunch') => $group,
  801. get_lang('HideForumNotifications') => $groupNotification,
  802. get_lang('SubscribeUsersToAllForumNotifications') => $addUsers,
  803. '' => $myButton,
  804. ];
  805. $form->addPanelOption(
  806. 'forum',
  807. Display::return_icon('forum.png', get_lang('Forum')).' '.get_lang('Forum'),
  808. $globalGroup
  809. );
  810. // Student publication
  811. $group = [
  812. $form->createElement('radio', 'show_score', null, get_lang('NewVisible'), 0),
  813. $form->createElement('radio', 'show_score', null, get_lang('NewUnvisible'), 1),
  814. ];
  815. $group2 = [
  816. $form->createElement('radio', 'student_delete_own_publication', null, get_lang('Yes'), 1),
  817. $form->createElement('radio', 'student_delete_own_publication', null, get_lang('No'), 0),
  818. ];
  819. $myButton = $form->addButtonSave(get_lang('SaveSettings'), 'submit_save', true);
  820. $globalGroup = [
  821. get_lang('DefaultUpload') => $group,
  822. get_lang('StudentAllowedToDeleteOwnPublication') => $group2,
  823. '' => $myButton,
  824. ];
  825. $form->addPanelOption(
  826. 'student-publication',
  827. Display::return_icon('work.png', get_lang('StudentPublications')).' '.get_lang('StudentPublications'),
  828. $globalGroup
  829. );
  830. // Plugin course settings
  831. $appPlugin = new AppPlugin();
  832. $appPlugin->add_course_settings_form($form);
  833. $form->addHtml('</div>');
  834. // Get all the course information
  835. $all_course_information = CourseManager::get_course_information($_course['sysCode']);
  836. // Set the default values of the form
  837. $values = [];
  838. $values['title'] = $_course['name'];
  839. $values['category_code'] = $_course['categoryCode'];
  840. $values['course_language'] = $_course['language'];
  841. $values['department_name'] = $_course['extLink']['name'];
  842. $values['department_url'] = $_course['extLink']['url'];
  843. $values['visibility'] = $_course['visibility'];
  844. $values['subscribe'] = $_course['subscribe'];
  845. $values['unsubscribe'] = $_course['unsubscribe'];
  846. $values['course_registration_password'] = $all_course_information['registration_code'];
  847. $values['legal'] = $all_course_information['legal'];
  848. $values['activate_legal'] = $all_course_information['activate_legal'];
  849. $values['show_score'] = $all_course_information['show_score'];
  850. $courseSettings = CourseManager::getCourseSettingVariables($appPlugin);
  851. foreach ($courseSettings as $setting) {
  852. $result = api_get_course_setting($setting, $_course, true);
  853. if ($result != '-1') {
  854. $values[$setting] = $result;
  855. }
  856. }
  857. // make sure new settings have a clear default value
  858. if (!isset($values['student_delete_own_publication'])) {
  859. $values['student_delete_own_publication'] = 0;
  860. }
  861. $form->setDefaults($values);
  862. // Validate form
  863. if ($form->validate() && is_settings_editable()) {
  864. $updateValues = $form->getSubmitValues();
  865. // update course picture
  866. $picture = $_FILES['picture'];
  867. if (!empty($picture['name'])) {
  868. CourseManager::update_course_picture(
  869. $_course,
  870. $picture['name'],
  871. $picture['tmp_name'],
  872. $updateValues['picture_crop_result']
  873. );
  874. }
  875. $visibility = $updateValues['visibility'];
  876. $deletePicture = isset($updateValues['delete_picture']) ? $updateValues['delete_picture'] : '';
  877. if ($deletePicture) {
  878. CourseManager::deleteCoursePicture($course_code);
  879. }
  880. global $_configuration;
  881. $urlId = api_get_current_access_url_id();
  882. if (isset($_configuration[$urlId]) &&
  883. isset($_configuration[$urlId]['hosting_limit_active_courses']) &&
  884. $_configuration[$urlId]['hosting_limit_active_courses'] > 0
  885. ) {
  886. $courseInfo = api_get_course_info_by_id($courseId);
  887. // Check if
  888. if ($courseInfo['visibility'] == COURSE_VISIBILITY_HIDDEN &&
  889. $visibility != $courseInfo['visibility']
  890. ) {
  891. $num = CourseManager::countActiveCourses($urlId);
  892. if ($num >= $_configuration[$urlId]['hosting_limit_active_courses']) {
  893. api_warn_hosting_contact('hosting_limit_active_courses');
  894. Display::addFlash(
  895. Display::return_message(get_lang('PortalActiveCoursesLimitReached'))
  896. );
  897. $url = api_get_path(WEB_CODE_PATH).'course_info/infocours.php?'.api_get_cidreq();
  898. header("Location: $url");
  899. exit;
  900. }
  901. }
  902. }
  903. $pdf_export_watermark_path = isset($_FILES['pdf_export_watermark_path'])
  904. ? $_FILES['pdf_export_watermark_path']
  905. : null;
  906. if (!empty($pdf_export_watermark_path['name'])) {
  907. PDF::upload_watermark(
  908. $pdf_export_watermark_path['name'],
  909. $pdf_export_watermark_path['tmp_name'],
  910. $course_code
  911. );
  912. unset($updateValues['pdf_export_watermark_path']);
  913. }
  914. $activeLegal = isset($updateValues['activate_legal']) ? $updateValues['activate_legal'] : 0;
  915. $table_course = Database::get_main_table(TABLE_MAIN_COURSE);
  916. $params = [
  917. 'title' => $updateValues['title'],
  918. 'course_language' => $updateValues['course_language'],
  919. 'category_code' => $updateValues['category_code'],
  920. 'department_name' => $updateValues['department_name'],
  921. 'department_url' => $updateValues['department_url'],
  922. 'visibility' => $updateValues['visibility'],
  923. 'subscribe' => $updateValues['subscribe'],
  924. 'unsubscribe' => $updateValues['unsubscribe'],
  925. 'legal' => $updateValues['legal'],
  926. 'activate_legal' => $activeLegal,
  927. 'registration_code' => $updateValues['course_registration_password'],
  928. 'show_score' => $updateValues['show_score'],
  929. ];
  930. Database::update($table_course, $params, ['id = ?' => $courseId]);
  931. // Insert/Updates course_settings table
  932. foreach ($courseSettings as $setting) {
  933. $value = isset($updateValues[$setting]) ? $updateValues[$setting] : null;
  934. CourseManager::saveCourseConfigurationSetting(
  935. $appPlugin,
  936. $setting,
  937. $value,
  938. api_get_course_int_id()
  939. );
  940. }
  941. // update the extra fields
  942. $courseFieldValue = new ExtraFieldValue('course');
  943. $courseFieldValue->saveFieldValues($updateValues);
  944. $appPlugin->saveCourseSettingsHook($updateValues);
  945. $courseParams = api_get_cidreq();
  946. $cidReset = true;
  947. $cidReq = $course_code;
  948. Display::addFlash(Display::return_message(get_lang('Updated')));
  949. require '../inc/local.inc.php';
  950. $url = api_get_path(WEB_CODE_PATH).'course_info/infocours.php?'.$courseParams;
  951. header("Location: $url");
  952. exit;
  953. }
  954. if ($show_delete_watermark_text_message) {
  955. Display::addFlash(
  956. Display::return_message(get_lang('FileDeleted'), 'normal')
  957. );
  958. }
  959. Display::display_header($nameTools, MODULE_HELP_NAME);
  960. echo '<div id="course_settings">';
  961. $form->display();
  962. echo '</div>';
  963. Display::display_footer();