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.
pull/2467/head
jmontoyaa 8 years ago
parent 62b741710f
commit b0c85057ad
  1. 16
      main/lp/learnpathItem.class.php
  2. 9
      main/lp/lp_view.php

@ -3920,24 +3920,16 @@ class learnpathItem
if (!empty($_REQUEST['exeId'])) { if (!empty($_REQUEST['exeId'])) {
$table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES); $table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
$exeId = (int) $_REQUEST['exeId']; $exeId = (int) $_REQUEST['exeId'];
$sql = "SELECT start_date, exe_date $sql = "SELECT exe_duration
FROM $table FROM $table
WHERE exe_id = $exeId"; WHERE exe_id = $exeId";
if ($debug) { if ($debug) {
error_log($sql); error_log($sql);
} }
$res = Database::query($sql); $res = Database::query($sql);
$row_dates = Database::fetch_array($res); $exeRow = Database::fetch_array($res);
$duration = $exeRow['exe_duration'];
$time_start_date = convert_sql_date( $total_time = " total_time = ".$duration.", ";
$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.", ";
if ($debug) { if ($debug) {
error_log("quiz: $total_time"); error_log("quiz: $total_time");
} }

@ -276,16 +276,13 @@ if (!empty($_REQUEST['exeId']) &&
if ($safe_id == strval(intval($safe_id)) && if ($safe_id == strval(intval($safe_id)) &&
$safe_item_id == strval(intval($safe_item_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.' FROM '.$TBL_TRACK_EXERCICES.'
WHERE exe_id = '.$safe_exe_id; WHERE exe_id = '.$safe_exe_id;
$res = Database::query($sql); $res = Database::query($sql);
$row_dates = Database::fetch_array($res); $row_dates = Database::fetch_array($res);
$time_start_date = api_strtotime($row_dates['start_date'], 'UTC'); $duration = (int) $row_dates['exe_duration'];
$time_exe_date = api_strtotime($row_dates['exe_date'], 'UTC');
$mytime = (int) $time_exe_date - (int) $time_start_date;
$score = (float) $row_dates['exe_result']; $score = (float) $row_dates['exe_result'];
$max_score = (float) $row_dates['exe_weighting']; $max_score = (float) $row_dates['exe_weighting'];
@ -326,7 +323,7 @@ if (!empty($_REQUEST['exeId']) &&
$sql = "UPDATE $TBL_LP_ITEM_VIEW SET $sql = "UPDATE $TBL_LP_ITEM_VIEW SET
status = '$status', status = '$status',
score = $score, score = $score,
total_time = $mytime total_time = $duration
WHERE iid = $lp_item_view_id"; WHERE iid = $lp_item_view_id";
if ($debug) { if ($debug) {
error_log($sql); error_log($sql);

Loading…
Cancel
Save