Skip to content

Commit

Permalink
MDL-30873 quiz: display an overall grade for preview users.
Browse files Browse the repository at this point in the history
Also, don't display an overall grade unless there is at least one finished attempt.
  • Loading branch information
timhunt committed Dec 23, 2011
1 parent ddb7ae2 commit aff96ba
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions mod/quiz/view.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,16 @@
$numattempts = count($attempts);

// Work out the final grade, checking whether it was overridden in the gradebook.
$mygrade = quiz_get_best_grade($quiz, $USER->id);
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 = '';

Expand Down Expand Up @@ -143,7 +152,7 @@
$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 {
Expand Down

0 comments on commit aff96ba

Please sign in to comment.