diff --git a/main/newscorm/learnpath.class.php b/main/newscorm/learnpath.class.php index 19864407ef..dc52f55d3a 100755 --- a/main/newscorm/learnpath.class.php +++ b/main/newscorm/learnpath.class.php @@ -67,6 +67,7 @@ class learnpath { public $debug = 0; //logging level public $lp_session_id =0; + public $lp_view_session_id =0; //the specific view might be bound to a session public $prerequisite = 0; @@ -170,7 +171,7 @@ class learnpath { $session_id = api_get_session_id(); // get the session condition for learning paths of the base + session - $session = api_get_session_condition($session_id,true,true); + $session = api_get_session_condition($session_id); //now get the latest attempt from this user on this LP, if available, otherwise create a new one $lp_table = Database::get_course_table(TABLE_LP_VIEW); //selecting by view_count descending allows to get the highest view_count first @@ -187,6 +188,7 @@ class learnpath { $this->lp_view_id = $row['id']; $this->last_item_seen = $row['last_item']; $this->progress_db = $row['progress']; + $this->lp_view_session_id = $row['session_id']; } else { if ($this->debug > 2) { error_log('New LP - learnpath::__construct() ' . __LINE__ . ' - NOT Found previous view', 0); @@ -3505,9 +3507,10 @@ class learnpath { //TODO //call autosave method to save the current progress //$this->index = 0; + $session_id = api_get_session_id(); $lp_view_table = Database :: get_course_table(TABLE_LP_VIEW); - $sql = "INSERT INTO $lp_view_table (lp_id, user_id, view_count) " . - "VALUES (" . $this->lp_id . "," . $this->get_user_id() . "," . ($this->attempt + 1) . ")"; + $sql = "INSERT INTO $lp_view_table (lp_id, user_id, view_count, session_id) " . + "VALUES (" . $this->lp_id . "," . $this->get_user_id() . "," . ($this->attempt + 1) . ", $session_id)"; if ($this->debug > 2) { error_log('New LP - Inserting new lp_view for restart: ' . $sql, 0); } @@ -3594,13 +3597,14 @@ class learnpath { if ($this->debug > 0) { error_log('New LP - In learnpath::save_last()', 0); } + $session_condition = api_get_session_condition(api_get_session_id(),true,false); $table = Database :: get_course_table(TABLE_LP_VIEW); if (isset ($this->current)) { if ($this->debug > 2) { error_log('New LP - Saving current item (' . $this->current . ') for later review', 0); } $sql = "UPDATE $table SET last_item = " . Database::escape_string($this->get_current_item_id()). " " . - "WHERE lp_id = " . $this->get_id() . " AND user_id = " . $this->get_user_id(); + "WHERE lp_id = " . $this->get_id() . " AND user_id = " . $this->get_user_id().' '.$session_condition; if ($this->debug > 2) { error_log('New LP - Saving last item seen : ' . $sql, 0); @@ -3618,7 +3622,7 @@ class learnpath { $sql = "UPDATE $table SET progress = $progress " . "WHERE lp_id = " . $this->get_id() . " AND " . - "user_id = " . $this->get_user_id(); + "user_id = " . $this->get_user_id().' '.$session_condition; $res = Database::query($sql); //ignore errors as some tables might not have the progress field just yet $this->progress_db = $progress; } diff --git a/main/newscorm/learnpathList.class.php b/main/newscorm/learnpathList.class.php index ffd542f3e6..784ffe28da 100755 --- a/main/newscorm/learnpathList.class.php +++ b/main/newscorm/learnpathList.class.php @@ -60,7 +60,7 @@ class learnpathList { //it prevents ' to be slashed and the input (done by learnpath.class.php::toggle_visibility()) //is done using domesticate() $myname = domesticate($row['name']); - $mylink = 'newscorm/lp_controller.php?action=view&lp_id='.$row['id']; + $mylink = 'newscorm/lp_controller.php?action=view&lp_id='.$row['id'].'&id_session='.$session_id; $sql2="SELECT * FROM $tbl_tool where (name='$myname' and image='scormbuilder.gif' and link LIKE '$mylink%')"; //error_log('New LP - learnpathList::__construct - getting visibility - '.$sql2,0); $res2 = Database::query($sql2); diff --git a/main/newscorm/lp_controller.php b/main/newscorm/lp_controller.php index 02806bcd77..48f47c83ab 100755 --- a/main/newscorm/lp_controller.php +++ b/main/newscorm/lp_controller.php @@ -11,7 +11,7 @@ * Initialisations */ $debug = 0; -if($debug>0) error_log('New LP -+- Entered lp_controller.php -+-',0); +if($debug>0) error_log('New LP -+- Entered lp_controller.php -+- (action: '.$_REQUEST['action'].')',0); // name of the language file that needs to be included if (isset($_GET['action'])) { @@ -71,6 +71,8 @@ if($debug>0) error_log('New LP - Included aiccItem',0); require_once 'back_compat.inc.php'; if($debug>0) error_log('New LP - Included back_compat',0); +$session_id = api_get_session_id(); + if (!$is_allowed_in_course) { api_not_allowed(true); } @@ -102,7 +104,7 @@ if(isset($_SESSION['lpobject'])) $oLP = unserialize($_SESSION['lpobject']); if(is_object($oLP)){ if($debug>0) error_log('New LP - oLP is object',0); - if($myrefresh == 1 OR (empty($oLP->cc)) OR $oLP->cc != api_get_course_id()){ + if($myrefresh == 1 OR (empty($oLP->cc)) OR $oLP->cc != api_get_course_id() OR $oLP->lp_view_session_id != $session_id){ if($debug>0) error_log('New LP - Course has changed, discard lp object',0); if($myrefresh == 1){$myrefresh_id = $oLP->get_id();} $oLP = null; diff --git a/main/newscorm/lp_stats.php b/main/newscorm/lp_stats.php index 677ee06467..7705651187 100755 --- a/main/newscorm/lp_stats.php +++ b/main/newscorm/lp_stats.php @@ -23,11 +23,8 @@ if(empty($_SESSION['_course']['id']) && isset($_GET['course'])) { if (isset($_GET['student_id'])) { $student_id = intval($_GET['student_id']); } -$session_id = 0; -if (isset($_GET['session_id'])) { - $session_id = intval($_GET['session_id']); -} - +$session_id = api_get_session_id(); +$session_condition = api_get_session_condition($session_id); //The two following variables have to be declared by the includer script //$lp_id = $_SESSION['oLP']->get_id(); //$list = $_SESSION['oLP']->get_flat_ordered_items_list($lp_id); @@ -102,7 +99,7 @@ $tbl_stats_exercices = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_E $tbl_stats_attempts= Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT); $tbl_quiz_questions= Database :: get_course_table(TABLE_QUIZ_QUESTION); $sql = "SELECT max(view_count) FROM $TBL_LP_VIEW " . -"WHERE lp_id = $lp_id AND user_id = '" . $user_id . "' AND session_id = $session_id"; +"WHERE lp_id = $lp_id AND user_id = '" . $user_id . "' $session_condition"; $res = Database::query($sql); $view = ''; $num = 0; diff --git a/main/newscorm/lp_view.php b/main/newscorm/lp_view.php index f97fb6b45a..d85ad72237 100755 --- a/main/newscorm/lp_view.php +++ b/main/newscorm/lp_view.php @@ -234,10 +234,10 @@ if($_SESSION['oLP']->mode == 'fullscreen') { @@ -420,4 +420,4 @@ if($_SESSION['oLP']->mode == 'fullscreen') {
- + - +