Permalink
Browse files

MDL-26505 rounding problem in quiz_save_best_grade.

Note I cheated and slipped in a fix for another instance of MDL-21811 too, since I noticed it at the same time.
  • Loading branch information...
1 parent 0af9124 commit 49b252149234232745766d6c913c75fb32140c6b @timhunt timhunt committed Feb 18, 2011
Showing with 6 additions and 6 deletions.
  1. +1 −1 mod/quiz/index.php
  2. +1 −1 mod/quiz/lib.php
  3. +1 −1 mod/quiz/locallib.php
  4. +3 −3 mod/quiz/view.php
View
2 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);
View
2 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;
}
View
2 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)) {
View
6 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 {

0 comments on commit 49b2521

Please sign in to comment.