Fixed small bug that was displaying fractions with too many decimal places
authormoodler <moodler>
Sat, 26 Oct 2002 06:11:43 +0000 (06:11 +0000)
committermoodler <moodler>
Sat, 26 Oct 2002 06:11:43 +0000 (06:11 +0000)
(eg 0.9999 instead of just 1)

mod/quiz/lib.php
mod/quiz/question.php

index 8156b28..afb4351 100644 (file)
@@ -1016,7 +1016,7 @@ function quiz_grade_attempt_results($quiz, $questions) {
             $grade = 0.0;
         }
 
-        $result->grades[$question->id] = $grade;
+        $result->grades[$question->id] = round($grade, 2);
         $result->sumgrades += $grade;
         $result->feedback[$question->id] = $feedback;
         $result->response[$question->id] = $response;
@@ -1026,6 +1026,7 @@ function quiz_grade_attempt_results($quiz, $questions) {
     $fraction = (float)($result->sumgrades / $quiz->sumgrades);
     $result->percentage = format_float($fraction * 100.0);
     $result->grade      = format_float($fraction * $quiz->grade);
+    $result->sumgrades = round($result->sumgrades, 2);
 
     return $result;
 }
index 14b594e..43b5b25 100644 (file)
                         exit;
                     }
                 } else {
+                    $totalfraction = round($totalfraction,2);
                     if ($totalfraction != 1) {
                         $totalfraction = $totalfraction * 100;
                         notice_yesno(get_string("fractionsaddwrong", "quiz", $totalfraction), "question.php?id=$question->id", "edit.php");
 
     } 
 
-    $grades = array(1,0.9,0.8,0.75,0.70,0.6666,0.60,0.50,0.40,0.3333,0.30,0.25,0.20,0.10,0.05,0);
+    $grades = array(1,0.9,0.8,0.75,0.70,0.66666,0.60,0.50,0.40,0.33333,0.30,0.25,0.20,0.10,0.05,0);
     foreach ($grades as $grade) {
         $percentage = 100 * $grade;
         $neggrade = -$grade;