diff --git a/main/tracking/exams.php b/main/tracking/exams.php index 1219969aa2..01e9b34839 100755 --- a/main/tracking/exams.php +++ b/main/tracking/exams.php @@ -5,7 +5,6 @@ * @package chamilo.tracking */ require_once '../inc/global.inc.php'; -//require_once api_get_path(LIBRARY_PATH).'pear/Spreadsheet_Excel_Writer/Writer.php'; $toolTable = Database::get_course_table(TABLE_TOOL_LIST); $quizTable = Database::get_course_table(TABLE_QUIZ_TEST); @@ -189,7 +188,7 @@ if (!empty($courseList) && is_array($courseList)) { if ($global) { $sql = "SELECT count(id) as count FROM $quizTable AS quiz - WHERE active='1' AND c_id = $courseId AND session_id = 0"; + WHERE active='1' AND c_id = $courseId AND (session_id = 0 OR session_id IS NULL)"; $result = Database::query($sql); $countExercises = Database::store_result($result); $exerciseCount = $countExercises[0]['count']; @@ -201,7 +200,7 @@ if (!empty($courseList) && is_array($courseList)) { $countExercises = Database::store_result($result); $exerciseSessionCount = $countExercises[0]['count']; - $exerciseCount = $exerciseCount + $exerciseCount *count($newSessionList) + $exerciseSessionCount; + $exerciseCount = $exerciseCount + $exerciseCount * count($newSessionList) + $exerciseSessionCount; // Add course and session list. if ($exerciseCount == 0) { @@ -238,7 +237,6 @@ if (!empty($courseList) && is_array($courseList)) { ORDER BY session_id, quiz.title ASC"; } else { - $sql = "SELECT quiz.title, id, session_id FROM $quizTable AS quiz WHERE @@ -254,7 +252,8 @@ if (!empty($courseList) && is_array($courseList)) { if (Database::num_rows($resultExercises) > 0) { $export_array_global = array(); - while ($exercise = Database::fetch_array($resultExercises)) { + while ($exercise = Database::fetch_array($resultExercises, 'ASSOC')) { + $exerciseSessionId = $exercise['session_id']; if (empty($exerciseSessionId)) { @@ -387,8 +386,10 @@ function sort_user($a, $b) { if ($a['score'] < $b['score']) { return 1; } + return 0; } + return 1; } @@ -482,6 +483,15 @@ function export_complete_report_xls($filename, $array) exit; } +/** + * @param $filter_score + * @param $global + * @param $exercise + * @param $courseInfo + * @param $sessionId + * @param $newSessionList + * @return array + */ function processStudentList($filter_score, $global, $exercise, $courseInfo, $sessionId, $newSessionList) { $exerciseStatsTable = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES); @@ -547,7 +557,7 @@ function processStudentList($filter_score, $global, $exercise, $courseInfo, $ses WHERE ex.c_id = $courseId AND ex.exe_exo_id = ".$exercise['id']." AND - exe_user_id='".$studentId."' AND + exe_user_id= $studentId AND session_id = $sessionId "; $result = Database::query($sql); @@ -556,7 +566,7 @@ function processStudentList($filter_score, $global, $exercise, $courseInfo, $ses $sql = "SELECT exe_id, exe_result, exe_weighting FROM $exerciseStatsTable WHERE - exe_user_id = ".$studentId." AND + exe_user_id = $studentId AND c_id = $courseId AND exe_exo_id = ".$exercise['id']." AND session_id = $sessionId