lp_view.php 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639
  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 needed anymore, 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> - redesign
  13. * @author Denes Nagy, principal author
  14. * @author Isthvan Mandak, several new features
  15. * @author Roan Embrechts, code improvements and refactoring
  16. */
  17. $use_anonymous = true;
  18. $this_section = SECTION_COURSES;
  19. if ($lp_controller_touched != 1) {
  20. header('Location: lp_controller.php?action=view&item_id='.intval($_REQUEST['item_id']));
  21. exit;
  22. }
  23. require_once __DIR__.'/../inc/global.inc.php';
  24. if (isset($_REQUEST['origin']) && $_REQUEST['origin'] === 'learnpath') {
  25. $_REQUEST['origin'] = '';
  26. }
  27. //To prevent the template class
  28. $show_learnpath = true;
  29. api_protect_course_script();
  30. $lp_id = !empty($_GET['lp_id']) ? (int) $_GET['lp_id'] : 0;
  31. $sessionId = api_get_session_id();
  32. $course_code = api_get_course_id();
  33. $course_id = api_get_course_int_id();
  34. $user_id = api_get_user_id();
  35. // Check if the learning path is visible for student - (LP requisites)
  36. if (!api_is_platform_admin()) {
  37. if (!api_is_allowed_to_edit(null, true, false, false) &&
  38. !learnpath::is_lp_visible_for_student($lp_id, api_get_user_id())
  39. ) {
  40. api_not_allowed(true);
  41. }
  42. }
  43. // Checking visibility (eye icon)
  44. $visibility = api_get_item_visibility(
  45. api_get_course_info(),
  46. TOOL_LEARNPATH,
  47. $lp_id,
  48. $action,
  49. api_get_user_id(),
  50. $sessionId
  51. );
  52. if ($visibility === 0 &&
  53. !api_is_allowed_to_edit(false, true, false, false)
  54. ) {
  55. api_not_allowed(true);
  56. }
  57. /** @var learnpath $lp */
  58. $lp = Session::read('oLP');
  59. if (empty($lp)) {
  60. api_not_allowed(true);
  61. }
  62. $debug = 0;
  63. if ($debug) {
  64. error_log('------ Entering lp_view.php -------');
  65. }
  66. $lp_item_id = $lp->get_current_item_id();
  67. $lpType = $lp->get_type();
  68. if (!$is_allowed_to_edit) {
  69. $categoryId = $lp->getCategoryId();
  70. $em = Database::getManager();
  71. if (!empty($categoryId)) {
  72. /** @var CLpCategory $category */
  73. $category = $em->getRepository('ChamiloCourseBundle:CLpCategory')->find($categoryId);
  74. $block = false;
  75. if ($category) {
  76. $user = UserManager::getRepository()->find($user_id);
  77. $users = $category->getUsers();
  78. if (!empty($users) && $users->count() > 0) {
  79. if ($user && !$category->hasUserAdded($user)) {
  80. $block = true;
  81. }
  82. }
  83. $isVisible = learnpath::categoryIsVisibleForStudent(
  84. $category,
  85. $user
  86. );
  87. if ($isVisible) {
  88. $block = false;
  89. }
  90. if ($block) {
  91. api_not_allowed(true);
  92. }
  93. }
  94. }
  95. }
  96. $platform_theme = api_get_setting('stylesheets');
  97. $my_style = $platform_theme;
  98. $ajaxUrl = api_get_path(WEB_AJAX_PATH).'lp.ajax.php?a=get_item_prerequisites&'.api_get_cidreq();
  99. $htmlHeadXtra[] = '<script>
  100. <!--
  101. var jQueryFrameReadyConfigPath = \''.api_get_jquery_web_path().'\';
  102. -->
  103. </script>';
  104. $htmlHeadXtra[] = api_get_css_asset('qtip2/jquery.qtip.min.css');
  105. $htmlHeadXtra[] = api_get_asset('qtip2/jquery.qtip.min.js');
  106. $htmlHeadXtra[] = '<script type="text/javascript" src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery.frameready.js"></script>';
  107. $htmlHeadXtra[] = '<script>
  108. $(function() {
  109. $("div#log_content_cleaner").bind("click", function() {
  110. $("div#log_content").empty();
  111. });
  112. });
  113. var chamilo_xajax_handler = window.oxajax;
  114. </script>';
  115. $allowLpItemTip = api_get_configuration_value('hide_accessibility_label_on_lp_item') === false;
  116. if ($allowLpItemTip) {
  117. $htmlHeadXtra[] = '<script>
  118. $(function() {
  119. $(".scorm_item_normal").qtip({
  120. content: {
  121. text: function(event, api) {
  122. var item = $(this);
  123. var itemId = $(this).attr("id");
  124. itemId = itemId.replace("toc_", "");
  125. var textToShow = "";
  126. $.ajax({
  127. type: "GET",
  128. url: "'.$ajaxUrl.'&item_id="+ itemId,
  129. async: false
  130. })
  131. .then(function(content) {
  132. if (content == 1) {
  133. textToShow = "'.addslashes(get_lang('LPItemCanBeAccessed')).'";
  134. api.set("style.classes", "qtip-green qtip-shadow");
  135. } else {
  136. textToShow = content;
  137. api.set("style.classes", "qtip-red qtip-shadow");
  138. }
  139. return textToShow;
  140. });
  141. return textToShow;
  142. }
  143. }
  144. });
  145. });
  146. </script>';
  147. }
  148. // Impress js
  149. if ($lp->mode == 'impress') {
  150. $lp_id = $lp->get_id();
  151. $url = api_get_path(WEB_CODE_PATH)."lp/lp_impress.php?lp_id=$lp_id&".api_get_cidreq();
  152. header("Location: $url");
  153. exit;
  154. }
  155. // Prepare variables for the test tool (just in case) - honestly, this should disappear later on.
  156. Session::write('scorm_view_id', $lp->get_view_id());
  157. Session::write('scorm_item_id', $lp_item_id);
  158. // Reinit exercises variables to avoid spacename clashes (see exercise tool)
  159. if (isset($exerciseResult) || isset($_SESSION['exerciseResult'])) {
  160. Session::erase('exerciseResult');
  161. Session::erase('objExercise');
  162. Session::erase('questionList');
  163. Session::erase('duration_time_previous');
  164. Session::erase('duration_time');
  165. }
  166. // additional APIs
  167. $htmlHeadXtra[] = '<script>
  168. chamilo_courseCode = "'.$course_code.'";
  169. </script>';
  170. // Document API
  171. $htmlHeadXtra[] = '<script src="js/documentapi.js" type="text/javascript" language="javascript"></script>';
  172. // Storage API
  173. $htmlHeadXtra[] = '<script>
  174. var sv_user = \''.api_get_user_id().'\';
  175. var sv_course = chamilo_courseCode;
  176. var sv_sco = \''.$lp_id.'\';
  177. </script>'; // FIXME fetch sco and userid from a more reliable source directly in sotrageapi.js
  178. $htmlHeadXtra[] = '<script type="text/javascript" src="js/storageapi.js"></script>';
  179. /**
  180. * Get a link to the corresponding document.
  181. */
  182. if ($debug) {
  183. error_log(" src: $src ");
  184. error_log(" lp_type: $lpType ");
  185. }
  186. $get_toc_list = $lp->get_toc();
  187. $get_teacher_buttons = $lp->get_teacher_toc_buttons();
  188. $type_quiz = false;
  189. foreach ($get_toc_list as $toc) {
  190. if ($toc['id'] == $lp_item_id && $toc['type'] == 'quiz') {
  191. $type_quiz = true;
  192. }
  193. }
  194. if (!isset($src)) {
  195. $src = null;
  196. switch ($lpType) {
  197. case 1:
  198. $lp->stop_previous_item();
  199. $htmlHeadXtra[] = '<script src="scorm_api.php" type="text/javascript" language="javascript"></script>';
  200. $preReqCheck = $lp->prerequisites_match($lp_item_id);
  201. if ($preReqCheck === true) {
  202. $src = $lp->get_link(
  203. 'http',
  204. $lp_item_id,
  205. $get_toc_list
  206. );
  207. // Prevents FF 3.6 + Adobe Reader 9 bug see BT#794 when calling a pdf file in a LP.
  208. $file_info = parse_url($src);
  209. if (isset($file_info['path'])) {
  210. $file_info = pathinfo($file_info['path']);
  211. }
  212. if (isset($file_info['extension']) &&
  213. api_strtolower(substr($file_info['extension'], 0, 3)) == 'pdf'
  214. ) {
  215. $src = api_get_path(WEB_CODE_PATH).'lp/lp_view_item.php?lp_item_id='.$lp_item_id.'&'.api_get_cidreq();
  216. }
  217. $src = $lp->fixBlockedLinks($src);
  218. $lp->start_current_item(); // starts time counter manually if asset
  219. } else {
  220. $src = 'blank.php?error=prerequisites';
  221. }
  222. break;
  223. case 2:
  224. // save old if asset
  225. $lp->stop_previous_item(); // save status manually if asset
  226. $htmlHeadXtra[] = '<script src="scorm_api.php" type="text/javascript" language="javascript"></script>';
  227. $preReqCheck = $lp->prerequisites_match($lp_item_id);
  228. if ($preReqCheck === true) {
  229. $src = $lp->get_link('http', $lp_item_id, $get_toc_list);
  230. $lp->start_current_item(); // starts time counter manually if asset
  231. } else {
  232. $src = 'blank.php?error=prerequisites';
  233. }
  234. break;
  235. case 3:
  236. // aicc
  237. $lp->stop_previous_item(); // save status manually if asset
  238. $htmlHeadXtra[] = '<script src="'.$lp->get_js_lib().'" type="text/javascript" language="javascript"></script>';
  239. $preReqCheck = $lp->prerequisites_match($lp_item_id);
  240. if ($preReqCheck === true) {
  241. $src = $lp->get_link(
  242. 'http',
  243. $lp_item_id,
  244. $get_toc_list
  245. );
  246. $lp->start_current_item(); // starts time counter manually if asset
  247. } else {
  248. $src = 'blank.php';
  249. }
  250. break;
  251. case 4:
  252. break;
  253. }
  254. }
  255. $autostart = 'true';
  256. // Update status, total_time from lp_item_view table when you finish the exercises in learning path.
  257. if ($debug) {
  258. error_log('$type_quiz: '.$type_quiz);
  259. error_log('$_REQUEST[exeId]: '.intval($_REQUEST['exeId']));
  260. error_log('$lp_id: '.$lp_id);
  261. error_log('$_GET[lp_item_id]: '.intval($_GET['lp_item_id']));
  262. }
  263. if (!empty($_REQUEST['exeId']) &&
  264. isset($lp_id) &&
  265. isset($_GET['lp_item_id'])
  266. ) {
  267. global $src;
  268. $lp->items[$lp->current]->write_to_db();
  269. $TBL_TRACK_EXERCICES = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
  270. $TBL_LP_ITEM_VIEW = Database::get_course_table(TABLE_LP_ITEM_VIEW);
  271. $TBL_LP_ITEM = Database::get_course_table(TABLE_LP_ITEM);
  272. $safe_item_id = (int) $_GET['lp_item_id'];
  273. $safe_id = $lp_id;
  274. $safe_exe_id = (int) $_REQUEST['exeId'];
  275. if ($safe_id == strval(intval($safe_id)) &&
  276. $safe_item_id == strval(intval($safe_item_id))
  277. ) {
  278. $sql = 'SELECT start_date, exe_date, exe_result, exe_weighting, exe_exo_id, exe_duration
  279. FROM '.$TBL_TRACK_EXERCICES.'
  280. WHERE exe_id = '.$safe_exe_id;
  281. $res = Database::query($sql);
  282. $row_dates = Database::fetch_array($res);
  283. $duration = (int) $row_dates['exe_duration'];
  284. $score = (float) $row_dates['exe_result'];
  285. $max_score = (float) $row_dates['exe_weighting'];
  286. $sql = "UPDATE $TBL_LP_ITEM SET
  287. max_score = '$max_score'
  288. WHERE iid = $safe_item_id";
  289. Database::query($sql);
  290. $sql = "SELECT id FROM $TBL_LP_ITEM_VIEW
  291. WHERE
  292. c_id = $course_id AND
  293. lp_item_id = $safe_item_id AND
  294. lp_view_id = ".$lp->lp_view_id."
  295. ORDER BY id DESC
  296. LIMIT 1";
  297. $res_last_attempt = Database::query($sql);
  298. if (Database::num_rows($res_last_attempt) && !api_is_invitee()) {
  299. $row_last_attempt = Database::fetch_row($res_last_attempt);
  300. $lp_item_view_id = $row_last_attempt[0];
  301. $exercise = new Exercise(api_get_course_int_id());
  302. $exercise->read($row_dates['exe_exo_id']);
  303. $status = 'completed';
  304. if (!empty($exercise->pass_percentage)) {
  305. $status = 'failed';
  306. $success = ExerciseLib::isSuccessExerciseResult(
  307. $score,
  308. $max_score,
  309. $exercise->pass_percentage
  310. );
  311. if ($success) {
  312. $status = 'passed';
  313. }
  314. }
  315. $sql = "UPDATE $TBL_LP_ITEM_VIEW SET
  316. status = '$status',
  317. score = $score,
  318. total_time = $duration
  319. WHERE iid = $lp_item_view_id";
  320. if ($debug) {
  321. error_log($sql);
  322. }
  323. Database::query($sql);
  324. $sql = "UPDATE $TBL_TRACK_EXERCICES SET
  325. orig_lp_item_view_id = $lp_item_view_id
  326. WHERE exe_id = ".$safe_exe_id;
  327. Database::query($sql);
  328. }
  329. }
  330. if (intval($_GET['fb_type']) > 0) {
  331. $src = 'blank.php?msg=exerciseFinished';
  332. } else {
  333. $src = api_get_path(WEB_CODE_PATH).'exercise/result.php?id='.$safe_exe_id.'&'.api_get_cidreq(true, true, 'learnpath');
  334. if ($debug) {
  335. error_log('Calling URL: '.$src);
  336. }
  337. }
  338. $autostart = 'false';
  339. }
  340. $lp->set_previous_item($lp_item_id);
  341. $nameTools = Security::remove_XSS($lp->get_name());
  342. $save_setting = api_get_setting('show_navigation_menu');
  343. global $_setting;
  344. $_setting['show_navigation_menu'] = 'false';
  345. $scorm_css_header = true;
  346. $lp_theme_css = $lp->get_theme();
  347. // Sets the css theme of the LP this call is also use at the frames (toc, nav, message).
  348. if ($lp->mode == 'fullscreen') {
  349. $htmlHeadXtra[] = "<script>
  350. window.open('$src','content_id','toolbar=0,location=0,status=0,scrollbars=1,resizable=1');
  351. </script>";
  352. }
  353. // Set flag to ensure lp_header.php is loaded by this script (flag is unset in lp_header.php).
  354. Session::write('loaded_lp_view', true);
  355. $display_none = '';
  356. $margin_left = '340px';
  357. // Media player code
  358. $display_mode = $lp->mode;
  359. $scorm_css_header = true;
  360. $lp_theme_css = $lp->get_theme();
  361. // Setting up the CSS theme if exists.
  362. if (!empty($lp_theme_css) && !empty($mycourselptheme) && $mycourselptheme != -1 && $mycourselptheme == 1) {
  363. global $lp_theme_css;
  364. } else {
  365. $lp_theme_css = $my_style;
  366. }
  367. $progress_bar = '';
  368. if (!api_is_invitee()) {
  369. $progress_bar = $lp->getProgressBar();
  370. }
  371. $navigation_bar = $lp->get_navigation_bar();
  372. $navigation_bar_bottom = $lp->get_navigation_bar('control-bottom', 'display:none');
  373. $mediaplayer = $lp->get_mediaplayer($lp->current, $autostart);
  374. $tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM);
  375. // Getting all the information about the item.
  376. $sql = "SELECT audio FROM $tbl_lp_item
  377. WHERE c_id = $course_id AND lp_id = ".$lp->lp_id;
  378. $res_media = Database::query($sql);
  379. $show_audioplayer = false;
  380. if (Database::num_rows($res_media) > 0) {
  381. while ($row_media = Database::fetch_array($res_media)) {
  382. if (!empty($row_media['audio'])) {
  383. $show_audioplayer = true;
  384. break;
  385. }
  386. }
  387. }
  388. $is_allowed_to_edit = api_is_allowed_to_edit(false, true, true, false);
  389. global $interbreadcrumb;
  390. if ($is_allowed_to_edit) {
  391. $interbreadcrumb[] = [
  392. 'url' => api_get_self().'?action=list&isStudentView=false&'.api_get_cidreq(true, true, 'course'),
  393. 'name' => get_lang('LearningPaths'),
  394. ];
  395. $interbreadcrumb[] = [
  396. 'url' => api_get_self()."?action=add_item&type=step&lp_id={$lp->lp_id}&isStudentView=false&".api_get_cidreq(true, true, 'course'),
  397. 'name' => $lp->get_name(),
  398. ];
  399. $interbreadcrumb[] = [
  400. 'url' => '#',
  401. 'name' => get_lang('Preview'),
  402. ];
  403. $buttonHomeUrl = 'lp_controller.php?'.api_get_cidreq(true, true, 'course').'&'.http_build_query([
  404. 'isStudentView' => 'false',
  405. 'action' => 'return_to_course_homepage',
  406. ]);
  407. } else {
  408. $buttonHomeUrl = 'lp_controller.php?'.api_get_cidreq(true, true, 'course').'&'.http_build_query([
  409. 'action' => 'return_to_course_homepage',
  410. ]);
  411. }
  412. $buttonHomeText = get_lang('CourseHomepageLink');
  413. $returnLink = api_get_course_setting('lp_return_link');
  414. switch ($returnLink) {
  415. case 1: // lp list
  416. $buttonHomeUrl .= '&redirectTo=lp_list';
  417. $buttonHomeText = get_lang('LearningPathList');
  418. break;
  419. case 2: // user portal
  420. $buttonHomeUrl .= '&redirectTo=my_courses';
  421. $buttonHomeText = get_lang('MyCourses');
  422. break;
  423. }
  424. $lpPreviewImagePath = Display::returnIconPath('unknown.png', ICON_SIZE_BIG);
  425. if ($lp->get_preview_image()) {
  426. $lpPreviewImagePath = $lp->get_preview_image_path();
  427. }
  428. if ($lp->current == $lp->get_last()) {
  429. $categories = Category::load(
  430. null,
  431. null,
  432. $course_code,
  433. null,
  434. null,
  435. $sessionId
  436. );
  437. if (!empty($categories)) {
  438. $gradebookEvaluations = $categories[0]->get_evaluations();
  439. $gradebookLinks = $categories[0]->get_links();
  440. if (count($gradebookEvaluations) === 0 &&
  441. count($gradebookLinks) === 1 &&
  442. $gradebookLinks[0]->get_type() == LINK_LEARNPATH &&
  443. $gradebookLinks[0]->get_ref_id() == $lp->lp_id
  444. ) {
  445. $gradebookMinScore = $categories[0]->getCertificateMinScore();
  446. $userScore = $gradebookLinks[0]->calc_score($user_id, 'best');
  447. if ($userScore[0] >= $gradebookMinScore) {
  448. Category::generateUserCertificate($categories[0]->get_id(), $user_id);
  449. }
  450. }
  451. }
  452. }
  453. $template = new Template('', false, false, true, true, false);
  454. $fixLinkSetting = api_get_configuration_value('lp_fix_embed_content');
  455. $fixLink = '';
  456. if ($fixLinkSetting) {
  457. $fixLink = '{type:"script", id:"_fr10", src:"'.api_get_path(WEB_LIBRARY_PATH).'javascript/fixlinks.js"}';
  458. }
  459. $template->assign('fix_link', $fixLink);
  460. $template->assign('glossary_tool_available_list', ['true', 'lp', 'exercise_and_lp']);
  461. // If the global gamification mode is enabled...
  462. $gamificationMode = api_get_setting('gamification_mode');
  463. // ...AND this learning path is set in gamification mode, then change the display
  464. $gamificationMode = $gamificationMode && $lp->seriousgame_mode;
  465. $template->assign('gamification_mode', $gamificationMode);
  466. $template->assign('glossary_extra_tools', api_get_setting('show_glossary_in_extra_tools'));
  467. $template->assign('show_glossary_in_documents', api_get_setting('show_glossary_in_documents'));
  468. $template->assign('jquery_web_path', api_get_jquery_web_path());
  469. $template->assign('jquery_ui_js_web_path', api_get_jquery_ui_js_web_path());
  470. $template->assign('jquery_ui_css_web_path', api_get_jquery_ui_css_web_path());
  471. $template->assign('is_allowed_to_edit', $is_allowed_to_edit);
  472. $template->assign('button_home_url', $buttonHomeUrl);
  473. $template->assign('button_home_text', $buttonHomeText);
  474. $template->assign('navigation_bar', $navigation_bar);
  475. $template->assign('progress_bar', $progress_bar);
  476. $template->assign('show_audio_player', $show_audioplayer);
  477. $template->assign('media_player', $mediaplayer);
  478. $template->assign('toc_list', $get_toc_list);
  479. $template->assign('teacher_toc_buttons', $get_teacher_buttons);
  480. $template->assign('iframe_src', $src);
  481. $template->assign('navigation_bar_bottom', $navigation_bar_bottom);
  482. $template->assign('show_left_column', $lp->getHideTableOfContents() == 0);
  483. if ($gamificationMode == 1) {
  484. $template->assign('gamification_stars', $lp->getCalculateStars($sessionId));
  485. $template->assign('gamification_points', $lp->getCalculateScore($sessionId));
  486. }
  487. $template->assign('lp_author', $lp->get_author());
  488. $lpMinTime = '';
  489. if (Tracking::minimunTimeAvailable(api_get_session_id(), api_get_course_int_id())) {
  490. // Calulate minimum and accumulated time
  491. $timeLp = $_SESSION['oLP']->getAccumulateWorkTime();
  492. $timeTotalCourse = $_SESSION['oLP']->getAccumulateWorkTimeTotalCourse();
  493. // Minimum connection percentage
  494. $perc = 100;
  495. // Time from the course
  496. $tc = $timeTotalCourse;
  497. // Percentage of the learning paths
  498. $pl = 0;
  499. if (!empty($timeTotalCourse)) {
  500. $pl = $timeLp / $timeTotalCourse;
  501. }
  502. // Minimum time for each learning path
  503. $time_min = intval($pl * $tc * $perc / 100);
  504. if ($_SESSION['oLP']->getAccumulateWorkTime() > 0) {
  505. $lpMinTime = '('.$time_min.' min)';
  506. }
  507. $lpTimeList = Tracking::getCalculateTime($user_id, api_get_course_int_id(), api_get_session_id());
  508. $lpTime = isset($lpTimeList[TOOL_LEARNPATH][$lp_id]) ? (int) $lpTimeList[TOOL_LEARNPATH][$lp_id] : 0;
  509. if ($lpTime >= ($time_min * 60)) {
  510. $time_progress_perc = '100%';
  511. $time_progress_value = 100;
  512. } else {
  513. $time_progress_value = intval(($lpTime * 100) / ($time_min * 60));
  514. $time_progress_perc = $time_progress_value.'%';
  515. }
  516. $template->assign('time_progress_perc', $time_progress_perc);
  517. $template->assign('time_progress_value', $time_progress_value);
  518. // Cronometro
  519. $hour = (intval($lpTime / 3600)) < 10 ? '0'.intval($lpTime / 3600) : intval($lpTime / 3600);
  520. $template->assign('hour', $hour);
  521. $template->assign('minute', date('i', $lpTime));
  522. $template->assign('second', date('s', $lpTime));
  523. $template->assign('hour_min', api_time_to_hms($timeLp * 60, '</div><div class="divider">:</div><div>'));
  524. }
  525. $template->assign('lp_accumulate_work_time', $lpMinTime);
  526. $template->assign('lp_mode', $lp->mode);
  527. $template->assign('lp_title_scorm', $lp->name);
  528. if (api_get_configuration_value('lp_view_accordion') === true && $lpType == 1) {
  529. $template->assign('data_panel', $lp->getParentToc($get_toc_list));
  530. } else {
  531. $template->assign('data_list', $lp->getListArrayToc($get_toc_list));
  532. }
  533. $template->assign('lp_id', $lp->lp_id);
  534. $template->assign('lp_current_item_id', $lp->get_current_item_id());
  535. $template->assign('disable_js_in_lp_view', (int) api_get_configuration_value('disable_js_in_lp_view'));
  536. $template->assign(
  537. 'lp_preview_image',
  538. Display::img(
  539. $lpPreviewImagePath,
  540. $lp->name,
  541. [],
  542. ICON_SIZE_BIG
  543. )
  544. );
  545. $frameReady = Display::getFrameReadyBlock('#content_id, #content_id_blank');
  546. $template->assign('frame_ready', $frameReady);
  547. $view = $template->get_template('learnpath/view.tpl');
  548. $content = $template->fetch($view);
  549. $template->assign('content', $content);
  550. $template->display_no_layout_template();
  551. // Restore a global setting.
  552. $_setting['show_navigation_menu'] = $save_setting;
  553. Session::write('oLP', $lp);
  554. if ($debug) {
  555. error_log(' ------- end lp_view.php ------');
  556. }