diff --git a/main/exercice/exercise.lib.php b/main/exercice/exercise.lib.php index 2e92527303..d13b21b7be 100644 --- a/main/exercice/exercise.lib.php +++ b/main/exercice/exercise.lib.php @@ -1067,7 +1067,9 @@ function get_exam_results_data($from, $number_of_items, $column, $direction, $ex $group_name_list .= $group_list_info[$id]['name'].' '; } $results[$i]['group_name'] = $group_name_list; - } + } + + $results[$i]['exe_duration'] = !empty($results[$i]['exe_duration']) ? round($results[$i]['exe_duration'] / 60) : 0; $user_list_id[] = $results[$i]['exe_user_id']; $id = $results[$i]['exe_id']; diff --git a/main/exercice/exercise_report.php b/main/exercice/exercise_report.php index 2a8ed7f5ac..4cbd1ffb42 100644 --- a/main/exercice/exercise_report.php +++ b/main/exercice/exercise_report.php @@ -331,7 +331,7 @@ if ($is_allowedToEdit || $is_tutor) { //The order is important you need to check the the $column variable in the model.ajax.php file $columns = array(get_lang('FirstName'), get_lang('LastName'), get_lang('LoginName'), - get_lang('Group'), get_lang('Duration'), get_lang('StartDate'), get_lang('EndDate'), get_lang('Score'), get_lang('Status'), get_lang('Actions')); + get_lang('Group'), get_lang('Duration').' ('.get_lang('MinMinute').')', get_lang('StartDate'), get_lang('EndDate'), get_lang('Score'), get_lang('Status'), get_lang('Actions')); //Column config $column_model = array( diff --git a/main/exercice/exercise_submit.php b/main/exercice/exercise_submit.php index 2afeb20b32..803b70f57d 100644 --- a/main/exercice/exercise_submit.php +++ b/main/exercice/exercise_submit.php @@ -151,10 +151,9 @@ if ($objExercise->expired_time != 0 && $origin != 'learnpath') { $time_control = true; } - //Generating the time control key for the user $current_expired_time_key = generate_time_control_key($objExercise->id); -$_SESSION['duration_time'][$current_expired_time_key] = $current_timestamp; +$_SESSION['duration_time'][$current_expired_time_key] = $current_timestamp; if ($time_control) { //Get the expired time of the current exercice in track_e_exercices diff --git a/main/inc/ajax/exercise.ajax.php b/main/inc/ajax/exercise.ajax.php index b4c0ab91b6..269340b779 100644 --- a/main/inc/ajax/exercise.ajax.php +++ b/main/inc/ajax/exercise.ajax.php @@ -316,24 +316,25 @@ switch ($action) { $duration = 0; $now = time(); + if ($type == 'all') { + $exercise_stat_info = $objExercise->get_stat_track_exercise_info_by_exe_id($exe_id); + } + if (isset($_SESSION['duration_time'][$key]) && !empty($_SESSION['duration_time'][$key])) { $duration = $now - $_SESSION['duration_time'][$key]; + if (!empty($exercise_stat_info['exe_duration'])) { - $duration += $exercise_stat_info['exe_duration']*60; + $duration += $exercise_stat_info['exe_duration']; } - $duration = intval(round($duration/60)); - $_SESSION['duration_time'][$key] = 0; - } else { + $duration = intval($duration); + } else { if (!empty($exercise_stat_info['exe_duration'])) { $duration = $exercise_stat_info['exe_duration']; - } - - if ($type == 'all') { - $exercise_stat_info = $objExercise->get_stat_track_exercise_info_by_exe_id($exe_id); - $duration = $exercise_stat_info['exe_duration']; - } + } } - + + $_SESSION['duration_time'][$key] = time(); + update_event_exercice($exe_id, $objExercise->selectId(), $total_score, $total_weight, api_get_session_id(), $exercise_stat_info['orig_lp_id'], $exercise_stat_info['orig_lp_item_id'], $exercise_stat_info['orig_lp_item_view_id'], $duration, $question_list, 'incomplete', $remind_list); // Destruction of the Question object diff --git a/main/inc/lib/events.lib.inc.php b/main/inc/lib/events.lib.inc.php index 932b498fb1..1b4829ac5c 100644 --- a/main/inc/lib/events.lib.inc.php +++ b/main/inc/lib/events.lib.inc.php @@ -311,7 +311,7 @@ function event_link($link_id) { * @param int exo_id exercise id * @param mixed result score * @param int weighting ( higher score ) - * @param int duration ( duration of the attempt, in seconds ) + * @param int duration ( duration of the attempt in seconds ) * @param int session_id * @param int learnpath_id (id of the learnpath) * @param int learnpath_item_id (id of the learnpath_item) @@ -322,7 +322,7 @@ function event_link($link_id) { */ function update_event_exercice($exeid, $exo_id, $score, $weighting, $session_id, $learnpath_id = 0, $learnpath_item_id = 0, $learnpath_item_view_id = 0, $duration = 0, $question_list = array(), $status = '', $remind_list = array() , $end_date = null) { //error_log('Called to update_event_exercice'); - //error_log('duration:' . $duration); + error_log('duration:' . $duration); require_once api_get_path(SYS_CODE_PATH).'exercice/exercise.lib.php'; if ($exeid != '') { // Validation in case of fraud with actived control time