lp_list.php 34 KB

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