lp_list.php 33 KB

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