diff --git a/main/inc/ajax/lp.ajax.php b/main/inc/ajax/lp.ajax.php index a281ed06d9..05dc8e3a96 100755 --- a/main/inc/ajax/lp.ajax.php +++ b/main/inc/ajax/lp.ajax.php @@ -8,12 +8,17 @@ use ChamiloSession as Session; */ require_once __DIR__.'/../global.inc.php'; api_protect_course_script(true); -$action = $_REQUEST['a']; + +$debug = false; +$action = isset($_REQUEST['a']) ? $_REQUEST['a'] : ''; $course_id = api_get_course_int_id(); -$tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM); $sessionId = api_get_session_id(); +if ($debug) { + error_log('----------lp.ajax-------------- action '.$action); +} + switch ($action) { case 'get_documents': $courseInfo = api_get_course_info(); @@ -102,6 +107,8 @@ switch ($action) { } } + $table = Database::get_course_table(TABLE_LP_ITEM); + foreach ($LP_item_list->list as $LP_item) { $params = []; $params['display_order'] = $LP_item->display_order; @@ -110,7 +117,7 @@ switch ($action) { $params['parent_item_id'] = $LP_item->parent_item_id; Database::update( - $tbl_lp_item, + $table, $params, [ 'id = ? AND c_id = ? ' => [ diff --git a/main/lp/learnpathItem.class.php b/main/lp/learnpathItem.class.php index 406296895a..b8203f7e30 100755 --- a/main/lp/learnpathItem.class.php +++ b/main/lp/learnpathItem.class.php @@ -2015,6 +2015,8 @@ class learnpathItem /** * Opens/launches the item. Initialises runtime values. * + * @param bool $allow_new_attempt + * * @return bool true on success, false on failure */ public function open($allow_new_attempt = false) @@ -4609,4 +4611,12 @@ class learnpathItem return true; } + + /** + * @return int + */ + public function getLastScormSessionTime() + { + return $this->last_scorm_session_time; + } } diff --git a/main/lp/lp_ajax_initialize.php b/main/lp/lp_ajax_initialize.php index 00a1cc96d4..c1d26ecb7f 100755 --- a/main/lp/lp_ajax_initialize.php +++ b/main/lp/lp_ajax_initialize.php @@ -28,10 +28,10 @@ require_once __DIR__.'/../inc/global.inc.php'; */ function initialize_item($lp_id, $user_id, $view_id, $next_item) { - global $debug; + $debug = 0; $return = ''; - if ($debug > 0) { - error_log('In initialize_item('.$lp_id.','.$user_id.','.$view_id.','.$next_item.')', 0); + if ($debug) { + error_log('In initialize_item('.$lp_id.','.$user_id.','.$view_id.','.$next_item.')'); } /*$item_id may be one of: * -'next' @@ -42,18 +42,18 @@ function initialize_item($lp_id, $user_id, $view_id, $next_item) */ $mylp = learnpath::getLpFromSession(api_get_course_id(), $lp_id, $user_id); $mylp->set_current_item($next_item); - if ($debug > 1) { - error_log('In initialize_item() - new item is '.$next_item, 0); + if ($debug) { + error_log('In initialize_item() - new item is '.$next_item); } $mylp->start_current_item(true); if (is_object($mylp->items[$next_item])) { - if ($debug > 1) { + if ($debug) { error_log('In initialize_item - recovering existing item object '.$next_item, 0); } $mylpi = $mylp->items[$next_item]; } else { - if ($debug > 1) { + if ($debug) { error_log('In initialize_item - generating new item object '.$next_item, 0); } $mylpi = new learnpathItem($next_item, $user_id); @@ -170,11 +170,10 @@ function initialize_item($lp_id, $user_id, $view_id, $next_item) $mylp->set_error_msg(''); $mylp->prerequisites_match(); // Check the prerequisites are all complete. - if ($debug > 1) { + if ($debug) { error_log('Prereq_match() returned '.htmlentities($mylp->error), 0); - } - if ($debug > 1) { error_log("return = $return "); + error_log("mylp->lp_view_session_id: ".$mylp->lp_view_session_id); } return $return; diff --git a/main/lp/lp_content.php b/main/lp/lp_content.php index ef58768af7..ee171ea7bb 100755 --- a/main/lp/lp_content.php +++ b/main/lp/lp_content.php @@ -14,13 +14,13 @@ require_once __DIR__.'/../inc/global.inc.php'; $debug = 0; if ($debug > 0) { - error_log('New lp - In lp_content.php', 0); + error_log('New lp - In lp_content.php'); } if (empty($lp_controller_touched)) { if ($debug > 0) { - error_log('New lp - In lp_content.php - Redirecting to lp_controller', 0); + error_log('New lp - In lp_content.php - Redirecting to lp_controller'); } - header('location: lp_controller.php?action=content&lp_id='.intval($_REQUEST['lp_id']).'&item_id='.intval($_REQUEST['item_id']).'&'.api_get_cidreq()); + header('Location: lp_controller.php?action=content&lp_id='.intval($_REQUEST['lp_id']).'&item_id='.intval($_REQUEST['item_id']).'&'.api_get_cidreq()); exit; } @@ -35,7 +35,9 @@ $lp_item_id = $learnPath->get_current_item_id(); */ $src = ''; if ($debug > 0) { - error_log('New lp - In lp_content.php - Looking for file url', 0); + error_log('New lp - In lp_content.php - Looking for file url'); + error_log("lp_type $lp_type"); + error_log("lp_item_id $lp_item_id"); } $list = $learnPath->get_toc(); @@ -93,7 +95,7 @@ if ($dir) { } if ($debug > 0) { - error_log('New lp - In lp_content.php - File url is '.$src, 0); + error_log('New lp - In lp_content.php - File url is '.$src); } $learnPath->set_previous_item($lp_item_id); @@ -114,7 +116,7 @@ $save_setting = api_get_setting('show_navigation_menu'); global $_setting; $_setting['show_navigation_menu'] = false; if ($debug > 0) { - error_log('New LP - In lp_content.php - Loading '.$src, 0); + error_log('New LP - In lp_content.php - Loading '.$src); } Session::write('oLP', $learnPath); header("Location: ".urldecode($src));