From: defacer Date: Thu, 27 Jan 2005 02:45:38 +0000 (+0000) Subject: It seems that grades are saved with two decimal points of precision while X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=35f45a0d830428d0bd8dc472a905971e289cc5d3;p=moodle.git It seems that grades are saved with two decimal points of precision while they are being retrieved as integers. Changed it to two decimals everywhere and continuing to go about it... --- diff --git a/mod/quiz/locallib.php b/mod/quiz/locallib.php index e78b5fdb38..16710e8a39 100644 --- a/mod/quiz/locallib.php +++ b/mod/quiz/locallib.php @@ -1444,7 +1444,7 @@ function quiz_get_best_grade($quizid, $userid) { return NULL; } - return (round($grade->grade)); + return (round($grade->grade, 2)); } function quiz_save_best_grade($quiz, $userid) { @@ -1452,18 +1452,18 @@ function quiz_save_best_grade($quiz, $userid) { /// and then saves that grade in the quiz_grades table. if (!$attempts = quiz_get_user_attempts($quiz->id, $userid)) { - notify("Could not find any user attempts"); + notify('Could not find any user attempts'); return false; } $bestgrade = quiz_calculate_best_grade($quiz, $attempts); $bestgrade = (($bestgrade / $quiz->sumgrades) * $quiz->grade); - if ($grade = get_record("quiz_grades", "quiz", $quiz->id, "userid", $userid)) { + if ($grade = get_record('quiz_grades', 'quiz', $quiz->id, 'userid', $userid)) { $grade->grade = round($bestgrade, 2); $grade->timemodified = time(); - if (!update_record("quiz_grades", $grade)) { - notify("Could not update best grade"); + if (!update_record('quiz_grades', $grade)) { + notify('Could not update best grade'); return false; } } else { @@ -1471,8 +1471,8 @@ function quiz_save_best_grade($quiz, $userid) { $grade->userid = $userid; $grade->grade = round($bestgrade, 2); $grade->timemodified = time(); - if (!insert_record("quiz_grades", $grade)) { - notify("Could not insert new best grade"); + if (!insert_record('quiz_grades', $grade)) { + notify('Could not insert new best grade'); return false; } }