lp_list.php 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * This file was originally the copy of document.php, but many modifications happened since then ;
  5. * the direct file view is not any more needed, if the user uploads a SCORM zip file, a directory
  6. * will be automatically created for it, and the files will be uncompressed there for example ;
  7. *
  8. * @package chamilo.learnpath
  9. * @author Yannick Warnier <ywarnier@beeznest.org>
  10. */
  11. use ChamiloSession as Session;
  12. $this_section = SECTION_COURSES;
  13. //@todo who turns on $lp_controller_touched?
  14. if (empty($lp_controller_touched) || $lp_controller_touched != 1) {
  15. header('location: lp_controller.php?action=list');
  16. exit;
  17. }
  18. require_once '../inc/global.inc.php';
  19. $courseDir = api_get_course_path().'/scorm';
  20. $baseWordDir = $courseDir;
  21. /**
  22. * Display initialisation and security checks
  23. */
  24. // Extra javascript functions for in html head:
  25. $htmlHeadXtra[] =
  26. "<script>
  27. function confirmation(name) {
  28. if (confirm(\" ".trim(get_lang('AreYouSureToDelete'))." \"+name+\"?\"))
  29. {return true;}
  30. else
  31. {return false;}
  32. }
  33. </script>";
  34. $nameTools = get_lang('LearningPaths');
  35. Event::event_access_tool(TOOL_LEARNPATH);
  36. api_protect_course_script();
  37. /**
  38. * Display
  39. */
  40. /* Require the search widget and prepare the header with its stuff. */
  41. if (api_get_setting('search_enabled') == 'true') {
  42. require api_get_path(LIBRARY_PATH).'search/search_widget.php';
  43. search_widget_prepare($htmlHeadXtra);
  44. }
  45. $current_session = api_get_session_id();
  46. /* Introduction section (editable by course admins) */
  47. $introductionSection = Display::return_introduction_section(
  48. TOOL_LEARNPATH,
  49. array(
  50. 'CreateDocumentWebDir' => api_get_path(WEB_COURSE_PATH).api_get_course_path().'/document/',
  51. 'CreateDocumentDir' => '../../courses/'.api_get_course_path().'/document/',
  52. 'BaseHref' => api_get_path(WEB_COURSE_PATH).api_get_course_path().'/'
  53. )
  54. );
  55. $is_allowed_to_edit = api_is_allowed_to_edit(null, true);
  56. $message = '';
  57. $actions = '';
  58. if ($is_allowed_to_edit) {
  59. if (!empty($dialog_box)) {
  60. switch ($_GET['dialogtype']) {
  61. case 'confirmation':
  62. $message = Display::return_message($dialog_box, 'success');
  63. break;
  64. case 'error':
  65. $message = Display::return_message($dialog_box, 'danger');
  66. break;
  67. case 'warning':
  68. $message = Display::return_message($dialog_box, 'warning');
  69. break;
  70. default:
  71. $message = Display::return_message($dialog_box);
  72. break;
  73. }
  74. }
  75. if (api_failure::get_last_failure()) {
  76. $message = Display::return_message(api_failure::get_last_failure());
  77. }
  78. $actions .= Display::url(
  79. Display::return_icon('new_folder.png', get_lang('AddCategory'), array(), ICON_SIZE_MEDIUM),
  80. api_get_self().'?'.api_get_cidreq().'&action=add_lp_category'
  81. );
  82. $actions .= Display::url(
  83. Display::return_icon('new_learnpath.png', get_lang('LearnpathAddLearnpath'), '', ICON_SIZE_MEDIUM),
  84. api_get_self().'?'.api_get_cidreq().'&action=add_lp'
  85. );
  86. $actions .= Display::url(
  87. Display::return_icon('import_scorm.png', get_lang('UploadScorm'), '', ICON_SIZE_MEDIUM),
  88. '../upload/index.php?'.api_get_cidreq().'&curdirpath=/&tool='.TOOL_LEARNPATH
  89. );
  90. if (api_get_setting('service_ppt2lp', 'active') == 'true') {
  91. $actions .= Display::url(
  92. Display::return_icon('import_powerpoint.png', get_lang('PowerPointConvert'), '', ICON_SIZE_MEDIUM),
  93. '../upload/upload_ppt.php?'.api_get_cidreq().'&curdirpath=/&tool='.TOOL_LEARNPATH
  94. );
  95. }
  96. }
  97. $token = Security::get_token();
  98. /* DISPLAY SCORM LIST */
  99. $categoriesTempList = learnpath::getCategories(api_get_course_int_id());
  100. $categoryTest = new \Chamilo\CourseBundle\Entity\CLpCategory();
  101. $categoryTest->setId(0);
  102. $categoryTest->setName(get_lang('WithOutCategory'));
  103. $categoryTest->setPosition(0);
  104. $categories = array(
  105. $categoryTest
  106. );
  107. if (!empty($categoriesTempList)) {
  108. $categories = array_merge($categories, $categoriesTempList);
  109. }
  110. $userId = api_get_user_id();
  111. $userInfo = api_get_user_info();
  112. $lpIsShown = false;
  113. $test_mode = api_get_setting('server_type');
  114. $data = [];
  115. foreach ($categories as $item) {
  116. $categoryId = $item->getId();
  117. $list = new LearnpathList(
  118. api_get_user_id(),
  119. null,
  120. null,
  121. null,
  122. false,
  123. $categoryId
  124. );
  125. $flat_list = $list->get_flat_list();
  126. // Hiding categories with out LPs (only for student)
  127. if (empty($flat_list) && !api_is_allowed_to_edit()) {
  128. continue;
  129. }
  130. $listData = [];
  131. if (!empty($flat_list)) {
  132. $max = count($flat_list);
  133. $counter = 0;
  134. $current = 0;
  135. $autolaunch_exists = false;
  136. foreach ($flat_list as $id => $details) {
  137. // Validation when belongs to a session.
  138. $session_img = api_get_session_image(
  139. $details['lp_session'],
  140. $userInfo['status']
  141. );
  142. if (!$is_allowed_to_edit && $details['lp_visibility'] == 0) {
  143. // This is a student and this path is invisible, skip.
  144. continue;
  145. }
  146. // Check if the learnpath is visible for student.
  147. if (!$is_allowed_to_edit && !learnpath::is_lp_visible_for_student(
  148. $id,
  149. $userId
  150. )
  151. ) {
  152. continue;
  153. }
  154. $start_time = $end_time = '';
  155. if (!$is_allowed_to_edit) {
  156. $time_limits = false;
  157. //This is an old LP (from a migration 1.8.7) so we do nothing
  158. if ((empty($details['created_on']) || $details['created_on'] == '0000-00-00 00:00:00') &&
  159. (empty($details['modified_on']) || $details['modified_on'] == '0000-00-00 00:00:00')
  160. ) {
  161. $time_limits = false;
  162. }
  163. //Checking if expired_on is ON
  164. if ($details['expired_on'] != '' && $details['expired_on'] != '0000-00-00 00:00:00') {
  165. $time_limits = true;
  166. }
  167. if ($time_limits) {
  168. // Check if start time
  169. if (!empty($details['publicated_on']) && $details['publicated_on'] != '0000-00-00 00:00:00' &&
  170. !empty($details['expired_on']) && $details['expired_on'] != '0000-00-00 00:00:00'
  171. ) {
  172. $start_time = api_strtotime(
  173. $details['publicated_on'],
  174. 'UTC'
  175. );
  176. $end_time = api_strtotime(
  177. $details['expired_on'],
  178. 'UTC'
  179. );
  180. $now = time();
  181. $is_actived_time = false;
  182. if ($now > $start_time && $end_time > $now) {
  183. $is_actived_time = true;
  184. }
  185. if (!$is_actived_time) {
  186. continue;
  187. }
  188. }
  189. }
  190. $start_time = $end_time = '';
  191. } else {
  192. if (!empty($details['publicated_on'])) {
  193. $start_time = api_convert_and_format_date(
  194. $details['publicated_on'],
  195. DATE_TIME_FORMAT_LONG
  196. );
  197. }
  198. if (!empty($details['expired_on'])) {
  199. $end_time = api_convert_and_format_date(
  200. $details['expired_on'],
  201. DATE_TIME_FORMAT_LONG
  202. );
  203. }
  204. }
  205. $counter++;
  206. if (($counter % 2) == 0) {
  207. $oddclass = 'row_odd';
  208. } else {
  209. $oddclass = 'row_even';
  210. }
  211. $url_start_lp = 'lp_controller.php?'.api_get_cidreq().'&action=view&lp_id='.$id;
  212. $name = Security::remove_XSS($details['lp_name']);
  213. $extra = null;
  214. if ($is_allowed_to_edit) {
  215. $url_start_lp .= '&isStudentView=true';
  216. $studentVisibility = learnpath::is_lp_visible_for_student(
  217. $id,
  218. $userId
  219. );
  220. $dsp_desc = '<em>'.$details['lp_maker'].'</em> '.($studentVisibility ? '' : ' - ('.get_lang('LPNotVisibleToStudent').')');
  221. $extra = '<div class ="lp_content_type_label">'.$dsp_desc.'</div>';
  222. }
  223. $my_title = $name;
  224. $icon_learnpath = Display::return_icon(
  225. 'learnpath.png',
  226. get_lang('LPName'),
  227. '',
  228. ICON_SIZE_SMALL
  229. );
  230. if ($details['lp_visibility'] == 0) {
  231. $my_title = Display::tag(
  232. 'font',
  233. $name,
  234. array('class' => 'invisible')
  235. );
  236. $icon_learnpath = Display::return_icon(
  237. 'learnpath_na.png',
  238. get_lang('LPName'),
  239. '',
  240. ICON_SIZE_SMALL
  241. );
  242. }
  243. $dsp_desc = '';
  244. $dsp_export = '';
  245. $dsp_build = '';
  246. $dsp_delete = '';
  247. $dsp_visible = '';
  248. $dsp_default_view = '';
  249. $dsp_debug = '';
  250. $dsp_order = '';
  251. $progress = 0;
  252. if (!api_is_invitee()) {
  253. $progress = learnpath::getProgress(
  254. $id,
  255. $userId,
  256. api_get_course_int_id(),
  257. api_get_session_id()
  258. );
  259. }
  260. if ($is_allowed_to_edit) {
  261. $dsp_progress = '<center>'.$progress.'</center>';
  262. } else {
  263. $dsp_progress = "";
  264. if (!api_is_invitee()) {
  265. $dsp_progress = learnpath::get_progress_bar($progress, '%');
  266. }
  267. }
  268. $token_parameter = "&sec_token=$token";
  269. $dsp_edit_lp = null;
  270. $dsp_publish = null;
  271. $dsp_reinit = null;
  272. $subscribeUsers = null;
  273. $dsp_disk = null;
  274. $copy = null;
  275. $lp_auto_launch_icon = null;
  276. $actionSeriousGame = null;
  277. if ($is_allowed_to_edit) {
  278. // EDIT LP
  279. if ($current_session == $details['lp_session']) {
  280. $dsp_edit_lp = Display::url(
  281. Display::return_icon('settings.png', get_lang('CourseSettings'), '', ICON_SIZE_SMALL),
  282. "lp_controller.php?" . api_get_cidreq() . "&action=edit&lp_id=$id"
  283. );
  284. } else {
  285. $dsp_edit_lp = Display::return_icon(
  286. 'settings_na.png',
  287. get_lang('CourseSettings'),
  288. '',
  289. ICON_SIZE_SMALL
  290. );
  291. }
  292. // BUILD
  293. if ($current_session == $details['lp_session']) {
  294. if ($details['lp_type'] == 1 || $details['lp_type'] == 2) {
  295. $dsp_build = Display::url(
  296. Display::return_icon('edit.png', get_lang('LearnpathEditLearnpath'), '', ICON_SIZE_SMALL),
  297. 'lp_controller.php?' . api_get_cidreq() . '&' . http_build_query([
  298. 'action' => 'add_item',
  299. 'type' => 'step',
  300. 'lp_id' => $id,
  301. 'isStudentView' => 'false'
  302. ])
  303. );
  304. } else {
  305. $dsp_build = Display::return_icon(
  306. 'edit_na.png',
  307. get_lang('LearnpathEditLearnpath'),
  308. '',
  309. ICON_SIZE_SMALL
  310. );
  311. }
  312. } else {
  313. $dsp_build = Display::return_icon(
  314. 'edit_na.png',
  315. get_lang('LearnpathEditLearnpath'),
  316. '',
  317. ICON_SIZE_SMALL
  318. );
  319. }
  320. /* VISIBILITY COMMAND */
  321. /* Session test not necessary if we want to show base course learning
  322. paths inside the session.
  323. See http://support.chamilo.org/projects/chamilo-18/wiki/Tools_and_sessions).
  324. */
  325. if (!isset($details['subscribe_users']) || $details['subscribe_users'] != 1) {
  326. if ($details['lp_visibility'] == 0) {
  327. $dsp_visible = Display::url(
  328. Display::return_icon('invisible.png', get_lang('Show'), '', ICON_SIZE_SMALL),
  329. api_get_self() . '?' . api_get_cidreq() . "&lp_id=$id&action=toggle_visible&new_status=1"
  330. );
  331. } else {
  332. $dsp_visible = Display::url(
  333. Display::return_icon('visible.png', get_lang('Hide'), '', ICON_SIZE_SMALL),
  334. api_get_self() . '?' . api_get_cidreq() . "&lp_id=$id&action=toggle_visible&new_status=0"
  335. );
  336. }
  337. }
  338. /* PUBLISH COMMAND */
  339. if ($current_session == $details['lp_session']) {
  340. if ($details['lp_published'] == "i") {
  341. $dsp_publish = Display::url(
  342. Display::return_icon(
  343. 'lp_publish_na.png',
  344. get_lang('LearnpathPublish'),
  345. '',
  346. ICON_SIZE_SMALL
  347. ),
  348. api_get_self() . '?' . api_get_cidreq() . "&lp_id=$id&action=toggle_publish&new_status=v"
  349. );
  350. } else {
  351. $dsp_publish = "<a href='".api_get_self(
  352. )."?".api_get_cidreq(
  353. )."&lp_id=$id&action=toggle_publish&new_status=i'>".Display::return_icon(
  354. 'lp_publish.png',
  355. get_lang('LearnpathDoNotPublish'),
  356. '',
  357. ICON_SIZE_SMALL
  358. )."</a>";
  359. $dsp_publish = Display::url(
  360. Display::return_icon(
  361. 'lp_publish.png',
  362. get_lang('LearnpathDoNotPublish'),
  363. '',
  364. ICON_SIZE_SMALL
  365. ),
  366. api_get_self() . '?' . api_get_cidreq() . "&lp_id=$id&action=toggle_publish&new_status=i"
  367. );
  368. }
  369. } else {
  370. $dsp_publish = Display::return_icon(
  371. 'lp_publish_na.png',
  372. get_lang('LearnpathDoNotPublish'),
  373. '',
  374. ICON_SIZE_SMALL
  375. );
  376. }
  377. /* MULTIPLE ATTEMPTS OR SERIOUS GAME MODE
  378. SERIOUSGAME MODE is a special mode where :
  379. * If a user exits the learning path before finishing it, he comes back where he left next time he tries
  380. * When lp status is completed, user can still modify the attempt (adds/time change score, and browse it)
  381. * It is thus a mix betwenn multiple attempt and mono attempt
  382. */
  383. if ($current_session == $details['lp_session']) {
  384. if ($details['seriousgame_mode'] == 1 && $details['lp_prevent_reinit'] == 1) { //seriousgame mode | next = single
  385. $dsp_reinit = Display::url(
  386. Display::return_icon(
  387. 'reload.png',
  388. get_lang('PreventMultipleAttempts'),
  389. '',
  390. ICON_SIZE_SMALL
  391. ),
  392. "lp_controller.php?" . api_get_cidreq() . "&action=switch_attempt_mode&lp_id=$id"
  393. );
  394. }
  395. if ($details['seriousgame_mode'] == 0 && $details['lp_prevent_reinit'] == 1) { //single mode | next = multiple
  396. $dsp_reinit = Display::url(
  397. Display::return_icon(
  398. 'reload_na.png',
  399. get_lang('AllowMultipleAttempts'),
  400. '',
  401. ICON_SIZE_SMALL
  402. ),
  403. "lp_controller.php?" . api_get_cidreq() . "&action=switch_attempt_mode&lp_id=$id"
  404. );
  405. }
  406. if ($details['seriousgame_mode'] == 0 && $details['lp_prevent_reinit'] == 0) { //multiple mode | next = seriousgame
  407. $dsp_reinit = Display::url(
  408. Display::return_icon(
  409. 'reload.png',
  410. get_lang('AllowMultipleAttempts'),
  411. '',
  412. ICON_SIZE_SMALL
  413. ),
  414. "lp_controller.php?" . api_get_cidreq() . "&action=switch_attempt_mode&lp_id=$id"
  415. );
  416. }
  417. } else {
  418. $dsp_reinit = Display::return_icon(
  419. 'reload_na.png',
  420. get_lang('AllowMultipleAttempts'),
  421. '',
  422. ICON_SIZE_SMALL
  423. );
  424. }
  425. /* SCREEN LP VIEW */
  426. if ($current_session == $details['lp_session']) {
  427. switch ($details['lp_view_mode']) {
  428. case 'fullscreen':
  429. $dsp_default_view = Display::url(
  430. Display::return_icon(
  431. 'view_fullscreen.png',
  432. get_lang('ViewModeFullScreen'),
  433. '',
  434. ICON_SIZE_SMALL
  435. ),
  436. 'lp_controller.php?' . api_get_cidreq()
  437. . '&action=switch_view_mode&lp_id=' . $id . $token_parameter
  438. );
  439. break;
  440. case 'embedded':
  441. $dsp_default_view = Display::url(
  442. Display::return_icon(
  443. 'view_left_right.png',
  444. get_lang('ViewModeEmbedded'),
  445. '',
  446. ICON_SIZE_SMALL
  447. ),
  448. 'lp_controller.php?' . api_get_cidreq()
  449. . '&action=switch_view_mode&lp_id=' . $id . $token_parameter
  450. );
  451. break;
  452. case 'embedframe':
  453. $dsp_default_view = Display::url(
  454. Display::return_icon(
  455. 'view_nofullscreen.png',
  456. get_lang('ViewModeEmbedFrame'),
  457. '',
  458. ICON_SIZE_SMALL
  459. ),
  460. 'lp_controller.php?' . api_get_cidreq()
  461. . '&action=switch_view_mode&lp_id=' . $id . $token_parameter
  462. );
  463. break;
  464. case 'impress':
  465. $dsp_default_view = Display::url(
  466. Display::return_icon(
  467. 'window_list_slide.png',
  468. get_lang('ViewModeImpress'),
  469. '',
  470. ICON_SIZE_SMALL
  471. ),
  472. 'lp_controller.php?' . api_get_cidreq()
  473. . '&action=switch_view_mode&lp_id=' . $id . $token_parameter
  474. );
  475. break;
  476. }
  477. } else {
  478. if ($details['lp_view_mode'] == 'fullscreen') {
  479. $dsp_default_view = Display::return_icon(
  480. 'view_fullscreen_na.png',
  481. get_lang('ViewModeEmbedded'),
  482. '',
  483. ICON_SIZE_SMALL
  484. );
  485. } else {
  486. $dsp_default_view = Display::return_icon(
  487. 'view_left_right_na.png',
  488. get_lang('ViewModeEmbedded'),
  489. '',
  490. ICON_SIZE_SMALL
  491. );
  492. }
  493. }
  494. /* DEBUG */
  495. if ($test_mode == 'test' or api_is_platform_admin()) {
  496. if ($details['lp_scorm_debug'] == 1) {
  497. $dsp_debug = Display::url(
  498. Display::return_icon(
  499. 'bug.png',
  500. get_lang('HideDebug'),
  501. '',
  502. ICON_SIZE_SMALL
  503. ),
  504. "lp_controller.php?" . api_get_cidreq() . "&action=switch_scorm_debug&lp_id=$id"
  505. );
  506. } else {
  507. $dsp_debug = Display::url(
  508. Display::return_icon(
  509. 'bug_na.png',
  510. get_lang('ShowDebug'),
  511. '',
  512. ICON_SIZE_SMALL
  513. ),
  514. "lp_controller.php?" . api_get_cidreq() . "&action=switch_scorm_debug&lp_id=$id"
  515. );
  516. }
  517. }
  518. /* Export */
  519. if ($details['lp_type'] == 1) {
  520. $dsp_disk = Display::url(
  521. Display::return_icon(
  522. 'cd.gif',
  523. get_lang('Export'),
  524. array(),
  525. ICON_SIZE_SMALL
  526. ),
  527. api_get_self()."?".api_get_cidreq(
  528. )."&action=export&lp_id=$id"
  529. );
  530. } elseif ($details['lp_type'] == 2) {
  531. $dsp_disk = Display::url(
  532. Display::return_icon(
  533. 'cd.gif',
  534. get_lang('Export'),
  535. array(),
  536. ICON_SIZE_SMALL
  537. ),
  538. api_get_self()."?".api_get_cidreq(
  539. )."&action=export&lp_id=$id&export_name=".api_replace_dangerous_char(
  540. $name,
  541. 'strict'
  542. ).".zip"
  543. );
  544. } else {
  545. $dsp_disk = Display::return_icon(
  546. 'cd_gray.gif',
  547. get_lang('Export'),
  548. array(),
  549. ICON_SIZE_SMALL
  550. );
  551. }
  552. // Copy
  553. $copy = Display::url(
  554. Display::return_icon(
  555. 'cd_copy.png',
  556. get_lang('Copy'),
  557. array(),
  558. ICON_SIZE_SMALL
  559. ),
  560. api_get_self()."?".api_get_cidreq()."&action=copy&lp_id=$id"
  561. );
  562. // Subscribe users
  563. $subscribeUsers = null;
  564. if ($details['subscribe_users'] == 1) {
  565. $subscribeUsers = Display::url(
  566. Display::return_icon('user.png', get_lang('SubscribeUsersToLp')),
  567. api_get_path(WEB_CODE_PATH)."newscorm/lp_subscribe_users.php?lp_id=$id&".api_get_cidreq()
  568. );
  569. }
  570. /* Auto launch LP code */
  571. if (api_get_course_setting('enable_lp_auto_launch') == 1) {
  572. if ($details['autolaunch'] == 1 && $autolaunch_exists == false) {
  573. $autolaunch_exists = true;
  574. $lp_auto_launch_icon = Display::url(
  575. Display::return_icon('launch.png', get_lang('DisableLPAutoLaunch')),
  576. api_get_self() . '?' . api_get_cidreq() . "&action=auto_launch&status=0&lp_id=$id"
  577. );
  578. } else {
  579. $lp_auto_launch_icon = Display::url(
  580. Display::return_icon('launch_na.png', get_lang('EnableLPAutoLaunch')),
  581. api_get_self() . '?' . api_get_cidreq() . "&action=auto_launch&status=1&lp_id=$id"
  582. );
  583. }
  584. }
  585. // Export to PDF
  586. $export_icon = Display::url(
  587. Display::return_icon(
  588. 'pdf.png',
  589. get_lang('ExportToPDFOnlyHTMLAndImages'),
  590. '',
  591. ICON_SIZE_SMALL
  592. ),
  593. api_get_self() . '?' . api_get_cidreq() . "&action=export_to_pdf&lp_id=$id"
  594. );
  595. /* Delete */
  596. if ($current_session == $details['lp_session']) {
  597. $dsp_delete = Display::url(
  598. Display::return_icon(
  599. 'delete.png',
  600. get_lang('LearnpathDeleteLearnpath'),
  601. '',
  602. ICON_SIZE_SMALL
  603. ),
  604. 'lp_controller.php?' . api_get_cidreq() . "&action=delete&lp_id=$id",
  605. ['onclick' => "javascript: return confirmation('" . addslashes($name) . "');"]
  606. );
  607. } else {
  608. $dsp_delete = Display::return_icon(
  609. 'delete_na.png',
  610. get_lang('LearnpathDeleteLearnpath'),
  611. '',
  612. ICON_SIZE_SMALL
  613. );
  614. }
  615. /* COLUMN ORDER */
  616. // Only active while session mode is not active
  617. if ($current_session == 0) {
  618. if ($details['lp_display_order'] == 1 && $max != 1) {
  619. $dsp_order .= Display::url(
  620. Display::return_icon('down.png', get_lang('MoveDown'), '', ICON_SIZE_SMALL),
  621. "lp_controller.php?" . api_get_cidreq() . "&action=move_lp_down&lp_id=$id"
  622. );
  623. } elseif ($current == $max - 1 && $max != 1) {
  624. $dsp_order .= Display::url(
  625. Display::return_icon('up.png', get_lang('MoveUp'), '', ICON_SIZE_SMALL),
  626. "lp_controller.php?" . api_get_cidreq() . "&action=move_lp_up&lp_id=$id"
  627. );
  628. } elseif ($max == 1) {
  629. $dsp_order = '';
  630. } else {
  631. $dsp_order .= Display::url(
  632. Display::return_icon('down.png', get_lang('MoveDown'), '', ICON_SIZE_SMALL),
  633. "lp_controller.php?" . api_get_cidreq() . "&action=move_lp_down&lp_id=$id"
  634. );
  635. $dsp_order .= Display::url(
  636. Display::return_icon('up.png', get_lang('MoveUp'), '', ICON_SIZE_SMALL),
  637. "lp_controller.php?" . api_get_cidreq() . "&action=move_lp_up&lp_id=$id"
  638. );
  639. }
  640. }
  641. if ($is_allowed_to_edit) {
  642. $start_time = $start_time;
  643. $end_time = $end_time;
  644. } else {
  645. $start_time = $end_time = '';
  646. }
  647. if (api_get_setting('gamification_mode') == 1) {
  648. if ($details['seriousgame_mode'] == 0) {
  649. $actionSeriousGame = Display::toolbarButton(
  650. null,
  651. api_get_self() . '?' . api_get_cidreq() . "&lp_id=$id&action=toggle_seriousgame",
  652. 'trophy',
  653. 'default',
  654. [
  655. 'class' => 'btn-xs',
  656. 'title' => get_lang('EnableGamificationMode')
  657. ]
  658. );
  659. } else {
  660. $actionSeriousGame = Display::toolbarButton(
  661. null,
  662. api_get_self() . '?' . api_get_cidreq() . "&lp_id=$id&action=toggle_seriousgame",
  663. 'trophy',
  664. 'warning',
  665. [
  666. 'class' => 'btn-xs active',
  667. 'title' => get_lang('DisableGamificationMode')
  668. ]
  669. );
  670. }
  671. }
  672. } else {
  673. // Student
  674. $export_icon = Display::url(
  675. Display::return_icon('pdf.png', get_lang('ExportToPDF'), '', ICON_SIZE_SMALL),
  676. api_get_self() . '?' . api_get_cidreq() . "&action=export_to_pdf&lp_id=$id"
  677. );
  678. }
  679. $hideScormExportLink = api_get_setting('hide_scorm_export_link');
  680. if ($hideScormExportLink === 'true') {
  681. $dsp_disk = null;
  682. }
  683. $hideScormCopyLink = api_get_setting('hide_scorm_copy_link');
  684. if ($hideScormCopyLink === 'true') {
  685. $copy = null;
  686. }
  687. $hideScormPdfLink = api_get_setting('hide_scorm_pdf_link');
  688. if ($hideScormPdfLink === 'true') {
  689. $export_icon = null;
  690. }
  691. $listData[] = [
  692. 'learnpath_icon' => $icon_learnpath,
  693. 'url_start' => $url_start_lp,
  694. 'title' => $my_title,
  695. 'session_image' => $session_img,
  696. 'extra' => $extra,
  697. 'start_time' => $start_time,
  698. 'end_time' => $end_time,
  699. 'dsp_progress' => $dsp_progress,
  700. 'action_build' => $dsp_build,
  701. 'action_edit' => $dsp_edit_lp,
  702. 'action_visible' => $dsp_visible,
  703. 'action_publish' => $dsp_publish,
  704. 'action_reinit' => $dsp_reinit,
  705. 'action_default_view' => $dsp_default_view,
  706. 'action_debug' => $dsp_debug,
  707. 'action_export' => $dsp_disk,
  708. 'action_copy' => $copy,
  709. 'action_auto_launch' => $lp_auto_launch_icon,
  710. 'action_pdf' => $export_icon,
  711. 'action_delete' => $dsp_delete,
  712. 'action_order' => $dsp_order,
  713. 'action_serious_game' => $actionSeriousGame,
  714. 'action_subscribe_users' => $subscribeUsers
  715. ];
  716. $lpIsShown = true;
  717. //counter for number of elements treated
  718. $current++;
  719. } // end foreach ($flat_list)
  720. }
  721. $data[] = [
  722. 'category' => $item,
  723. 'lp_list' => $listData
  724. ];
  725. }
  726. $template = new Template($nameTools);
  727. $template->assign('is_allowed_to_edit', $is_allowed_to_edit);
  728. $template->assign('is_invitee', api_is_invitee());
  729. $template->assign('actions', $actions);
  730. $template->assign('message', $message);
  731. $template->assign('introduction_section', $introductionSection);
  732. $template->assign('data', $data);
  733. $template->assign('lp_is_shown', $lpIsShown);
  734. $content = $template->fetch('default/learnpath/list.tpl');
  735. $template->assign('content', $content);
  736. $template->display_one_col_template();
  737. $course_info = api_get_course_info();
  738. learnpath::generate_learning_path_folder($course_info);
  739. // Deleting the objects
  740. Session::erase('oLP');
  741. Session::erase('lpobject');
  742. DocumentManager::removeGeneratedAudioTempFile();