|
@@ -737,7 +737,7 @@ function get_session_time_control_key($exercise_id) {
|
|
|
*/
|
|
|
function get_count_exam_results($exercise_id = null) {
|
|
|
//@todo replace all this globals
|
|
|
- global $is_allowedToEdit, $is_tutor,$_cid,$_user,$TBL_USER, $TBL_EXERCICES,$TBL_TRACK_EXERCICES, $TBL_TRACK_HOTPOTATOES, $TBL_TRACK_ATTEMPT_RECORDING,$filter_by_not_revised,$filter_by_revised,$documentPath;
|
|
|
+ global $is_allowedToEdit, $is_tutor,$TBL_USER, $TBL_EXERCICES,$TBL_TRACK_EXERCICES, $TBL_TRACK_HOTPOTATOES, $TBL_TRACK_ATTEMPT_RECORDING,$filter_by_not_revised,$filter_by_revised,$documentPath;
|
|
|
$session_id_and = ' AND te.session_id = ' . api_get_session_id() . ' ';
|
|
|
if ($is_allowedToEdit || $is_tutor) {
|
|
|
$user_id_and = '';
|
|
@@ -750,15 +750,11 @@ function get_count_exam_results($exercise_id = null) {
|
|
|
}
|
|
|
if ($_GET['gradebook'] == 'view') {
|
|
|
$exercise_where_query = 'te.exe_exo_id =ce.id AND ';
|
|
|
- }
|
|
|
-
|
|
|
+ }
|
|
|
+ $exercise_id = intval($_GET['exerciseId']);
|
|
|
$exercise_where = '';
|
|
|
- if (isset($_GET['exerciseId'])) {
|
|
|
- $exercise_where = ' AND te.exe_exo_id = '.intval($_GET['exerciseId']).' ';
|
|
|
- }
|
|
|
-
|
|
|
if (!empty($exercise_id)) {
|
|
|
- $exercise_where = ' AND te.exe_exo_id = '.intval($exercise_id).' ';
|
|
|
+ $exercise_where = ' AND te.exe_exo_id = '.$exercise_id.' ';
|
|
|
}
|
|
|
|
|
|
//@todo fix to work with COURSE_RELATION_TYPE_RRHH in both queries
|
|
@@ -769,15 +765,15 @@ function get_count_exam_results($exercise_id = null) {
|
|
|
WHERE user.user_id=cuser.user_id AND cuser.relation_type<>".COURSE_RELATION_TYPE_RRHH." AND te.exe_exo_id = ce.id AND te.status != 'incomplete' AND cuser.user_id=te.exe_user_id AND te.exe_cours_id='" . Database :: escape_string($_cid) . "'
|
|
|
$user_id_and $session_id_and AND ce.active <>-1 AND orig_lp_id = 0 AND orig_lp_item_id = 0
|
|
|
AND cuser.course_code=te.exe_cours_id ORDER BY col1, te.exe_cours_id ASC, ce.title ASC, te.exe_date DESC";*/
|
|
|
-
|
|
|
- $sql="SELECT count(*) as count
|
|
|
- FROM $TBL_EXERCICES AS ce INNER JOIN $TBL_TRACK_EXERCICES AS te ON (te.exe_exo_id = ce.id) INNER JOIN $TBL_USER AS user ON (user.user_id = exe_user_id)
|
|
|
- WHERE te.status != 'incomplete' AND te.exe_cours_id='" . Database :: escape_string($_cid) . "' $user_id_and $session_id_and AND ce.active <>-1 AND orig_lp_id = 0 AND orig_lp_item_id = 0 $exercise_where ";
|
|
|
-
|
|
|
+
|
|
|
+ $sql="SELECT DISTINCT te.exe_id
|
|
|
+ FROM $TBL_EXERCICES AS ce INNER JOIN $TBL_TRACK_EXERCICES AS te ON (te.exe_exo_id = ce.id) INNER JOIN $TBL_USER AS user ON (user.user_id = exe_user_id) INNER JOIN $TBL_TRACK_ATTEMPT_RECORDING re ON(re.exe_id = te.exe_id)
|
|
|
+ WHERE te.status != 'incomplete' AND te.exe_cours_id='" . api_get_course_id() . "' $user_id_and $session_id_and AND ce.active <>-1 AND orig_lp_id = 0 AND orig_lp_item_id = 0 $exercise_where ";
|
|
|
+
|
|
|
//Seems that the $TBL_TRACK_HOTPOTATOES does not have an exercise id that's weird ... we are removing $exercise_where
|
|
|
$hpsql="SELECT ".(api_is_western_name_order() ? "firstname as col0, lastname col1" : "lastname as col0, firstname as col1").", tth.exe_name, tth.exe_result , tth.exe_weighting, tth.exe_date
|
|
|
FROM $TBL_TRACK_HOTPOTATOES tth, $TBL_USER tu
|
|
|
- WHERE tu.user_id=tth.exe_user_id AND tth.exe_cours_id = '" . Database :: escape_string($_cid) . "' $user_id_and
|
|
|
+ WHERE tu.user_id=tth.exe_user_id AND tth.exe_cours_id = '" . api_get_course_id() . "' $user_id_and
|
|
|
ORDER BY tth.exe_cours_id ASC, tth.exe_date DESC";
|
|
|
|
|
|
} else {
|
|
@@ -795,18 +791,63 @@ function get_count_exam_results($exercise_id = null) {
|
|
|
|
|
|
$sql="SELECT count(*) as count
|
|
|
FROM $TBL_EXERCICES AS ce INNER JOIN $TBL_TRACK_EXERCICES AS te ON (te.exe_exo_id = ce.id) INNER JOIN $TBL_USER AS user ON (user.user_id = exe_user_id)
|
|
|
- WHERE te.status != 'incomplete' AND te.exe_cours_id='" . Database :: escape_string($_cid) . "' $user_id_and $session_id_and AND ce.active <>-1 AND" .
|
|
|
+ WHERE te.status != 'incomplete' AND te.exe_cours_id='" . api_get_course_id() . "' $user_id_and $session_id_and AND ce.active <>-1 AND" .
|
|
|
" orig_lp_id = 0 AND orig_lp_item_id = 0 ";
|
|
|
|
|
|
$hpsql = "SELECT '',exe_name, exe_result , exe_weighting, exe_date
|
|
|
FROM $TBL_TRACK_HOTPOTATOES
|
|
|
- WHERE exe_user_id = '" . $_user['user_id'] . "' AND exe_cours_id = '" . Database :: escape_string($_cid) . "'
|
|
|
+ WHERE exe_user_id = '" . api_get_user_id() . "' AND exe_cours_id = '" . api_get_course_id() . "'
|
|
|
ORDER BY exe_cours_id ASC, exe_date DESC";
|
|
|
}
|
|
|
-
|
|
|
$resx = Database::query($sql);
|
|
|
- $rowx = Database::fetch_array($resx,'ASSOC');
|
|
|
- return $rowx['count'];
|
|
|
+ $hpres = Database::query($hpsql);
|
|
|
+
|
|
|
+ $count = 0;
|
|
|
+ if (Database::num_rows($resx) > 0) {
|
|
|
+ while ($rowx = Database::fetch_array($resx,'ASSOC')) {
|
|
|
+ $results[] = $rowx;
|
|
|
+ }
|
|
|
+ $has_test_results = false;
|
|
|
+
|
|
|
+ if (is_array($results)) {
|
|
|
+ $has_test_results = true;
|
|
|
+ $users_array_id = array ();
|
|
|
+ if ($_GET['gradebook'] == 'view') {
|
|
|
+ $filter_by_no_revised = true;
|
|
|
+ $from_gradebook = true;
|
|
|
+ }
|
|
|
+ $sizeof = count($results);
|
|
|
+
|
|
|
+ $user_list_id = array ();
|
|
|
+ $user_last_name = '';
|
|
|
+ $user_first_name = '';
|
|
|
+ $quiz_name_list = '';
|
|
|
+ $duration_list = '';
|
|
|
+ $date_list = '';
|
|
|
+ $result_list = '';
|
|
|
+ $more_details_list = '';
|
|
|
+ for ($i = 0; $i < $sizeof; $i++) {
|
|
|
+ $revised = false;
|
|
|
+ $sql_exe = 'SELECT exe_id FROM ' . $TBL_TRACK_ATTEMPT_RECORDING . ' WHERE author != "" AND exe_id = ' . Database :: escape_string($results[$i]['exe_id']) .' LIMIT 1';
|
|
|
+ $query = Database::query($sql_exe);
|
|
|
+ if (Database :: num_rows($query) > 0) {
|
|
|
+ $revised = true;
|
|
|
+ }
|
|
|
+ if ($filter_by_not_revised && $revised) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if ($filter_by_revised && !$revised) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ $count++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (Database::num_rows($hpres) > 0) {
|
|
|
+ $rowx = Database::fetch_array($hpres,'ASSOC');
|
|
|
+ $count += $rowx['count'];
|
|
|
+ }
|
|
|
+ return $count;
|
|
|
}
|
|
|
|
|
|
|
|
@@ -818,8 +859,11 @@ function get_count_exam_results($exercise_id = null) {
|
|
|
*/
|
|
|
function get_exam_results_data($from, $number_of_items, $column, $direction) {
|
|
|
//@todo replace all this globals
|
|
|
- global $is_allowedToEdit, $is_tutor,$_cid,$_user,$TBL_USER, $TBL_EXERCICES,$TBL_TRACK_HOTPOTATOES, $TBL_TRACK_EXERCICES, $TBL_TRACK_ATTEMPT_RECORDING,$filter_by_not_revised,$filter_by_revised,$documentPath,$filter;
|
|
|
+ global $is_allowedToEdit, $is_tutor,$TBL_USER, $TBL_EXERCICES,$TBL_TRACK_HOTPOTATOES, $TBL_TRACK_EXERCICES, $TBL_TRACK_ATTEMPT_RECORDING,$filter_by_not_revised,$filter_by_revised,$documentPath,$filter;
|
|
|
$session_id_and = ' AND te.session_id = ' . api_get_session_id() . ' ';
|
|
|
+
|
|
|
+ $exercise_id = intval($_GET['exerciseId']);
|
|
|
+
|
|
|
if ($is_allowedToEdit || $is_tutor) {
|
|
|
$user_id_and = '';
|
|
|
if (!empty ($_POST['filter_by_user'])) {
|
|
@@ -835,8 +879,8 @@ function get_exam_results_data($from, $number_of_items, $column, $direction) {
|
|
|
}
|
|
|
|
|
|
$exercise_where = '';
|
|
|
- if (isset($_GET['exerciseId'])) {
|
|
|
- $exercise_where .= ' AND te.exe_exo_id = '.intval($_GET['exerciseId']).' ';
|
|
|
+ if (!empty($exercise_id)) {
|
|
|
+ $exercise_where .= ' AND te.exe_exo_id = '.$exercise_id.' ';
|
|
|
}
|
|
|
|
|
|
|
|
@@ -845,18 +889,17 @@ function get_exam_results_data($from, $number_of_items, $column, $direction) {
|
|
|
/*$sql="SELECT ".(api_is_western_name_order() ? "firstname as col0, lastname col1" : "lastname as col0, firstname as col1").", ce.title as extitle, te.exe_result as exresult ,
|
|
|
te.exe_weighting as exweight, te.exe_date as exdate, te.exe_id as exid, email as exemail, te.start_date as exstart, steps_counter as exstep,cuser.user_id as excruid,te.exe_duration as exduration
|
|
|
FROM $TBL_EXERCICES AS ce , $TBL_TRACK_EXERCICES AS te, $TBL_USER AS user,$tbl_course_rel_user AS cuser
|
|
|
- WHERE user.user_id=cuser.user_id AND cuser.relation_type<>".COURSE_RELATION_TYPE_RRHH." AND te.exe_exo_id = ce.id AND te.status != 'incomplete' AND cuser.user_id=te.exe_user_id AND te.exe_cours_id='" . Database :: escape_string($_cid) . "'
|
|
|
+ WHERE user.user_id=cuser.user_id AND cuser.relation_type<>".COURSE_RELATION_TYPE_RRHH." AND te.exe_exo_id = ce.id AND te.status != 'incomplete' AND cuser.user_id=te.exe_user_id AND te.exe_cours_id='" . Database :: escape_string(api_get_course_id()) . "'
|
|
|
$user_id_and $session_id_and AND ce.active <>-1 AND orig_lp_id = 0 AND orig_lp_item_id = 0
|
|
|
AND cuser.course_code=te.exe_cours_id ORDER BY col1, te.exe_cours_id ASC, ce.title ASC, te.exe_date DESC";*/
|
|
|
-
|
|
|
$sql="SELECT ".(api_is_western_name_order() ? "firstname as col0, lastname col1" : "lastname as col0, firstname as col1").", ce.title as col2, te.exe_result as exresult , te.exe_weighting as exweight,
|
|
|
te.exe_date as exdate, te.exe_id as exid, email as exemail, te.start_date as col4, steps_counter as exstep, exe_user_id as excruid,te.exe_duration as exduration
|
|
|
FROM $TBL_EXERCICES AS ce INNER JOIN $TBL_TRACK_EXERCICES AS te ON (te.exe_exo_id = ce.id) INNER JOIN $TBL_USER AS user ON (user.user_id = exe_user_id)
|
|
|
- WHERE te.status != 'incomplete' AND te.exe_cours_id='" . Database :: escape_string($_cid) . "' $user_id_and $session_id_and AND ce.active <>-1 AND orig_lp_id = 0 AND orig_lp_item_id = 0 $exercise_where ";
|
|
|
+ WHERE te.status != 'incomplete' AND te.exe_cours_id='" . api_get_course_id() . "' $user_id_and $session_id_and AND ce.active <>-1 AND orig_lp_id = 0 AND orig_lp_item_id = 0 $exercise_where ";
|
|
|
|
|
|
$hpsql="SELECT ".(api_is_western_name_order() ? "firstname as col0, lastname col1" : "lastname as col0, firstname as col1").", tth.exe_name, tth.exe_result , tth.exe_weighting, tth.exe_date
|
|
|
FROM $TBL_TRACK_HOTPOTATOES tth, $TBL_USER tu
|
|
|
- WHERE tu.user_id=tth.exe_user_id AND tth.exe_cours_id = '" . Database :: escape_string($_cid)."' $user_id_and $exercise_where
|
|
|
+ WHERE tu.user_id=tth.exe_user_id AND tth.exe_cours_id = '" . api_get_course_id()."' $user_id_and $exercise_where
|
|
|
ORDER BY tth.exe_cours_id ASC, tth.exe_date DESC";
|
|
|
|
|
|
|
|
@@ -874,26 +917,24 @@ function get_exam_results_data($from, $number_of_items, $column, $direction) {
|
|
|
AND cuser.relation_type<>".COURSE_RELATION_TYPE_RRHH." $user_id_and $session_id_and AND ce.active <>-1 AND" .
|
|
|
" orig_lp_id = 0 AND orig_lp_item_id = 0 AND cuser.course_code=te.exe_cours_id ORDER BY col1, te.exe_cours_id ASC, ce.title ASC, te.exe_date DESC";*/
|
|
|
|
|
|
-
|
|
|
-
|
|
|
$sql="SELECT ".(api_is_western_name_order() ? "firstname as col0, lastname col1" : "lastname as col0, firstname as col1")." , ce.title as col2, te.exe_result as exresult, " .
|
|
|
"te.exe_weighting as exweight, te.exe_date as exdate, te.exe_id as exid, email as exemail, " .
|
|
|
"te.start_date as col4, steps_counter as exstep, exe_user_id as excruid, te.exe_duration as exduration, ce.results_disabled as exdisabled
|
|
|
FROM $TBL_EXERCICES AS ce INNER JOIN $TBL_TRACK_EXERCICES AS te ON (te.exe_exo_id = ce.id) INNER JOIN $TBL_USER AS user ON (user.user_id = exe_user_id)
|
|
|
- WHERE te.status != 'incomplete' AND te.exe_cours_id='" . Database :: escape_string($_cid) . "' $user_id_and $session_id_and AND ce.active <>-1 AND orig_lp_id = 0 AND orig_lp_item_id = 0 ";
|
|
|
+ WHERE te.status != 'incomplete' AND te.exe_cours_id='" . api_get_course_id() . "' $user_id_and $session_id_and AND ce.active <>-1 AND orig_lp_id = 0 AND orig_lp_item_id = 0 ";
|
|
|
|
|
|
- $hpsql = "SELECT '',exe_name, exe_result , exe_weighting, exe_date
|
|
|
+ $hpsql = "SELECT '', exe_name, exe_result , exe_weighting, exe_date
|
|
|
FROM $TBL_TRACK_HOTPOTATOES
|
|
|
- WHERE exe_user_id = '" . $_user['user_id'] . "' AND exe_cours_id = '" . Database :: escape_string($_cid) . "'
|
|
|
+ WHERE exe_user_id = '" . api_get_user_id() . "' AND exe_cours_id = '" . api_get_course_id() . "'
|
|
|
ORDER BY exe_cours_id ASC, exe_date DESC";
|
|
|
}
|
|
|
|
|
|
|
|
|
- $column = intval($column);
|
|
|
- $from = intval($from);
|
|
|
- $number_of_items = intval($number_of_items);
|
|
|
- $sql .= " ORDER BY col$column $direction ";
|
|
|
- $sql .= " LIMIT $from,$number_of_items";
|
|
|
+ $column = intval($column);
|
|
|
+ $from = intval($from);
|
|
|
+ $number_of_items = intval($number_of_items);
|
|
|
+ $sql .= " ORDER BY col$column $direction ";
|
|
|
+ $sql .= " LIMIT $from, $number_of_items";
|
|
|
|
|
|
$results = array();
|
|
|
|
|
@@ -901,14 +942,14 @@ function get_exam_results_data($from, $number_of_items, $column, $direction) {
|
|
|
while ($rowx = Database::fetch_array($resx,'ASSOC')) {
|
|
|
$results[] = $rowx;
|
|
|
}
|
|
|
+
|
|
|
$hpresults = getManyResultsXCol($hpsql, 5);
|
|
|
|
|
|
$has_test_results = false;
|
|
|
$list_info = array();
|
|
|
|
|
|
// Print test results.
|
|
|
- $lang_nostartdate = get_lang('NoStartDate') . ' / ';
|
|
|
-
|
|
|
+ $lang_nostartdate = get_lang('NoStartDate') . ' / ';
|
|
|
|
|
|
if (is_array($results)) {
|
|
|
$has_test_results = true;
|
|
@@ -929,9 +970,8 @@ function get_exam_results_data($from, $number_of_items, $column, $direction) {
|
|
|
$more_details_list = '';
|
|
|
for ($i = 0; $i < $sizeof; $i++) {
|
|
|
$revised = false;
|
|
|
- $sql_exe = 'SELECT exe_id FROM ' . $TBL_TRACK_ATTEMPT_RECORDING . ' WHERE author != ' . "''" . ' AND exe_id = ' . Database :: escape_string($results[$i]['exid']) .' LIMIT 1';
|
|
|
+ $sql_exe = 'SELECT exe_id FROM ' . $TBL_TRACK_ATTEMPT_RECORDING . ' WHERE author != "" AND exe_id = ' . Database :: escape_string($results[$i]['exid']) .' LIMIT 1';
|
|
|
$query = Database::query($sql_exe);
|
|
|
-
|
|
|
if (Database :: num_rows($query) > 0) {
|
|
|
$revised = true;
|
|
|
}
|
|
@@ -941,6 +981,7 @@ function get_exam_results_data($from, $number_of_items, $column, $direction) {
|
|
|
if ($filter_by_revised && !$revised) {
|
|
|
continue;
|
|
|
}
|
|
|
+
|
|
|
if ($from_gradebook && ($is_allowedToEdit || $is_tutor)) {
|
|
|
if (in_array($results[$i]['col2'] . $results[$i]['col0'] . $results[$i]['col1'], $users_array_id)) {
|
|
|
continue;
|
|
@@ -1013,12 +1054,12 @@ function get_exam_results_data($from, $number_of_items, $column, $direction) {
|
|
|
$html_link.= "<a href='exercise_show.php?".api_get_cidreq()."&action=edit&id=$id'>".Display :: return_icon('edit.gif', get_lang('Edit'));
|
|
|
$html_link.= ' ';
|
|
|
} else {
|
|
|
- $html_link.="<a href='exercise_show.php?".api_get_cidreq()."&action=qualify&id=$id'>".Display :: return_icon('quizz_small.gif', get_lang('Qualify'));
|
|
|
+ $html_link.="<a href='exercise_show.php?".api_get_cidreq()."&action=qualify&id=$id'>".Display :: return_icon('quiz.gif', get_lang('Qualify'));
|
|
|
$html_link.=' ';
|
|
|
}
|
|
|
$html_link.="</a>";
|
|
|
if (api_is_platform_admin() || $is_tutor) {
|
|
|
- $html_link.=' <a href="exercice.php?'.api_get_cidreq().'&show=result&filter=' . $filter . '&delete=delete&did=' . $id . '" onclick="javascript:if(!confirm(\'' . sprintf(get_lang('DeleteAttempt'), $user, $dt) . '\')) return false;">'.Display :: return_icon('delete.gif', get_lang('Delete')).'</a>';
|
|
|
+ $html_link.=' <a href="exercice.php?'.api_get_cidreq().'&show=result&filter=' . $filter . '&exerciseId='.$exercise_id.'&delete=delete&did=' . $id . '" onclick="javascript:if(!confirm(\'' . sprintf(get_lang('DeleteAttempt'), $user, $dt) . '\')) return false;">'.Display :: return_icon('delete.png', get_lang('Delete')).'</a>';
|
|
|
$html_link.=' ';
|
|
|
}
|
|
|
if ($is_allowedToEdit) {
|