Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed small bug that was displaying fractions with too many decimal p…

…laces

(eg 0.9999 instead of just 1)
  • Loading branch information...
commit 3a50203f34cef1281b8e71f5aef3f6f27b5bb432 1 parent e386617
moodler authored
Showing with 4 additions and 2 deletions.
  1. +2 −1  mod/quiz/lib.php
  2. +2 −1  mod/quiz/question.php
View
3  mod/quiz/lib.php
@@ -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;
}
View
3  mod/quiz/question.php
@@ -235,6 +235,7 @@
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");
@@ -255,7 +256,7 @@
}
- $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;
Please sign in to comment.
Something went wrong with that request. Please try again.