]> git.mjollnir.org Git - moodle.git/commitdiff
quiz outline report: MDL-18285 Show regrade date, not last attempt date.
authortjhunt <tjhunt>
Wed, 18 Mar 2009 05:16:49 +0000 (05:16 +0000)
committertjhunt <tjhunt>
Wed, 18 Mar 2009 05:16:49 +0000 (05:16 +0000)
I also took the opportunity to clean up the code a bit.

mod/quiz/lib.php

index 1562b2686941178505802b736293872d7ec33311..24e7a97f7dfd83353393c4b3b3d80df8cfa96976 100644 (file)
@@ -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').':&nbsp;'.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 . '<br />';
+            echo get_string('grade') . ': ' . $grade . '/' . quiz_format_grade($quiz, $quiz->grade) . '<br />';
         }
         foreach ($attempts as $attempt) {
             echo get_string('attempt', 'quiz').' '.$attempt->attempt.': ';