From d5f3fba8123c0e46a731dff42e1c6d72523f56e7 Mon Sep 17 00:00:00 2001 From: ywarnier Date: Fri, 8 Jul 2011 17:41:35 -0500 Subject: [PATCH] To be reviewed - fix to negative total time connected to the platform --- main/inc/lib/tracking.lib.php | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/main/inc/lib/tracking.lib.php b/main/inc/lib/tracking.lib.php index 42d9070cad..63aa9f7ef0 100755 --- a/main/inc/lib/tracking.lib.php +++ b/main/inc/lib/tracking.lib.php @@ -51,12 +51,16 @@ class Tracking { $i_timestamp_login_date = strtotime($s_login_date); $i_timestamp_logout_date = strtotime($s_logout_date); - if($i_timestamp_logout_date>0) - { - $nb_seconds += ($i_timestamp_logout_date - $i_timestamp_login_date); - } - else - { // there are wrong datas in db, then we can't give a wrong time + if ($i_timestamp_logout_date > 0) { + // @TODO YW 20110708: for some reason the result here is often + // negative, resulting in a negative time total. Considering the + // logout_date is > 0, this can only mean that the database + // contains items where the login_date is higher (=later) than + // the logout date for a specific connexion. This has to be + // analyzed and fixed. Also see the get_time_spent_on_the_course + // for SQL summing. + $nb_seconds += abs($i_timestamp_logout_date - $i_timestamp_login_date); + } else { // there are wrong datas in db, then we can't give a wrong time $wrong_logout_dates = true; }