diff --git a/mod/quiz/questionlib.php b/mod/quiz/questionlib.php index 309fd9b7b6d..b22bd30e8a0 100644 --- a/mod/quiz/questionlib.php +++ b/mod/quiz/questionlib.php @@ -510,10 +510,13 @@ function quiz_regrade_question_in_attempt($question, $attempt, $cmoptions, $verb $attempt)) { $verbose && notify("Couldn't regrade state #{$state->id}!"); } - if ((float)$replaystate->raw_grade != (float)$states[$j]->raw_grade) { - $changed++; + // We need rounding here because grades in the DB get truncated + // e.g. 0.33333 != 0.3333333, but we want them to be equal here + if (round((float)$replaystate->grade, 5) != round((float)$states[$j]->grade, 5)) { + $changed++; } + $replaystate->id = $states[$j]->id; $replaystate->update = true; quiz_save_question_session($question, $replaystate);