Adding session_id when updating the TABLE_STATISTIC_TRACK_E_COURSE_ACCESS table

skala
Julio Montoya 14 years ago
parent 1314d2735e
commit 601650744c
  1. 30
      main/inc/local.inc.php

@ -777,10 +777,6 @@ if (isset($uidReset) && $uidReset) { // session data refresh requested
/* COURSE INIT */
if (isset($cidReset) && $cidReset) { // course session data refresh requested or empty data
if (api_get_session_id()) {
api_session_unregister('id_session');
}
if ($cidReq) {
$course_table = Database::get_main_table(TABLE_MAIN_COURSE);
@ -890,11 +886,10 @@ if (isset($cidReset) && $cidReset) { // course session data refresh requested or
//We select the last record for the current course in the course tracking table
// But only if the login date is < thant now + max_life_time
$sql="SELECT course_access_id FROM $course_tracking_table
WHERE user_id=".intval($_user ['user_id'])."
AND course_code='$course_code'
WHERE user_id=".intval($_user ['user_id'])."
AND course_code='$course_code' AND session_id = ".api_get_session_id()."
AND login_course_date > now() - INTERVAL $session_lifetime SECOND
ORDER BY login_course_date DESC LIMIT 0,1";
$result=Database::query($sql);
@ -903,16 +898,12 @@ if (isset($cidReset) && $cidReset) { // course session data refresh requested or
$i_course_access_id = Database::result($result,0,0);
//We update the course tracking table
$sql="UPDATE $course_tracking_table " .
"SET logout_course_date = '$time', " .
"counter = counter+1 " .
"WHERE course_access_id=".intval($i_course_access_id);
$sql="UPDATE $course_tracking_table SET logout_course_date = '$time', counter = counter+1 ".
"WHERE course_access_id=".intval($i_course_access_id)." AND session_id = ".api_get_session_id();
Database::query($sql);
} else {
$sql="INSERT INTO $course_tracking_table
(course_code, user_id, login_course_date, logout_course_date, counter)" .
"VALUES('".$course_code."', '".$_user['user_id']."', '$time', '$time', '1')";
$sql="INSERT INTO $course_tracking_table (course_code, user_id, login_course_date, logout_course_date, counter, session_id)" .
"VALUES('".$course_code."', '".$_user['user_id']."', '$time', '$time', '1','".api_get_session_id()."')";
Database::query($sql);
}
}
@ -1184,4 +1175,11 @@ if (isset($_cid)) {
$time = api_get_datetime();
$sql="UPDATE $tbl_course SET last_visit= '$time' WHERE code='$_cid'";
Database::query($sql);
}
//Deleting session id
if (isset($cidReset) && $cidReset) {
if (api_get_session_id()) {
api_session_unregister('id_session');
}
}
Loading…
Cancel
Save