lp_list.php 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833
  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('AreYouSureToDeleteJS'))." \"+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. $trackingAction = '';
  249. $dsp_default_view = '';
  250. $dsp_debug = '';
  251. $dsp_order = '';
  252. $progress = 0;
  253. if (!api_is_invitee()) {
  254. $progress = learnpath::getProgress(
  255. $id,
  256. $userId,
  257. api_get_course_int_id(),
  258. api_get_session_id()
  259. );
  260. }
  261. if ($is_allowed_to_edit) {
  262. $dsp_progress = '<center>'.$progress.'</center>';
  263. } else {
  264. $dsp_progress = "";
  265. if (!api_is_invitee()) {
  266. $dsp_progress = learnpath::get_progress_bar($progress, '%');
  267. }
  268. }
  269. $token_parameter = "&sec_token=$token";
  270. $dsp_edit_lp = null;
  271. $dsp_publish = null;
  272. $dsp_reinit = null;
  273. $subscribeUsers = null;
  274. $dsp_disk = null;
  275. $copy = null;
  276. $lp_auto_launch_icon = null;
  277. $actionSeriousGame = null;
  278. if ($is_allowed_to_edit) {
  279. // EDIT LP
  280. if ($current_session == $details['lp_session']) {
  281. $dsp_edit_lp = Display::url(
  282. Display::return_icon('settings.png', get_lang('CourseSettings'), '', ICON_SIZE_SMALL),
  283. "lp_controller.php?" . api_get_cidreq() . "&action=edit&lp_id=$id"
  284. );
  285. } else {
  286. $dsp_edit_lp = Display::return_icon(
  287. 'settings_na.png',
  288. get_lang('CourseSettings'),
  289. '',
  290. ICON_SIZE_SMALL
  291. );
  292. }
  293. // BUILD
  294. if ($current_session == $details['lp_session']) {
  295. if ($details['lp_type'] == 1 || $details['lp_type'] == 2) {
  296. $dsp_build = Display::url(
  297. Display::return_icon('edit.png', get_lang('LearnpathEditLearnpath'), '', ICON_SIZE_SMALL),
  298. 'lp_controller.php?' . api_get_cidreq() . '&' . http_build_query([
  299. 'action' => 'add_item',
  300. 'type' => 'step',
  301. 'lp_id' => $id,
  302. 'isStudentView' => 'false'
  303. ])
  304. );
  305. } else {
  306. $dsp_build = Display::return_icon(
  307. 'edit_na.png',
  308. get_lang('LearnpathEditLearnpath'),
  309. '',
  310. ICON_SIZE_SMALL
  311. );
  312. }
  313. } else {
  314. $dsp_build = Display::return_icon(
  315. 'edit_na.png',
  316. get_lang('LearnpathEditLearnpath'),
  317. '',
  318. ICON_SIZE_SMALL
  319. );
  320. }
  321. /* VISIBILITY COMMAND */
  322. /* Session test not necessary if we want to show base course learning
  323. paths inside the session.
  324. See http://support.chamilo.org/projects/chamilo-18/wiki/Tools_and_sessions).
  325. */
  326. if (!isset($details['subscribe_users']) || $details['subscribe_users'] != 1) {
  327. if ($details['lp_visibility'] == 0) {
  328. $dsp_visible = Display::url(
  329. Display::return_icon('invisible.png', get_lang('Show'), '', ICON_SIZE_SMALL),
  330. api_get_self() . '?' . api_get_cidreq() . "&lp_id=$id&action=toggle_visible&new_status=1"
  331. );
  332. } else {
  333. $dsp_visible = Display::url(
  334. Display::return_icon('visible.png', get_lang('Hide'), '', ICON_SIZE_SMALL),
  335. api_get_self() . '?' . api_get_cidreq() . "&lp_id=$id&action=toggle_visible&new_status=0"
  336. );
  337. }
  338. }
  339. //Tracking command
  340. $trackingActionUrl = 'lp_controller.php?'
  341. . api_get_cidreq() . '&'
  342. . http_build_query([
  343. 'action' => 'report',
  344. 'lp_id' => $id
  345. ]);
  346. $trackingAction = Display::url(
  347. Display::return_icon('test_results.png', get_lang('Results'), array(), ICON_SIZE_SMALL),
  348. $trackingActionUrl
  349. );
  350. /* PUBLISH COMMAND */
  351. if ($current_session == $details['lp_session']) {
  352. if ($details['lp_published'] == "i") {
  353. $dsp_publish = Display::url(
  354. Display::return_icon(
  355. 'lp_publish_na.png',
  356. get_lang('LearnpathPublish'),
  357. '',
  358. ICON_SIZE_SMALL
  359. ),
  360. api_get_self() . '?' . api_get_cidreq() . "&lp_id=$id&action=toggle_publish&new_status=v"
  361. );
  362. } else {
  363. $dsp_publish = "<a href='".api_get_self()."?".api_get_cidreq()."&lp_id=$id&action=toggle_publish&new_status=i'>".
  364. Display::return_icon(
  365. 'lp_publish.png',
  366. get_lang('LearnpathDoNotPublish'),
  367. '',
  368. ICON_SIZE_SMALL
  369. )."</a>";
  370. $dsp_publish = Display::url(
  371. Display::return_icon(
  372. 'lp_publish.png',
  373. get_lang('LearnpathDoNotPublish'),
  374. '',
  375. ICON_SIZE_SMALL
  376. ),
  377. api_get_self() . '?' . api_get_cidreq() . "&lp_id=$id&action=toggle_publish&new_status=i"
  378. );
  379. }
  380. } else {
  381. $dsp_publish = Display::return_icon(
  382. 'lp_publish_na.png',
  383. get_lang('LearnpathDoNotPublish'),
  384. '',
  385. ICON_SIZE_SMALL
  386. );
  387. }
  388. /* MULTIPLE ATTEMPTS OR SERIOUS GAME MODE
  389. SERIOUSGAME MODE is a special mode where :
  390. * If a user exits the learning path before finishing it, he comes back where he left next time he tries
  391. * When lp status is completed, user can still modify the attempt (adds/time change score, and browse it)
  392. * It is thus a mix betwenn multiple attempt and mono attempt
  393. */
  394. if ($current_session == $details['lp_session']) {
  395. if ($details['seriousgame_mode'] == 1 && $details['lp_prevent_reinit'] == 1) { //seriousgame mode | next = single
  396. $dsp_reinit = Display::url(
  397. Display::return_icon(
  398. 'reload.png',
  399. get_lang('PreventMultipleAttempts'),
  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'] == 1) { //single mode | next = multiple
  407. $dsp_reinit = Display::url(
  408. Display::return_icon(
  409. 'reload_na.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. if ($details['seriousgame_mode'] == 0 && $details['lp_prevent_reinit'] == 0) { //multiple mode | next = seriousgame
  418. $dsp_reinit = Display::url(
  419. Display::return_icon(
  420. 'reload.png',
  421. get_lang('AllowMultipleAttempts'),
  422. '',
  423. ICON_SIZE_SMALL
  424. ),
  425. "lp_controller.php?" . api_get_cidreq() . "&action=switch_attempt_mode&lp_id=$id"
  426. );
  427. }
  428. } else {
  429. $dsp_reinit = Display::return_icon(
  430. 'reload_na.png',
  431. get_lang('AllowMultipleAttempts'),
  432. '',
  433. ICON_SIZE_SMALL
  434. );
  435. }
  436. /* SCREEN LP VIEW */
  437. if ($current_session == $details['lp_session']) {
  438. switch ($details['lp_view_mode']) {
  439. case 'fullscreen':
  440. $dsp_default_view = Display::url(
  441. Display::return_icon(
  442. 'view_fullscreen.png',
  443. get_lang('ViewModeFullScreen'),
  444. '',
  445. ICON_SIZE_SMALL
  446. ),
  447. 'lp_controller.php?' . api_get_cidreq()
  448. . '&action=switch_view_mode&lp_id=' . $id . $token_parameter
  449. );
  450. break;
  451. case 'embedded':
  452. $dsp_default_view = Display::url(
  453. Display::return_icon(
  454. 'view_left_right.png',
  455. get_lang('ViewModeEmbedded'),
  456. '',
  457. ICON_SIZE_SMALL
  458. ),
  459. 'lp_controller.php?' . api_get_cidreq()
  460. . '&action=switch_view_mode&lp_id=' . $id . $token_parameter
  461. );
  462. break;
  463. case 'embedframe':
  464. $dsp_default_view = Display::url(
  465. Display::return_icon(
  466. 'view_nofullscreen.png',
  467. get_lang('ViewModeEmbedFrame'),
  468. '',
  469. ICON_SIZE_SMALL
  470. ),
  471. 'lp_controller.php?' . api_get_cidreq()
  472. . '&action=switch_view_mode&lp_id=' . $id . $token_parameter
  473. );
  474. break;
  475. case 'impress':
  476. $dsp_default_view = Display::url(
  477. Display::return_icon(
  478. 'window_list_slide.png',
  479. get_lang('ViewModeImpress'),
  480. '',
  481. ICON_SIZE_SMALL
  482. ),
  483. 'lp_controller.php?' . api_get_cidreq()
  484. . '&action=switch_view_mode&lp_id=' . $id . $token_parameter
  485. );
  486. break;
  487. }
  488. } else {
  489. if ($details['lp_view_mode'] == 'fullscreen') {
  490. $dsp_default_view = Display::return_icon(
  491. 'view_fullscreen_na.png',
  492. get_lang('ViewModeEmbedded'),
  493. '',
  494. ICON_SIZE_SMALL
  495. );
  496. } else {
  497. $dsp_default_view = Display::return_icon(
  498. 'view_left_right_na.png',
  499. get_lang('ViewModeEmbedded'),
  500. '',
  501. ICON_SIZE_SMALL
  502. );
  503. }
  504. }
  505. /* DEBUG */
  506. if ($test_mode == 'test' or api_is_platform_admin()) {
  507. if ($details['lp_scorm_debug'] == 1) {
  508. $dsp_debug = Display::url(
  509. Display::return_icon(
  510. 'bug.png',
  511. get_lang('HideDebug'),
  512. '',
  513. ICON_SIZE_SMALL
  514. ),
  515. "lp_controller.php?" . api_get_cidreq() . "&action=switch_scorm_debug&lp_id=$id"
  516. );
  517. } else {
  518. $dsp_debug = Display::url(
  519. Display::return_icon(
  520. 'bug_na.png',
  521. get_lang('ShowDebug'),
  522. '',
  523. ICON_SIZE_SMALL
  524. ),
  525. "lp_controller.php?" . api_get_cidreq() . "&action=switch_scorm_debug&lp_id=$id"
  526. );
  527. }
  528. }
  529. /* Export */
  530. if ($details['lp_type'] == 1) {
  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"
  540. );
  541. } elseif ($details['lp_type'] == 2) {
  542. $dsp_disk = Display::url(
  543. Display::return_icon(
  544. 'cd.gif',
  545. get_lang('Export'),
  546. array(),
  547. ICON_SIZE_SMALL
  548. ),
  549. api_get_self()."?".api_get_cidreq()."&action=export&lp_id=$id&export_name=".api_replace_dangerous_char($name, 'strict' ).".zip"
  550. );
  551. } else {
  552. $dsp_disk = Display::return_icon(
  553. 'cd_gray.gif',
  554. get_lang('Export'),
  555. array(),
  556. ICON_SIZE_SMALL
  557. );
  558. }
  559. // Copy
  560. $copy = Display::url(
  561. Display::return_icon(
  562. 'cd_copy.png',
  563. get_lang('Copy'),
  564. array(),
  565. ICON_SIZE_SMALL
  566. ),
  567. api_get_self()."?".api_get_cidreq()."&action=copy&lp_id=$id"
  568. );
  569. // Subscribe users
  570. $subscribeUsers = null;
  571. if ($details['subscribe_users'] == 1) {
  572. $subscribeUsers = Display::url(
  573. Display::return_icon('user.png', get_lang('SubscribeUsersToLp')),
  574. api_get_path(WEB_CODE_PATH)."newscorm/lp_subscribe_users.php?lp_id=$id&".api_get_cidreq()
  575. );
  576. }
  577. /* Auto launch LP code */
  578. if (api_get_course_setting('enable_lp_auto_launch') == 1) {
  579. if ($details['autolaunch'] == 1 && $autolaunch_exists == false) {
  580. $autolaunch_exists = true;
  581. $lp_auto_launch_icon = Display::url(
  582. Display::return_icon('launch.png', get_lang('DisableLPAutoLaunch')),
  583. api_get_self() . '?' . api_get_cidreq() . "&action=auto_launch&status=0&lp_id=$id"
  584. );
  585. } else {
  586. $lp_auto_launch_icon = Display::url(
  587. Display::return_icon('launch_na.png', get_lang('EnableLPAutoLaunch')),
  588. api_get_self() . '?' . api_get_cidreq() . "&action=auto_launch&status=1&lp_id=$id"
  589. );
  590. }
  591. }
  592. // Export to PDF
  593. $export_icon = Display::url(
  594. Display::return_icon(
  595. 'pdf.png',
  596. get_lang('ExportToPDFOnlyHTMLAndImages'),
  597. '',
  598. ICON_SIZE_SMALL
  599. ),
  600. api_get_self() . '?' . api_get_cidreq() . "&action=export_to_pdf&lp_id=$id"
  601. );
  602. /* Delete */
  603. if ($current_session == $details['lp_session']) {
  604. $dsp_delete = Display::url(
  605. Display::return_icon(
  606. 'delete.png',
  607. get_lang('LearnpathDeleteLearnpath'),
  608. '',
  609. ICON_SIZE_SMALL
  610. ),
  611. 'lp_controller.php?' . api_get_cidreq() . "&action=delete&lp_id=$id",
  612. ['onclick' => "javascript: return confirmation('" . addslashes($name) . "');"]
  613. );
  614. } else {
  615. $dsp_delete = Display::return_icon(
  616. 'delete_na.png',
  617. get_lang('LearnpathDeleteLearnpath'),
  618. '',
  619. ICON_SIZE_SMALL
  620. );
  621. }
  622. /* COLUMN ORDER */
  623. // Only active while session mode is not active
  624. if ($current_session == 0) {
  625. if ($details['lp_display_order'] == 1 && $max != 1) {
  626. $dsp_order .= Display::url(
  627. Display::return_icon('down.png', get_lang('MoveDown'), '', ICON_SIZE_SMALL),
  628. "lp_controller.php?" . api_get_cidreq() . "&action=move_lp_down&lp_id=$id"
  629. );
  630. } elseif ($current == $max - 1 && $max != 1) {
  631. $dsp_order .= Display::url(
  632. Display::return_icon('up.png', get_lang('MoveUp'), '', ICON_SIZE_SMALL),
  633. "lp_controller.php?" . api_get_cidreq() . "&action=move_lp_up&lp_id=$id"
  634. );
  635. } elseif ($max == 1) {
  636. $dsp_order = '';
  637. } else {
  638. $dsp_order .= Display::url(
  639. Display::return_icon('down.png', get_lang('MoveDown'), '', ICON_SIZE_SMALL),
  640. "lp_controller.php?" . api_get_cidreq() . "&action=move_lp_down&lp_id=$id"
  641. );
  642. $dsp_order .= Display::url(
  643. Display::return_icon('up.png', get_lang('MoveUp'), '', ICON_SIZE_SMALL),
  644. "lp_controller.php?" . api_get_cidreq() . "&action=move_lp_up&lp_id=$id"
  645. );
  646. }
  647. }
  648. if ($is_allowed_to_edit) {
  649. $start_time = $start_time;
  650. $end_time = $end_time;
  651. } else {
  652. $start_time = $end_time = '';
  653. }
  654. if (api_get_setting('gamification_mode') == 1) {
  655. if ($details['seriousgame_mode'] == 0) {
  656. $actionSeriousGame = Display::toolbarButton(
  657. null,
  658. api_get_self() . '?' . api_get_cidreq() . "&lp_id=$id&action=toggle_seriousgame",
  659. 'trophy',
  660. 'default',
  661. [
  662. 'class' => 'btn-xs',
  663. 'title' => get_lang('EnableGamificationMode')
  664. ]
  665. );
  666. } else {
  667. $actionSeriousGame = Display::toolbarButton(
  668. null,
  669. api_get_self() . '?' . api_get_cidreq() . "&lp_id=$id&action=toggle_seriousgame",
  670. 'trophy',
  671. 'warning',
  672. [
  673. 'class' => 'btn-xs active',
  674. 'title' => get_lang('DisableGamificationMode')
  675. ]
  676. );
  677. }
  678. }
  679. } else {
  680. // Student
  681. $export_icon = Display::url(
  682. Display::return_icon('pdf.png', get_lang('ExportToPDF'), '', ICON_SIZE_SMALL),
  683. api_get_self() . '?' . api_get_cidreq() . "&action=export_to_pdf&lp_id=$id"
  684. );
  685. }
  686. $hideScormExportLink = api_get_setting('hide_scorm_export_link');
  687. if ($hideScormExportLink === 'true') {
  688. $dsp_disk = null;
  689. }
  690. $hideScormCopyLink = api_get_setting('hide_scorm_copy_link');
  691. if ($hideScormCopyLink === 'true') {
  692. $copy = null;
  693. }
  694. $hideScormPdfLink = api_get_setting('hide_scorm_pdf_link');
  695. if ($hideScormPdfLink === 'true') {
  696. $export_icon = null;
  697. }
  698. $listData[] = [
  699. 'learnpath_icon' => $icon_learnpath,
  700. 'url_start' => $url_start_lp,
  701. 'title' => $my_title,
  702. 'session_image' => $session_img,
  703. 'extra' => $extra,
  704. 'start_time' => $start_time,
  705. 'end_time' => $end_time,
  706. 'dsp_progress' => $dsp_progress,
  707. 'action_build' => $dsp_build,
  708. 'action_edit' => $dsp_edit_lp,
  709. 'action_tracking' => $trackingAction,
  710. 'action_visible' => $dsp_visible,
  711. 'action_publish' => $dsp_publish,
  712. 'action_reinit' => $dsp_reinit,
  713. 'action_default_view' => $dsp_default_view,
  714. 'action_debug' => $dsp_debug,
  715. 'action_export' => $dsp_disk,
  716. 'action_copy' => $copy,
  717. 'action_auto_launch' => $lp_auto_launch_icon,
  718. 'action_pdf' => $export_icon,
  719. 'action_delete' => $dsp_delete,
  720. 'action_order' => $dsp_order,
  721. 'action_serious_game' => $actionSeriousGame,
  722. 'action_subscribe_users' => $subscribeUsers
  723. ];
  724. $lpIsShown = true;
  725. //counter for number of elements treated
  726. $current++;
  727. } // end foreach ($flat_list)
  728. }
  729. $data[] = [
  730. 'category' => $item,
  731. 'lp_list' => $listData
  732. ];
  733. }
  734. $template = new Template($nameTools);
  735. $template->assign('is_allowed_to_edit', $is_allowed_to_edit);
  736. $template->assign('is_invitee', api_is_invitee());
  737. $template->assign('actions', $actions);
  738. $template->assign('categories', $categories);
  739. $template->assign('message', $message);
  740. $template->assign('introduction_section', $introductionSection);
  741. $template->assign('data', $data);
  742. $template->assign('lp_is_shown', $lpIsShown);
  743. $content = $template->fetch('default/learnpath/list.tpl');
  744. $template->assign('content', $content);
  745. $template->display_one_col_template();
  746. $course_info = api_get_course_info();
  747. learnpath::generate_learning_path_folder($course_info);
  748. // Deleting the objects
  749. Session::erase('oLP');
  750. Session::erase('lpobject');
  751. DocumentManager::removeGeneratedAudioTempFile();