MDL-30873 quiz: display an overall grade for preview users.

Also, don't display an overall grade unless there is at least one finished attempt.
This commit is contained in:
Tim Hunt 2011-12-22 13:51:52 +00:00
parent 2117dcb591
commit ce70117bba

View File

@ -94,7 +94,16 @@ if ($unfinishedattempt = quiz_get_user_attempt_unfinished($quiz->id, $USER->id))
$numattempts = count($attempts);
// Work out the final grade, checking whether it was overridden in the gradebook.
if (!$canpreview) {
$mygrade = quiz_get_best_grade($quiz, $USER->id);
} else if ($lastfinishedattempt) {
// Users who can preview the quiz don't get a proper grade, so work out a
// plausible value to display instead, so the page looks right.
$mygrade = quiz_rescale_grade($lastfinishedattempt->sumgrades, $quiz, false);
} else {
$mygrade = null;
}
$mygradeoverridden = false;
$gradebookfeedback = '';
@ -137,7 +146,7 @@ if ($attempts) {
$viewobj->gradecolumn = $someoptions->marks >= question_display_options::MARK_AND_MAX &&
quiz_has_grades($quiz);
$viewobj->markcolumn = $viewobj->gradecolumn && ($quiz->grade != $quiz->sumgrades);
$viewobj->overallstats = $alloptions->marks >= question_display_options::MARK_AND_MAX;
$viewobj->overallstats = $lastfinishedattempt && $alloptions->marks >= question_display_options::MARK_AND_MAX;
$viewobj->feedbackcolumn = quiz_has_feedback($quiz) && $alloptions->overallfeedback;
} else {