lp_list.php 39 KB

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