lp_view.php 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645
  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. api_protect_course_script();
  25. if (isset($_REQUEST['origin']) && $_REQUEST['origin'] === 'learnpath') {
  26. $_REQUEST['origin'] = '';
  27. }
  28. // To prevent the template class
  29. $show_learnpath = true;
  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 (!empty($safe_id) && !empty($safe_item_id)) {
  276. $sql = 'SELECT start_date, exe_date, exe_result, exe_weighting, exe_exo_id, exe_duration
  277. FROM '.$TBL_TRACK_EXERCICES.'
  278. WHERE exe_id = '.$safe_exe_id;
  279. $res = Database::query($sql);
  280. $row_dates = Database::fetch_array($res);
  281. $duration = (int) $row_dates['exe_duration'];
  282. $score = (float) $row_dates['exe_result'];
  283. $max_score = (float) $row_dates['exe_weighting'];
  284. $sql = "UPDATE $TBL_LP_ITEM SET
  285. max_score = '$max_score'
  286. WHERE iid = $safe_item_id";
  287. Database::query($sql);
  288. $sql = "SELECT id FROM $TBL_LP_ITEM_VIEW
  289. WHERE
  290. c_id = $course_id AND
  291. lp_item_id = $safe_item_id AND
  292. lp_view_id = ".$lp->get_view_id()."
  293. ORDER BY id DESC
  294. LIMIT 1";
  295. $res_last_attempt = Database::query($sql);
  296. if (Database::num_rows($res_last_attempt) && !api_is_invitee()) {
  297. $row_last_attempt = Database::fetch_row($res_last_attempt);
  298. $lp_item_view_id = $row_last_attempt[0];
  299. $exercise = new Exercise(api_get_course_int_id());
  300. $exercise->read($row_dates['exe_exo_id']);
  301. $status = 'completed';
  302. if (!empty($exercise->pass_percentage)) {
  303. $status = 'failed';
  304. $success = ExerciseLib::isSuccessExerciseResult(
  305. $score,
  306. $max_score,
  307. $exercise->pass_percentage
  308. );
  309. if ($success) {
  310. $status = 'passed';
  311. }
  312. }
  313. $sql = "UPDATE $TBL_LP_ITEM_VIEW SET
  314. status = '$status',
  315. score = $score,
  316. total_time = $duration
  317. WHERE iid = $lp_item_view_id";
  318. if ($debug) {
  319. error_log($sql);
  320. }
  321. Database::query($sql);
  322. $sql = "UPDATE $TBL_TRACK_EXERCICES SET
  323. orig_lp_item_view_id = $lp_item_view_id
  324. WHERE exe_id = ".$safe_exe_id;
  325. Database::query($sql);
  326. }
  327. }
  328. if (intval($_GET['fb_type']) != EXERCISE_FEEDBACK_TYPE_END) {
  329. $src = 'blank.php?msg=exerciseFinished';
  330. } else {
  331. $src = api_get_path(WEB_CODE_PATH).'exercise/result.php?id='.$safe_exe_id.'&'.api_get_cidreq(true, true, 'learnpath');
  332. if ($debug) {
  333. error_log('Calling URL: '.$src);
  334. }
  335. }
  336. $autostart = 'false';
  337. }
  338. $lp->set_previous_item($lp_item_id);
  339. $nameTools = Security::remove_XSS($lp->get_name());
  340. $save_setting = api_get_setting('show_navigation_menu');
  341. global $_setting;
  342. $_setting['show_navigation_menu'] = 'false';
  343. $scorm_css_header = true;
  344. $lp_theme_css = $lp->get_theme();
  345. // Sets the css theme of the LP this call is also use at the frames (toc, nav, message).
  346. if ($lp->mode == 'fullscreen') {
  347. $htmlHeadXtra[] = "<script>
  348. window.open('$src','content_id','toolbar=0,location=0,status=0,scrollbars=1,resizable=1');
  349. </script>";
  350. }
  351. // Set flag to ensure lp_header.php is loaded by this script (flag is unset in lp_header.php).
  352. Session::write('loaded_lp_view', true);
  353. $display_none = '';
  354. $margin_left = '340px';
  355. // Media player code
  356. $display_mode = $lp->mode;
  357. $scorm_css_header = true;
  358. $lp_theme_css = $lp->get_theme();
  359. // Setting up the CSS theme if exists.
  360. if (!empty($lp_theme_css) && !empty($mycourselptheme) && $mycourselptheme != -1 && $mycourselptheme == 1) {
  361. global $lp_theme_css;
  362. } else {
  363. $lp_theme_css = $my_style;
  364. }
  365. $progress_bar = '';
  366. if (!api_is_invitee()) {
  367. $progress_bar = $lp->getProgressBar();
  368. }
  369. $navigation_bar = $lp->get_navigation_bar();
  370. $navigation_bar_bottom = $lp->get_navigation_bar('control-bottom', 'display:none');
  371. $mediaplayer = $lp->get_mediaplayer($lp->current, $autostart);
  372. $tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM);
  373. // Getting all the information about the item.
  374. $sql = "SELECT audio FROM $tbl_lp_item
  375. WHERE c_id = $course_id AND lp_id = ".$lp->lp_id;
  376. $res_media = Database::query($sql);
  377. $show_audioplayer = false;
  378. if (Database::num_rows($res_media) > 0) {
  379. while ($row_media = Database::fetch_array($res_media)) {
  380. if (!empty($row_media['audio'])) {
  381. $show_audioplayer = true;
  382. break;
  383. }
  384. }
  385. }
  386. $is_allowed_to_edit = api_is_allowed_to_edit(false, true, true, false);
  387. global $interbreadcrumb;
  388. if ($is_allowed_to_edit) {
  389. $interbreadcrumb[] = [
  390. 'url' => api_get_self().'?action=list&isStudentView=false&'.api_get_cidreq(true, true, 'course'),
  391. 'name' => get_lang('LearningPaths'),
  392. ];
  393. $interbreadcrumb[] = [
  394. 'url' => api_get_self()."?action=add_item&type=step&lp_id={$lp->lp_id}&isStudentView=false&".api_get_cidreq(true, true, 'course'),
  395. 'name' => $lp->get_name(),
  396. ];
  397. $interbreadcrumb[] = [
  398. 'url' => '#',
  399. 'name' => get_lang('Preview'),
  400. ];
  401. $buttonHomeUrl = 'lp_controller.php?'.api_get_cidreq(true, true, 'course').'&'.http_build_query([
  402. 'isStudentView' => 'false',
  403. 'action' => 'return_to_course_homepage',
  404. ]);
  405. } else {
  406. $buttonHomeUrl = 'lp_controller.php?'.api_get_cidreq(true, true, 'course').'&'.http_build_query([
  407. 'action' => 'return_to_course_homepage',
  408. ]);
  409. }
  410. $buttonHomeText = get_lang('CourseHomepageLink');
  411. $returnLink = api_get_course_setting('lp_return_link');
  412. switch ($returnLink) {
  413. case 1: // lp list
  414. $buttonHomeUrl .= '&redirectTo=lp_list';
  415. $buttonHomeText = get_lang('LearningPathList');
  416. break;
  417. case 2: // user portal
  418. $buttonHomeUrl .= '&redirectTo=my_courses';
  419. $buttonHomeText = get_lang('MyCourses');
  420. break;
  421. }
  422. $lpPreviewImagePath = Display::returnIconPath('unknown.png', ICON_SIZE_BIG);
  423. if ($lp->get_preview_image()) {
  424. $lpPreviewImagePath = $lp->get_preview_image_path();
  425. }
  426. if ($lp->current == $lp->get_last()) {
  427. $categories = Category::load(
  428. null,
  429. null,
  430. $course_code,
  431. null,
  432. null,
  433. $sessionId
  434. );
  435. if (!empty($categories)) {
  436. $gradebookEvaluations = $categories[0]->get_evaluations();
  437. $gradebookLinks = $categories[0]->get_links();
  438. if (count($gradebookEvaluations) === 0 &&
  439. count($gradebookLinks) === 1 &&
  440. $gradebookLinks[0]->get_type() == LINK_LEARNPATH &&
  441. $gradebookLinks[0]->get_ref_id() == $lp->lp_id
  442. ) {
  443. $gradebookMinScore = $categories[0]->getCertificateMinScore();
  444. $userScore = $gradebookLinks[0]->calc_score($user_id, 'best');
  445. if ($userScore[0] >= $gradebookMinScore) {
  446. Category::generateUserCertificate($categories[0]->get_id(), $user_id);
  447. }
  448. }
  449. }
  450. }
  451. $template = new Template('', false, false, true, true, false);
  452. $fixLinkSetting = api_get_configuration_value('lp_fix_embed_content');
  453. $fixLink = '';
  454. if ($fixLinkSetting) {
  455. $fixLink = '{type:"script", id:"_fr10", src:"'.api_get_path(WEB_LIBRARY_PATH).'javascript/fixlinks.js"}';
  456. }
  457. $template->assign('fix_link', $fixLink);
  458. $template->assign('glossary_tool_available_list', ['true', 'lp', 'exercise_and_lp']);
  459. // If the global gamification mode is enabled...
  460. $gamificationMode = api_get_setting('gamification_mode');
  461. // ...AND this learning path is set in gamification mode, then change the display
  462. $gamificationMode = $gamificationMode && $lp->seriousgame_mode;
  463. $template->assign('gamification_mode', $gamificationMode);
  464. $template->assign('glossary_extra_tools', api_get_setting('show_glossary_in_extra_tools'));
  465. $template->assign('show_glossary_in_documents', api_get_setting('show_glossary_in_documents'));
  466. $template->assign('jquery_web_path', api_get_jquery_web_path());
  467. $template->assign('jquery_ui_js_web_path', api_get_jquery_ui_js_web_path());
  468. $template->assign('jquery_ui_css_web_path', api_get_jquery_ui_css_web_path());
  469. $template->assign('is_allowed_to_edit', $is_allowed_to_edit);
  470. $template->assign('button_home_url', $buttonHomeUrl);
  471. $template->assign('button_home_text', $buttonHomeText);
  472. $template->assign('navigation_bar', $navigation_bar);
  473. $template->assign('progress_bar', $progress_bar);
  474. $template->assign('show_audio_player', $show_audioplayer);
  475. $template->assign('media_player', $mediaplayer);
  476. $template->assign('toc_list', $get_toc_list);
  477. $template->assign('teacher_toc_buttons', $get_teacher_buttons);
  478. $template->assign('iframe_src', $src);
  479. $template->assign('navigation_bar_bottom', $navigation_bar_bottom);
  480. $template->assign('show_left_column', $lp->getHideTableOfContents() == 0);
  481. if ($gamificationMode == 1) {
  482. $template->assign('gamification_stars', $lp->getCalculateStars($sessionId));
  483. $template->assign('gamification_points', $lp->getCalculateScore($sessionId));
  484. }
  485. $template->assign('lp_author', $lp->get_author());
  486. $lpMinTime = '';
  487. if (Tracking::minimumTimeAvailable(api_get_session_id(), api_get_course_int_id())) {
  488. // Calulate minimum and accumulated time
  489. $timeLp = $_SESSION['oLP']->getAccumulateWorkTime();
  490. $timeTotalCourse = $_SESSION['oLP']->getAccumulateWorkTimeTotalCourse();
  491. // Minimum connection percentage
  492. $perc = 100;
  493. // Time from the course
  494. $tc = $timeTotalCourse;
  495. // Percentage of the learning paths
  496. $pl = 0;
  497. if (!empty($timeTotalCourse)) {
  498. $pl = $timeLp / $timeTotalCourse;
  499. }
  500. // Minimum time for each learning path
  501. $time_min = intval($pl * $tc * $perc / 100);
  502. if ($_SESSION['oLP']->getAccumulateWorkTime() > 0) {
  503. $lpMinTime = '('.$time_min.' min)';
  504. }
  505. $lpTimeList = Tracking::getCalculateTime($user_id, api_get_course_int_id(), api_get_session_id());
  506. $lpTime = isset($lpTimeList[TOOL_LEARNPATH][$lp_id]) ? (int) $lpTimeList[TOOL_LEARNPATH][$lp_id] : 0;
  507. if ($lpTime >= ($time_min * 60)) {
  508. $time_progress_perc = '100%';
  509. $time_progress_value = 100;
  510. } else {
  511. $time_progress_value = intval(($lpTime * 100) / ($time_min * 60));
  512. $time_progress_perc = $time_progress_value.'%';
  513. }
  514. $template->assign('time_progress_perc', $time_progress_perc);
  515. $template->assign('time_progress_value', $time_progress_value);
  516. // Cronometro
  517. $hour = (intval($lpTime / 3600)) < 10 ? '0'.intval($lpTime / 3600) : intval($lpTime / 3600);
  518. $template->assign('hour', $hour);
  519. $template->assign('minute', date('i', $lpTime));
  520. $template->assign('second', date('s', $lpTime));
  521. $template->assign('hour_min', api_time_to_hms($timeLp * 60, '</div><div class="divider">:</div><div>'));
  522. }
  523. $template->assign('lp_accumulate_work_time', $lpMinTime);
  524. $template->assign('lp_mode', $lp->mode);
  525. $template->assign('lp_title_scorm', $lp->name);
  526. // ofaj
  527. $template->assign('lp_item_parents', $lp->getCurrentItemParentNames($lp->get_current_item_id()));
  528. // ofaj
  529. $template->assign('title_course', $lp->course_info['title']);
  530. if (api_get_configuration_value('lp_view_accordion') === true && $lpType == 1) {
  531. $template->assign('data_panel', $lp->getParentToc($get_toc_list));
  532. } else {
  533. $template->assign('data_list', $lp->getListArrayToc($get_toc_list));
  534. }
  535. $template->assign('lp_id', $lp->lp_id);
  536. $template->assign('lp_current_item_id', $lp->get_current_item_id());
  537. $template->assign('disable_js_in_lp_view', (int) api_get_configuration_value('disable_js_in_lp_view'));
  538. $template->assign(
  539. 'lp_preview_image',
  540. Display::img(
  541. $lpPreviewImagePath,
  542. $lp->name,
  543. [],
  544. ICON_SIZE_BIG
  545. )
  546. );
  547. $frameReady = Display::getFrameReadyBlock('#content_id, #content_id_blank');
  548. $template->assign('frame_ready', $frameReady);
  549. // Ofaj
  550. $template->assign('lp_id', $lp->lp_id);
  551. $template->assign('lp_current_item_id', $lp->get_current_item_id());
  552. $view = $template->get_template('learnpath/view.tpl');
  553. $content = $template->fetch($view);
  554. $template->assign('content', $content);
  555. $template->display_no_layout_template();
  556. // Restore a global setting.
  557. $_setting['show_navigation_menu'] = $save_setting;
  558. Session::write('oLP', $lp);
  559. if ($debug) {
  560. error_log(' ------- end lp_view.php ------');
  561. }