Creating new function to save the course login + adding the course ranking updates there (suggested by ywarnier) see #4200

skala
Julio Montoya 13 years ago
parent 17b948e574
commit e52ff8129e
  1. 30
      main/inc/lib/events.lib.inc.php
  2. 9
      main/inc/local.inc.php

@ -18,6 +18,7 @@
$TABLETRACK_LOGIN = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_LOGIN);
$TABLETRACK_OPEN = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_OPEN);
$TABLETRACK_ACCESS = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ACCESS);
$course_tracking_table = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
$TABLETRACK_DOWNLOADS = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
$TABLETRACK_UPLOADS = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_UPLOADS);
$TABLETRACK_LINKS = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_LINKS);
@ -132,10 +133,7 @@ function event_access_course() {
VALUES (".$user_id.", '".$_cid."', '$now', '".$id_session."')";
$res = Database::query($sql);
}
// end "what's new" notification
//Course catalog stats modifications see #4191
CourseManager::update_course_ranking();
// end "what's new" notification
return 1;
}
@ -1288,7 +1286,6 @@ function get_comments($id,$question_id) {
}
function get_all_exercise_event_by_exe_id($exe_id) {
$table_track_attempt = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
$exe_id = intval($exe_id);
@ -1304,7 +1301,6 @@ function get_all_exercise_event_by_exe_id($exe_id) {
}
function delete_attempt($exe_id, $user_id, $course_code, $session_id, $question_id) {
$table_track_attempt = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
@ -1331,3 +1327,25 @@ function delete_attempt_hotspot($exe_id, $user_id, $course_code, $question_id) {
Database::query($sql);
}
/**
* User logs in for the first time to a course
*/
function event_course_login($course_code, $user_id, $session_id) {
global $course_tracking_table;
//@todo use api_get_utc_datetime
$time = api_get_datetime();
$course_code = Database::escape_string($course_code);
$user_id = Database::escape_string($user_id);
$session_id = Database::escape_string($session_id);
$sql = "INSERT INTO $course_tracking_table(course_code, user_id, login_course_date, logout_course_date, counter, session_id)
VALUES('".$course_code."', '".$user_id."', '$time', '$time', '1', '".$session_id."')";
Database::query($sql);
//Course catalog stats modifications see #4191
CourseManager::update_course_ranking();
}

@ -745,13 +745,8 @@ if (isset($cidReset) && $cidReset) { // course session data refresh requested or
}
if (!isset($_SESSION['login_as'])) {
//We add a new record in the course tracking table
$course_tracking_table = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
$time = api_get_datetime();
$sql="INSERT INTO $course_tracking_table(course_code, user_id, login_course_date, logout_course_date, counter, session_id)" .
"VALUES('".$_course['sysCode']."', '".$_user['user_id']."', '$time', '$time', '1', '".api_get_session_id()."')";
//error_log($sql);
Database::query($sql);
//Course login
event_course_login($_course['sysCode'], $_user['user_id'], api_get_session_id());
}
} else {
//exit("WARNING UNDEFINED CID !! ");

Loading…
Cancel
Save