lp_list.php 34 KB

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