lp_list.php 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856
  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('test_results.png', get_lang('Results'), array(), ICON_SIZE_SMALL),
  378. $trackingActionUrl
  379. );
  380. /* PUBLISH COMMAND */
  381. if ($current_session == $details['lp_session']) {
  382. if ($details['lp_published'] == "i") {
  383. $dsp_publish = Display::url(
  384. Display::return_icon(
  385. 'lp_publish_na.png',
  386. get_lang('LearnpathPublish'),
  387. '',
  388. ICON_SIZE_SMALL
  389. ),
  390. api_get_self().'?'.api_get_cidreq()."&lp_id=$id&action=toggle_publish&new_status=v"
  391. );
  392. } else {
  393. $dsp_publish = "<a href='".api_get_self()."?".api_get_cidreq()."&lp_id=$id&action=toggle_publish&new_status=i'>".
  394. Display::return_icon(
  395. 'lp_publish.png',
  396. get_lang('LearnpathDoNotPublish'),
  397. '',
  398. ICON_SIZE_SMALL
  399. )."</a>";
  400. $dsp_publish = Display::url(
  401. Display::return_icon(
  402. 'lp_publish.png',
  403. get_lang('LearnpathDoNotPublish'),
  404. '',
  405. ICON_SIZE_SMALL
  406. ),
  407. api_get_self().'?'.api_get_cidreq()."&lp_id=$id&action=toggle_publish&new_status=i"
  408. );
  409. }
  410. } else {
  411. $dsp_publish = Display::return_icon(
  412. 'lp_publish_na.png',
  413. get_lang('LearnpathDoNotPublish'),
  414. '',
  415. ICON_SIZE_SMALL
  416. );
  417. }
  418. /* MULTIPLE ATTEMPTS OR SERIOUS GAME MODE
  419. SERIOUSGAME MODE is a special mode where :
  420. * If a user exits the learning path before finishing it, he comes back where he left next time he tries
  421. * When lp status is completed, user can still modify the attempt (adds/time change score, and browse it)
  422. * It is thus a mix betwenn multiple attempt and mono attempt
  423. */
  424. if ($current_session == $details['lp_session']) {
  425. if ($details['seriousgame_mode'] == 1 && $details['lp_prevent_reinit'] == 1) { //seriousgame mode | next = single
  426. $dsp_reinit = Display::url(
  427. Display::return_icon(
  428. 'reload.png',
  429. get_lang('PreventMultipleAttempts'),
  430. '',
  431. ICON_SIZE_SMALL
  432. ),
  433. "lp_controller.php?".api_get_cidreq()."&action=switch_attempt_mode&lp_id=$id"
  434. );
  435. }
  436. if ($details['seriousgame_mode'] == 0 && $details['lp_prevent_reinit'] == 1) { //single mode | next = multiple
  437. $dsp_reinit = Display::url(
  438. Display::return_icon(
  439. 'reload_na.png',
  440. get_lang('AllowMultipleAttempts'),
  441. '',
  442. ICON_SIZE_SMALL
  443. ),
  444. "lp_controller.php?".api_get_cidreq()."&action=switch_attempt_mode&lp_id=$id"
  445. );
  446. }
  447. if ($details['seriousgame_mode'] == 0 && $details['lp_prevent_reinit'] == 0) { //multiple mode | next = seriousgame
  448. $dsp_reinit = Display::url(
  449. Display::return_icon(
  450. 'reload.png',
  451. get_lang('AllowMultipleAttempts'),
  452. '',
  453. ICON_SIZE_SMALL
  454. ),
  455. "lp_controller.php?".api_get_cidreq()."&action=switch_attempt_mode&lp_id=$id"
  456. );
  457. }
  458. } else {
  459. $dsp_reinit = Display::return_icon(
  460. 'reload_na.png',
  461. get_lang('AllowMultipleAttempts'),
  462. '',
  463. ICON_SIZE_SMALL
  464. );
  465. }
  466. /* SCREEN LP VIEW */
  467. if ($current_session == $details['lp_session']) {
  468. switch ($details['lp_view_mode']) {
  469. case 'fullscreen':
  470. $dsp_default_view = Display::url(
  471. Display::return_icon(
  472. 'view_fullscreen.png',
  473. get_lang('ViewModeFullScreen'),
  474. '',
  475. ICON_SIZE_SMALL
  476. ),
  477. 'lp_controller.php?'.api_get_cidreq()
  478. . '&action=switch_view_mode&lp_id='.$id.$token_parameter
  479. );
  480. break;
  481. case 'embedded':
  482. $dsp_default_view = Display::url(
  483. Display::return_icon(
  484. 'view_left_right.png',
  485. get_lang('ViewModeEmbedded'),
  486. '',
  487. ICON_SIZE_SMALL
  488. ),
  489. 'lp_controller.php?'.api_get_cidreq()
  490. . '&action=switch_view_mode&lp_id='.$id.$token_parameter
  491. );
  492. break;
  493. case 'embedframe':
  494. $dsp_default_view = Display::url(
  495. Display::return_icon(
  496. 'view_nofullscreen.png',
  497. get_lang('ViewModeEmbedFrame'),
  498. '',
  499. ICON_SIZE_SMALL
  500. ),
  501. 'lp_controller.php?'.api_get_cidreq()
  502. . '&action=switch_view_mode&lp_id='.$id.$token_parameter
  503. );
  504. break;
  505. case 'impress':
  506. $dsp_default_view = Display::url(
  507. Display::return_icon(
  508. 'window_list_slide.png',
  509. get_lang('ViewModeImpress'),
  510. '',
  511. ICON_SIZE_SMALL
  512. ),
  513. 'lp_controller.php?'.api_get_cidreq()
  514. . '&action=switch_view_mode&lp_id='.$id.$token_parameter
  515. );
  516. break;
  517. }
  518. } else {
  519. if ($details['lp_view_mode'] == 'fullscreen') {
  520. $dsp_default_view = Display::return_icon(
  521. 'view_fullscreen_na.png',
  522. get_lang('ViewModeEmbedded'),
  523. '',
  524. ICON_SIZE_SMALL
  525. );
  526. } else {
  527. $dsp_default_view = Display::return_icon(
  528. 'view_left_right_na.png',
  529. get_lang('ViewModeEmbedded'),
  530. '',
  531. ICON_SIZE_SMALL
  532. );
  533. }
  534. }
  535. /* DEBUG */
  536. if ($test_mode == 'test' or api_is_platform_admin()) {
  537. if ($details['lp_scorm_debug'] == 1) {
  538. $dsp_debug = Display::url(
  539. Display::return_icon(
  540. 'bug.png',
  541. get_lang('HideDebug'),
  542. '',
  543. ICON_SIZE_SMALL
  544. ),
  545. "lp_controller.php?".api_get_cidreq()."&action=switch_scorm_debug&lp_id=$id"
  546. );
  547. } else {
  548. $dsp_debug = Display::url(
  549. Display::return_icon(
  550. 'bug_na.png',
  551. get_lang('ShowDebug'),
  552. '',
  553. ICON_SIZE_SMALL
  554. ),
  555. "lp_controller.php?".api_get_cidreq()."&action=switch_scorm_debug&lp_id=$id"
  556. );
  557. }
  558. }
  559. /* Export */
  560. if ($details['lp_type'] == 1) {
  561. $dsp_disk = Display::url(
  562. Display::return_icon(
  563. 'cd.png',
  564. get_lang('Export'),
  565. array(),
  566. ICON_SIZE_SMALL
  567. ),
  568. api_get_self()."?".api_get_cidreq(
  569. )."&action=export&lp_id=$id"
  570. );
  571. } elseif ($details['lp_type'] == 2) {
  572. $dsp_disk = Display::url(
  573. Display::return_icon(
  574. 'cd.png',
  575. get_lang('Export'),
  576. array(),
  577. ICON_SIZE_SMALL
  578. ),
  579. api_get_self()."?".api_get_cidreq()."&action=export&lp_id=$id&export_name=".api_replace_dangerous_char($name).".zip"
  580. );
  581. } else {
  582. $dsp_disk = Display::return_icon(
  583. 'cd_na.png',
  584. get_lang('Export'),
  585. array(),
  586. ICON_SIZE_SMALL
  587. );
  588. }
  589. // Copy
  590. $copy = Display::url(
  591. Display::return_icon(
  592. 'cd_copy.png',
  593. get_lang('Copy'),
  594. array(),
  595. ICON_SIZE_SMALL
  596. ),
  597. api_get_self()."?".api_get_cidreq()."&action=copy&lp_id=$id"
  598. );
  599. // Subscribe users
  600. $subscribeUsers = null;
  601. if ($details['subscribe_users'] == 1) {
  602. $subscribeUsers = Display::url(
  603. Display::return_icon('user.png', get_lang('SubscribeUsersToLp')),
  604. api_get_path(WEB_CODE_PATH)."lp/lp_subscribe_users.php?lp_id=$id&".api_get_cidreq()
  605. );
  606. }
  607. /* Auto launch LP code */
  608. if (api_get_course_setting('enable_lp_auto_launch') == 1) {
  609. if ($details['autolaunch'] == 1 && $autolaunch_exists == false) {
  610. $autolaunch_exists = true;
  611. $lp_auto_launch_icon = Display::url(
  612. Display::return_icon('launch.png', get_lang('DisableLPAutoLaunch')),
  613. api_get_self().'?'.api_get_cidreq()."&action=auto_launch&status=0&lp_id=$id"
  614. );
  615. } else {
  616. $lp_auto_launch_icon = Display::url(
  617. Display::return_icon('launch_na.png', get_lang('EnableLPAutoLaunch')),
  618. api_get_self().'?'.api_get_cidreq()."&action=auto_launch&status=1&lp_id=$id"
  619. );
  620. }
  621. }
  622. // Export to PDF
  623. $export_icon = Display::url(
  624. Display::return_icon(
  625. 'pdf.png',
  626. get_lang('ExportToPDFOnlyHTMLAndImages'),
  627. '',
  628. ICON_SIZE_SMALL
  629. ),
  630. api_get_self().'?'.api_get_cidreq()."&action=export_to_pdf&lp_id=$id"
  631. );
  632. /* Delete */
  633. if ($current_session == $details['lp_session']) {
  634. $dsp_delete = Display::url(
  635. Display::return_icon(
  636. 'delete.png',
  637. get_lang('LearnpathDeleteLearnpath'),
  638. '',
  639. ICON_SIZE_SMALL
  640. ),
  641. 'lp_controller.php?'.api_get_cidreq()."&action=delete&lp_id=$id",
  642. ['onclick' => "javascript: return confirmation('".addslashes($name)."');"]
  643. );
  644. } else {
  645. $dsp_delete = Display::return_icon(
  646. 'delete_na.png',
  647. get_lang('LearnpathDeleteLearnpath'),
  648. '',
  649. ICON_SIZE_SMALL
  650. );
  651. }
  652. /* COLUMN ORDER */
  653. // Only active while session mode is not active
  654. if ($current_session == 0) {
  655. if ($details['lp_display_order'] == 1 && $max != 1) {
  656. $dsp_order .= Display::url(
  657. Display::return_icon('down.png', get_lang('MoveDown'), '', ICON_SIZE_SMALL),
  658. "lp_controller.php?".api_get_cidreq()."&action=move_lp_down&lp_id=$id"
  659. );
  660. } elseif ($current == $max - 1 && $max != 1) {
  661. $dsp_order .= Display::url(
  662. Display::return_icon('up.png', get_lang('MoveUp'), '', ICON_SIZE_SMALL),
  663. "lp_controller.php?".api_get_cidreq()."&action=move_lp_up&lp_id=$id"
  664. );
  665. } elseif ($max == 1) {
  666. $dsp_order = '';
  667. } else {
  668. $dsp_order .= Display::url(
  669. Display::return_icon('down.png', get_lang('MoveDown'), '', ICON_SIZE_SMALL),
  670. "lp_controller.php?".api_get_cidreq()."&action=move_lp_down&lp_id=$id"
  671. );
  672. $dsp_order .= Display::url(
  673. Display::return_icon('up.png', get_lang('MoveUp'), '', ICON_SIZE_SMALL),
  674. "lp_controller.php?".api_get_cidreq()."&action=move_lp_up&lp_id=$id"
  675. );
  676. }
  677. }
  678. if ($is_allowed_to_edit) {
  679. $start_time = $start_time;
  680. $end_time = $end_time;
  681. } else {
  682. $start_time = $end_time = '';
  683. }
  684. if (api_get_setting('gamification_mode') == 1) {
  685. if ($details['seriousgame_mode'] == 0) {
  686. $actionSeriousGame = Display::toolbarButton(
  687. null,
  688. api_get_self().'?'.api_get_cidreq()."&lp_id=$id&action=toggle_seriousgame",
  689. 'trophy',
  690. 'default',
  691. [
  692. 'class' => 'btn-xs',
  693. 'title' => get_lang('EnableGamificationMode'),
  694. ]
  695. );
  696. } else {
  697. $actionSeriousGame = Display::toolbarButton(
  698. null,
  699. api_get_self().'?'.api_get_cidreq()."&lp_id=$id&action=toggle_seriousgame",
  700. 'trophy',
  701. 'warning',
  702. [
  703. 'class' => 'btn-xs active',
  704. 'title' => get_lang('DisableGamificationMode'),
  705. ]
  706. );
  707. }
  708. }
  709. } else {
  710. // Student
  711. $export_icon = Display::url(
  712. Display::return_icon('pdf.png', get_lang('ExportToPDF'), '', ICON_SIZE_SMALL),
  713. api_get_self().'?'.api_get_cidreq()."&action=export_to_pdf&lp_id=$id"
  714. );
  715. }
  716. $hideScormExportLink = api_get_setting('hide_scorm_export_link');
  717. if ($hideScormExportLink === 'true') {
  718. $dsp_disk = null;
  719. }
  720. $hideScormCopyLink = api_get_setting('hide_scorm_copy_link');
  721. if ($hideScormCopyLink === 'true') {
  722. $copy = null;
  723. }
  724. $hideScormPdfLink = api_get_setting('hide_scorm_pdf_link');
  725. if ($hideScormPdfLink === 'true') {
  726. $export_icon = null;
  727. }
  728. $listData[] = [
  729. 'learnpath_icon' => $icon_learnpath,
  730. 'url_start' => $url_start_lp,
  731. 'title' => $my_title,
  732. 'session_image' => $session_img,
  733. 'extra' => $extra,
  734. 'start_time' => $start_time,
  735. 'end_time' => $end_time,
  736. 'dsp_progress' => $dsp_progress,
  737. 'action_build' => $dsp_build,
  738. 'action_edit' => $dsp_edit_lp,
  739. 'action_tracking' => $trackingAction,
  740. 'action_visible' => $dsp_visible,
  741. 'action_publish' => $dsp_publish,
  742. 'action_reinit' => $dsp_reinit,
  743. 'action_default_view' => $dsp_default_view,
  744. 'action_debug' => $dsp_debug,
  745. 'action_export' => $dsp_disk,
  746. 'action_copy' => $copy,
  747. 'action_auto_launch' => $lp_auto_launch_icon,
  748. 'action_pdf' => $export_icon,
  749. 'action_delete' => $dsp_delete,
  750. 'action_order' => $dsp_order,
  751. 'action_serious_game' => $actionSeriousGame,
  752. 'action_subscribe_users' => $subscribeUsers,
  753. ];
  754. $lpIsShown = true;
  755. // Counter for number of elements treated
  756. $current++;
  757. } // end foreach ($flat_list)
  758. }
  759. $data[] = [
  760. 'category' => $item,
  761. 'lp_list' => $listData
  762. ];
  763. }
  764. $template = new Template($nameTools);
  765. $template->assign('is_allowed_to_edit', $is_allowed_to_edit);
  766. $template->assign('is_invitee', api_is_invitee());
  767. $template->assign('actions', $actions);
  768. $template->assign('categories', $categories);
  769. $template->assign('message', $message);
  770. $template->assign('introduction_section', $introductionSection);
  771. $template->assign('data', $data);
  772. $template->assign('lp_is_shown', $lpIsShown);
  773. $templateName = $template->get_template('learnpath/list.tpl');
  774. $content = $template->fetch($templateName);
  775. $template->assign('content', $content);
  776. $template->display_one_col_template();
  777. learnpath::generate_learning_path_folder($courseInfo);
  778. // Deleting the objects
  779. Session::erase('oLP');
  780. Session::erase('lpobject');
  781. DocumentManager::removeGeneratedAudioTempFile();