pull/3064/head
Yannick Warnier 5 years ago
parent 03cf40a039
commit 275949f0b4
  1. 43
      main/exercise/exercise_result.class.php

@ -80,7 +80,8 @@ class ExerciseResult
te.exe_duration as duration, te.exe_duration as duration,
te.orig_lp_id as orig_lp_id, te.orig_lp_id as orig_lp_id,
tlm.name as lp_name, tlm.name as lp_name,
user.username user.username,
te.status as exstatus
FROM $TBL_EXERCISES AS ce FROM $TBL_EXERCISES AS ce
INNER JOIN $TBL_TRACK_EXERCISES AS te INNER JOIN $TBL_TRACK_EXERCISES AS te
ON (te.exe_exo_id = ce.id) ON (te.exe_exo_id = ce.id)
@ -90,7 +91,6 @@ class ExerciseResult
ON (tlm.id = te.orig_lp_id AND tlm.c_id = ce.c_id) ON (tlm.id = te.orig_lp_id AND tlm.c_id = ce.c_id)
WHERE WHERE
ce.c_id = $course_id AND ce.c_id = $course_id AND
te.status != 'incomplete' AND
te.c_id = ce.c_id $user_id_and $session_id_and AND te.c_id = ce.c_id $user_id_and $session_id_and AND
ce.active <>-1"; ce.active <>-1";
} else { } else {
@ -111,7 +111,8 @@ class ExerciseResult
ce.results_disabled as exdisabled, ce.results_disabled as exdisabled,
te.orig_lp_id as orig_lp_id, te.orig_lp_id as orig_lp_id,
tlm.name as lp_name, tlm.name as lp_name,
user.username user.username,
te.status as exstatus
FROM $TBL_EXERCISES AS ce FROM $TBL_EXERCISES AS ce
INNER JOIN $TBL_TRACK_EXERCISES AS te INNER JOIN $TBL_TRACK_EXERCISES AS te
ON (te.exe_exo_id = ce.id) ON (te.exe_exo_id = ce.id)
@ -121,7 +122,6 @@ class ExerciseResult
ON (tlm.id = te.orig_lp_id AND tlm.c_id = ce.c_id) ON (tlm.id = te.orig_lp_id AND tlm.c_id = ce.c_id)
WHERE WHERE
ce.c_id = $course_id AND ce.c_id = $course_id AND
te.status != 'incomplete' AND
te.c_id = ce.c_id $user_id_and $session_id_and AND te.c_id = ce.c_id $user_id_and $session_id_and AND
ce.active <>-1 AND ce.active <>-1 AND
ORDER BY userpart2, te.c_id ASC, ce.title ASC, te.exe_date DESC"; ORDER BY userpart2, te.c_id ASC, ce.title ASC, te.exe_date DESC";
@ -179,25 +179,29 @@ class ExerciseResult
if (is_array($results)) { if (is_array($results)) {
$i = 0; $i = 0;
foreach ($results as $result) { foreach ($results as $result) {
$revised = false; $revised = 0;
//revised or not if ($result['exstatus'] === 'incomplete') {
$sql_exe = "SELECT exe_id $revised = -1;
FROM $TBL_TRACK_ATTEMPT_RECORDING } else {
WHERE //revised or not
author != '' AND $sql_exe = "SELECT exe_id
exe_id = ".Database::escape_string($result['exid'])." FROM $TBL_TRACK_ATTEMPT_RECORDING
LIMIT 1"; WHERE
$query = Database::query($sql_exe); author != '' AND
exe_id = ".intval($result['exid'])."
if (Database:: num_rows($query) > 0) { LIMIT 1";
$revised = true; $query = Database::query($sql_exe);
if (Database:: num_rows($query) > 0) {
$revised = 1;
}
} }
if ($filter_by_not_revised && $revised) { if ($filter_by_not_revised && $revised === 1) {
continue; continue;
} }
if ($filter_by_revised && !$revised) { if ($filter_by_revised && $revised < 1) {
continue; continue;
} }
@ -221,7 +225,8 @@ class ExerciseResult
$return[$i]['duration'] = $result['duration']; $return[$i]['duration'] = $result['duration'];
$return[$i]['result'] = $result['exresult']; $return[$i]['result'] = $result['exresult'];
$return[$i]['max'] = $result['exweight']; $return[$i]['max'] = $result['exweight'];
$return[$i]['status'] = $revised ? get_lang('Validated') : get_lang('Not validated'); // Revised: 1 = revised, 0 = not revised, -1 = not even finished by user
$return[$i]['status'] = $revised === 1 ? get_lang('Validated') : ($revised === 0 ? get_lang('NotValidated') : get_lang('Unclosed') );
$return[$i]['lp_id'] = $result['orig_lp_id']; $return[$i]['lp_id'] = $result['orig_lp_id'];
$return[$i]['lp_name'] = $result['lp_name']; $return[$i]['lp_name'] = $result['lp_name'];

Loading…
Cancel
Save