From b0c85057adeedb59cb28ec2ca96820a56d29f4d2 Mon Sep 17 00:00:00 2001 From: jmontoyaa Date: Mon, 26 Mar 2018 15:45:29 +0200 Subject: [PATCH] Save duration instead of calculation of start/end date see BT#14161 - Bug appears, when I start exercise today, then I resume tomorrow, the total time will be more than 24 hours, this is wrong. I was only 5 min in the exercise. --- main/lp/learnpathItem.class.php | 16 ++++------------ main/lp/lp_view.php | 9 +++------ 2 files changed, 7 insertions(+), 18 deletions(-) diff --git a/main/lp/learnpathItem.class.php b/main/lp/learnpathItem.class.php index 0bacac1cbb..8ae06e7ddf 100755 --- a/main/lp/learnpathItem.class.php +++ b/main/lp/learnpathItem.class.php @@ -3920,24 +3920,16 @@ class learnpathItem if (!empty($_REQUEST['exeId'])) { $table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES); $exeId = (int) $_REQUEST['exeId']; - $sql = "SELECT start_date, exe_date + $sql = "SELECT exe_duration FROM $table WHERE exe_id = $exeId"; if ($debug) { error_log($sql); } $res = Database::query($sql); - $row_dates = Database::fetch_array($res); - - $time_start_date = convert_sql_date( - $row_dates['start_date'] - ); - $time_exe_date = convert_sql_date( - $row_dates['exe_date'] - ); - $mytime = ((int) $time_exe_date - (int) $time_start_date); - $mytime = $this->fixAbusiveTime($mytime); - $total_time = " total_time = ".$mytime.", "; + $exeRow = Database::fetch_array($res); + $duration = $exeRow['exe_duration']; + $total_time = " total_time = ".$duration.", "; if ($debug) { error_log("quiz: $total_time"); } diff --git a/main/lp/lp_view.php b/main/lp/lp_view.php index b4b6f16f36..db3640d940 100755 --- a/main/lp/lp_view.php +++ b/main/lp/lp_view.php @@ -276,16 +276,13 @@ if (!empty($_REQUEST['exeId']) && if ($safe_id == strval(intval($safe_id)) && $safe_item_id == strval(intval($safe_item_id)) ) { - $sql = 'SELECT start_date, exe_date, exe_result, exe_weighting, exe_exo_id + $sql = 'SELECT start_date, exe_date, exe_result, exe_weighting, exe_exo_id, exe_duration FROM '.$TBL_TRACK_EXERCICES.' WHERE exe_id = '.$safe_exe_id; $res = Database::query($sql); $row_dates = Database::fetch_array($res); - $time_start_date = api_strtotime($row_dates['start_date'], 'UTC'); - $time_exe_date = api_strtotime($row_dates['exe_date'], 'UTC'); - - $mytime = (int) $time_exe_date - (int) $time_start_date; + $duration = (int) $row_dates['exe_duration']; $score = (float) $row_dates['exe_result']; $max_score = (float) $row_dates['exe_weighting']; @@ -326,7 +323,7 @@ if (!empty($_REQUEST['exeId']) && $sql = "UPDATE $TBL_LP_ITEM_VIEW SET status = '$status', score = $score, - total_time = $mytime + total_time = $duration WHERE iid = $lp_item_view_id"; if ($debug) { error_log($sql);