lp_list.php 34 KB

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