More fixes to avoid high times values see BT#13552

pull/2487/head
jmontoyaa 8 years ago
parent 762a613257
commit dab9dc8506
  1. 34
      main/lp/learnpathItem.class.php

@ -1815,6 +1815,23 @@ class learnpathItem
}
return 0;
} else {
$time = self::fixAbusiveTime($time);
if (self::DEBUG > 2) {
error_log(
'Current start time = '.$this->current_start_time.', current stop time = '.
$this->current_stop_time.' Returning '.$time."-----------\n"
);
}
return $time;
}
}
/**
* @param int $time
* @return int
*/
public static function fixAbusiveTime($time)
{
// Code based from Event::courseLogout
$sessionLifetime = api_get_configuration_value('session_lifetime');
// If session life time too big use 1 hour
@ -1830,15 +1847,8 @@ class learnpathItem
$time = $fixedAddedMinute;
}
if (self::DEBUG > 2) {
error_log(
'Current start time = '.$this->current_start_time.', current stop time = '.
$this->current_stop_time.' Returning '.$time."-----------\n"
);
}
return $time;
}
}
/**
* Gets the item type
@ -3502,6 +3512,7 @@ class learnpathItem
$total_time += $total_sec;
} else {
// Step 2.2 : if not cumulative mode total_time = total_time - last_update + total_sec
$total_sec = self::fixAbusiveTime($total_sec);
$total_time = $total_time - $this->last_scorm_session_time + $total_sec;
$this->last_scorm_session_time = $total_sec;
@ -3546,9 +3557,9 @@ class learnpathItem
**/
public function scorm_init_time()
{
$item_view_table = Database::get_course_table(TABLE_LP_ITEM_VIEW);
$table = Database::get_course_table(TABLE_LP_ITEM_VIEW);
$course_id = api_get_course_int_id();
$sql = 'UPDATE '.$item_view_table.'
$sql = 'UPDATE '.$table.'
SET total_time = 0,
start_time = '.time().'
WHERE c_id = '.$course_id.'
@ -3817,11 +3828,11 @@ class learnpathItem
$my_status = ' ';
$total_time = ' ';
if (!empty($_REQUEST['exeId'])) {
$TBL_TRACK_EXERCICES = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
$table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
$safe_exe_id = intval($_REQUEST['exeId']);
$sql = "SELECT start_date, exe_date
FROM $TBL_TRACK_EXERCICES
FROM $table
WHERE exe_id = $safe_exe_id";
$res = Database::query($sql);
$row_dates = Database::fetch_array($res);
@ -3833,6 +3844,7 @@ class learnpathItem
$row_dates['exe_date']
);
$mytime = ((int) $time_exe_date - (int) $time_start_date);
$mytime = self::fixAbusiveTime($mytime);
$total_time = " total_time = ".$mytime.", ";
}
} else {

Loading…
Cancel
Save