@ -1307,7 +1307,7 @@ function get_exercise_result_ranking($my_score, $my_exe_id, $exercise_id, $cours
/**
* Gets the position of the score based in a given score (result/weight) and the exe_id based in all attempts
* (NO Exercises in LPs ) old funcionality
* (NO Exercises in LPs ) old funcionality by attempt
* @param float user score to be compared attention => score/weight
* @param int exe id of the exercise (this is necesary because if 2 students have the same score the one with the minor exe_id will have a best position, just to be fair and FIFO)
* @param int exercise id
@ -1368,7 +1368,7 @@ function get_exercise_result_ranking_by_attempt($my_score, $my_exe_id, $exercise
* Get the best score in a exercise (NO Exercises in LPs )
*/
function get_best_attempt_score($exercise_id, $course_code, $session_id) {
function get_best_attempt_in_course($exercise_id, $course_code, $session_id) {
$sql = "SELECT * FROM $TABLETRACK_EXERCICES WHERE status = '' AND exe_cours_id = '$course_code' AND exe_exo_id = '$exercise_id' AND session_id = $session_id AND orig_lp_id =0 AND orig_lp_item_id = 0 ORDER BY exe_id";
$sql = "SELECT * FROM $table_track_exercises WHERE status = '' AND exe_cours_id = '$course_code' AND exe_exo_id = '$exercise_id' AND session_id = $session_id AND orig_lp_id =0 AND orig_lp_item_id = 0 ORDER BY exe_id";
$session_id = intval($session_id);
$select = '*';
if ($get_count) {
$select = 'count(*) as count';
}
$sql = "SELECT $select FROM $table_track_exercises WHERE status = '' AND exe_cours_id = '$course_code' AND session_id = $session_id AND orig_lp_id =0 AND orig_lp_item_id = 0 ORDER BY exe_id";
$sql = "SELECT $select FROM $table_track_exercises WHERE status = '' AND exe_cours_id = '$course_code' AND session_id = $session_id AND orig_lp_id =0 AND orig_lp_item_id = 0 ORDER BY exe_id";
$user_id = intval($user_id);
$sql = "SELECT * FROM $table_track_exercises WHERE status = '' AND exe_user_id = $user_id AND exe_cours_id = '$course_code' AND exe_exo_id = $exercise_id AND session_id = $session_id AND orig_lp_id = 0 AND orig_lp_item_id = 0 ORDER by exe_id";
$sql = "SELECT count(*) as count FROM $TABLETRACK_EXERCICES WHERE status = '' AND exe_user_id = '$user_id' AND exe_cours_id = '$course_code' AND exe_exo_id = '$exercise_id' AND session_id = $session_id AND orig_lp_id =0 AND orig_lp_item_id = 0 ORDER BY exe_id";
//echo '<br>';
$res = Database::query($sql);
$result = 0;
if (Database::num_rows($res) > 0 ) {
$row = Database::fetch_array($res,'ASSOC');
$result = $row['count'];
}
return $result;
}
/**
* Gets all exercise BEST results attempts (NO Exercises in LPs ) from a given exercise id, course, session per user
* @param int exercise id
* @param string course code
* @param int session id
* @return array with the results
*
*/
function get_best_exercise_results_by_user($exercise_id, $course_code, $session_id = 0) {
$sql = "SELECT * FROM $table_track_exercises WHERE status = '' AND exe_cours_id = '$course_code' AND exe_exo_id = $exercise_id AND session_id = $session_id AND orig_lp_id = 0 AND orig_lp_item_id = 0 AND exe_user_id = $user_id ORDER by exe_id";
$sql = "SELECT * FROM $table_track_exercises WHERE status = '' AND exe_cours_id = '$course_code' AND exe_exo_id = '$exercise_id' AND session_id = $session_id AND orig_lp_id =0 AND orig_lp_item_id = 0 ORDER BY exe_id";
$res = Database::query($sql);
$list = array();
@ -807,8 +816,25 @@ function get_all_exercise_results_by_user($user_id, $exercise_id, $course_code,