lp_list.php 33 KB

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