diff --git a/mod/quiz/index.php b/mod/quiz/index.php index 912d40407fb..602564f8e3f 100644 --- a/mod/quiz/index.php +++ b/mod/quiz/index.php @@ -147,7 +147,7 @@ $feedback = ''; if ($quiz->grade && !is_null($bestgrade)) { if ($alloptions->scores) { - $grade = "$bestgrade / $quiz->grade"; + $grade = round($bestgrade, $quiz->decimalpoints) . ' / ' . $quiz->grade; } if ($alloptions->overallfeedback) { $feedback = quiz_feedback_for_grade($bestgrade, $quiz->id); diff --git a/mod/quiz/lib.php b/mod/quiz/lib.php index bf4dd5b51b7..0e79f02f07e 100644 --- a/mod/quiz/lib.php +++ b/mod/quiz/lib.php @@ -186,7 +186,7 @@ function quiz_get_best_grade($quiz, $userid) { // Need to detect errors/no result, without catching 0 scores. if (is_numeric($grade)) { - return round($grade, $quiz->decimalpoints); + return $grade + 0; } else { return NULL; } diff --git a/mod/quiz/locallib.php b/mod/quiz/locallib.php index 16a166ec235..b986592c9e3 100644 --- a/mod/quiz/locallib.php +++ b/mod/quiz/locallib.php @@ -429,7 +429,7 @@ function quiz_save_best_grade($quiz, $userid = null) { // Calculate the best grade $bestgrade = quiz_calculate_best_grade($quiz, $attempts); - $bestgrade = quiz_rescale_grade($bestgrade, $quiz); + $bestgrade = quiz_rescale_grade($bestgrade, $quiz, false); // Save the best grade in the database if ($grade = get_record('quiz_grades', 'quiz', $quiz->id, 'userid', $userid)) { diff --git a/mod/quiz/view.php b/mod/quiz/view.php index 98db79cd239..efd44c0fee5 100644 --- a/mod/quiz/view.php +++ b/mod/quiz/view.php @@ -267,11 +267,11 @@ } // Ouside the if because we may be showing feedback but not grades. - $attemptgrade = quiz_rescale_grade($attempt->sumgrades, $quiz); + $attemptgrade = quiz_rescale_grade($attempt->sumgrades, $quiz, false); if ($gradecolumn) { if ($attemptoptions->scores && $attempt->timefinish > 0) { - $formattedgrade = $attemptgrade; + $formattedgrade = round($attemptgrade, $quiz->decimalpoints); // highlight the highest grade if appropriate if ($overallstats && $numattempts > 1 && !is_null($mygrade) && $attemptgrade == $mygrade && $quiz->grademethod == QUIZ_GRADEHIGHEST) { $table->rowclass[$attempt->attempt] = 'bestrow'; @@ -313,7 +313,7 @@ if ($available && $moreattempts) { $a = new stdClass; $a->method = quiz_get_grading_option_name($quiz->grademethod); - $a->mygrade = $mygrade; + $a->mygrade = round($mygrade, $quiz->decimalpoints); $a->quizgrade = $quiz->grade; $resultinfo .= print_heading(get_string('gradesofar', 'quiz', $a), '', 2, 'main', true); } else {