From: tjhunt Date: Wed, 18 Mar 2009 05:16:49 +0000 (+0000) Subject: quiz outline report: MDL-18285 Show regrade date, not last attempt date. X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=5ecfab51488d4c648f3d32912ad3575f8d241b23;p=moodle.git quiz outline report: MDL-18285 Show regrade date, not last attempt date. I also took the opportunity to clean up the code a bit. --- diff --git a/mod/quiz/lib.php b/mod/quiz/lib.php index 1562b26869..24e7a97f7d 100644 --- a/mod/quiz/lib.php +++ b/mod/quiz/lib.php @@ -217,16 +217,16 @@ function quiz_user_outline($course, $user, $mod, $quiz) { /// Used for user activity reports. /// $return->time = the time they did it /// $return->info = a short text description - if ($grade = $DB->get_record('quiz_grades', array('userid' => $user->id, 'quiz' => $quiz->id))) { - $result = new stdClass; - if ((float)$grade->grade) { - $result->info = get_string('grade').': '.quiz_format_grade($quiz, $grade->grade); - } - $result->time = $grade->timemodified; - return $result; + $grade = quiz_get_best_grade($quiz, $user->id); + if (is_null($grade)) { + return NULL; + } + + $result = new stdClass; + $result->info = get_string('grade') . ': ' . $grade . '/' . $quiz->grade; + $result->time = get_field('quiz_attempts', 'MAX(timefinish)', 'userid', $user->id, 'quiz', $quiz->id); + return $result; } - return NULL; -} /** * Is this a graded quiz? If this method returns true, you can assume that @@ -265,9 +265,9 @@ function quiz_user_complete($course, $user, $mod, $quiz) { /// Print a detailed representation of what a user has done with /// a given particular instance of this module, for user activity reports. - if ($attempts = $DB->get_records_select('quiz_attempts', "userid=? AND quiz=?", array($user->id, $quiz->id), 'attempt ASC')) { + if ($attempts = $DB->get_records('quiz_attempts', array('userid' => $user->id, 'quiz' => $quiz->id), 'attempt')) { if (quiz_has_grades($quiz) && $grade = quiz_get_best_grade($quiz, $user->id)) { - echo get_string('grade') . ': ' . $grade . '/' . $quiz->grade . '
'; + echo get_string('grade') . ': ' . $grade . '/' . quiz_format_grade($quiz, $quiz->grade) . '
'; } foreach ($attempts as $attempt) { echo get_string('attempt', 'quiz').' '.$attempt->attempt.': ';