lp_list.php 34 KB

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