diff --git a/main/newscorm/learnpath.class.php b/main/newscorm/learnpath.class.php index 7cea75cbe9..0280860fd1 100644 --- a/main/newscorm/learnpath.class.php +++ b/main/newscorm/learnpath.class.php @@ -1497,7 +1497,7 @@ class learnpath { error_log('New LP - In learnpath::get_total_items_count_without_chapters()', 0); } $total = 0; - foreach ($this->items as $temp => $temp2) { + foreach ($this->items as $temp2) { if (!in_array($temp2->get_type(), array ( 'dokeos_chapter', 'chapter', @@ -1536,6 +1536,7 @@ class learnpath { !empty($this->items[$this->last_item_seen]) && $this->items[$this->last_item_seen]->get_type() != 'dir' && $this->items[$this->last_item_seen]->get_type() != 'dokeos_chapter' + //with this change (below) the LP will NOT go to the next item, it will take lp item we left //&& !$this->items[$this->last_item_seen]->is_done() ) { @@ -2693,7 +2694,7 @@ class learnpath { * Uses the table generated by get_toc() and returns an HTML-formatted string ready to display * @return string HTML TOC ready to display */ - public function get_html_toc() { + public function get_html_toc($toc_list = null) { $course_id = api_get_course_int_id(); $course_code = api_get_course_id(); $is_allowed_to_edit = api_is_allowed_to_edit(null, true); @@ -2704,7 +2705,9 @@ class learnpath { if ($this->debug > 0) { error_log('New LP - In learnpath::get_html_toc()', 0); } - $list = $this->get_toc(); + if (empty($toc_list)) { + $toc_list = $this->get_toc(); + } //echo $this->current; //$parent = $this->items[$this->current]->get_parent(); //if (empty($parent)) { $parent = $this->ordered_items[$this->items[$this->current]->get_previous_index()]; } @@ -2741,7 +2744,7 @@ class learnpath { $color_counter = 0; $i = 0; - foreach ($list as $item) { + foreach ($toc_list as $item) { if ($this->debug > 2) { //error_log('New LP - learnpath::get_html_toc(): using item ' . $item['id'], 0); } @@ -2795,7 +2798,7 @@ class learnpath { $title = Security::remove_XSS($title); if ($item['type'] != 'dokeos_chapter' && $item['type'] != 'dir' && $item['type'] != 'dokeos_module') { //$html .= "".$title."" ; - $url = $this->get_link('http', $item['id'], $list); + $url = $this->get_link('http', $item['id'], $toc_list); //$html .= ''.$title.'' ; //$html .= ''.$title.'' ; @@ -2902,7 +2905,7 @@ class learnpath { $item_id = $this->get_current_item_id(); } - if (empty ($item_id)) { + if (empty($item_id)) { if ($this->debug > 2) { error_log('New LP - In learnpath::get_link() - no current item id found in learnpath object', 0); } @@ -2955,7 +2958,12 @@ class learnpath { if (in_array($lp_item_type, array('quiz', 'document', 'link', 'forum', 'thread', 'student_publication'))) { $lp_type = 1; } - + + if ($this->debug > 2) { + error_log('New LP - In learnpath::get_link() - $lp_type ' . $lp_type, 0); + error_log('New LP - In learnpath::get_link() - $lp_item_type ' . $lp_item_type, 0); + } + // Now go through the specific cases to get the end of the path. // @todo Use constants instead of int values. @@ -2965,8 +2973,9 @@ class learnpath { $file = 'lp_content.php?type=dir'; } else { require_once 'resourcelinker.inc.php'; - $file = rl_get_resource_link_for_learnpath(api_get_course_id(), $this->get_id(), $item_id); - + + $file = rl_get_resource_link_for_learnpath(api_get_course_id(), $this->get_id(), $item_id); + if ($this->debug > 0) { error_log('rl_get_resource_link_for_learnpath - file: ' . $file, 0); } @@ -2983,9 +2992,15 @@ class learnpath { $lp_view_id = $this->get_view_id(); $prevent_reinit = $this->items[$this->current]->get_prevent_reinit(); - if (empty($provided_toc)) { + if (empty($provided_toc)) { + if ($this->debug > 0) { + error_log('In learnpath::get_link() Loading get_toc ', 0); + } $list = $this->get_toc(); } else { + if ($this->debug > 0) { + error_log('In learnpath::get_link() Loading get_toc from "cache" ', 0); + } $list = $provided_toc; } diff --git a/main/newscorm/lp_view.php b/main/newscorm/lp_view.php index 46f06f29be..52516878d3 100644 --- a/main/newscorm/lp_view.php +++ b/main/newscorm/lp_view.php @@ -121,16 +121,30 @@ $htmlHeadXtra[] = ''; $prereq_check = $_SESSION['oLP']->prerequisites_match($lp_item_id); if ($prereq_check === true) { - $src = $_SESSION['oLP']->get_link('http', $lp_item_id); + $src = $_SESSION['oLP']->get_link('http', $lp_item_id, $get_toc_list); //Prevents FF 3.6 + Adobe Reader 9 bug see BT#794 when calling a pdf file in a LP. $file_info = parse_url($src); @@ -150,7 +164,7 @@ if (!isset($src)) { $htmlHeadXtra[] = ''; $prereq_check = $_SESSION['oLP']->prerequisites_match($lp_item_id); if ($prereq_check === true) { - $src = $_SESSION['oLP']->get_link('http',$lp_item_id); + $src = $_SESSION['oLP']->get_link('http',$lp_item_id, $get_toc_list); $_SESSION['oLP']->start_current_item(); // starts time counter manually if asset } else { $src = 'blank.php?error=prerequisites'; @@ -162,7 +176,7 @@ if (!isset($src)) { $htmlHeadXtra[] = ''; $prereq_check = $_SESSION['oLP']->prerequisites_match($lp_item_id); if ($prereq_check === true) { - $src = $_SESSION['oLP']->get_link('http',$lp_item_id); + $src = $_SESSION['oLP']->get_link('http',$lp_item_id, $get_toc_list); $_SESSION['oLP']->start_current_item(); // starts time counter manually if asset } else { $src = 'blank.php'; @@ -173,23 +187,14 @@ if (!isset($src)) { } } -$list = $_SESSION['oLP']->get_toc(); -$type_quiz = false; - -foreach($list as $toc) { - if ($toc['id'] == $lp_item_id && ($toc['type']=='quiz')) { - $type_quiz = true; - } -} - $autostart = 'true'; // Update status, total_time from lp_item_view table when you finish the exercises in learning path. if ($debug) { error_log('$type_quiz: '.$type_quiz); - error_log('$_REQUEST[exeId]: '.$_REQUEST['exeId']); + error_log('$_REQUEST[exeId]: '.intval($_REQUEST['exeId'])); error_log('$lp_id: '.$lp_id); - error_log('$_GET[lp_item_id]: '.$_GET['lp_item_id']); + error_log('$_GET[lp_item_id]: '.intval($_GET['lp_item_id'])); } if ($type_quiz && !empty($_REQUEST['exeId']) && isset($lp_id) && isset($_GET['lp_item_id'])) { @@ -374,7 +379,7 @@ if (Database::num_rows($res_media) > 0) {
- get_html_toc(); ?> + get_html_toc($get_toc_list); ?> scorm_debug)) { //only show log ?>