lp_list.php 34 KB

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