quiz outline report: MDL-18285 Show regrade date, not last attempt date.

I also took the opportunity to clean up the code a bit.
This commit is contained in:
tjhunt 2009-03-18 05:16:49 +00:00
parent 353b2d700d
commit 5ecfab5148

View file

@ -217,16 +217,16 @@ function quiz_user_outline($course, $user, $mod, $quiz) {
/// Used for user activity reports. /// Used for user activity reports.
/// $return->time = the time they did it /// $return->time = the time they did it
/// $return->info = a short text description /// $return->info = a short text description
if ($grade = $DB->get_record('quiz_grades', array('userid' => $user->id, 'quiz' => $quiz->id))) { $grade = quiz_get_best_grade($quiz, $user->id);
$result = new stdClass; if (is_null($grade)) {
if ((float)$grade->grade) { return NULL;
$result->info = get_string('grade').': '.quiz_format_grade($quiz, $grade->grade); }
}
$result->time = $grade->timemodified; $result = new stdClass;
return $result; $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 * 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 /// Print a detailed representation of what a user has done with
/// a given particular instance of this module, for user activity reports. /// 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)) { 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) { foreach ($attempts as $attempt) {
echo get_string('attempt', 'quiz').' '.$attempt->attempt.': '; echo get_string('attempt', 'quiz').' '.$attempt->attempt.': ';