mirror of
https://github.com/moodle/moodle.git
synced 2025-03-14 04:30:15 +01:00
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...
This commit is contained in:
parent
cb8057dee2
commit
35f45a0d83
@ -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;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user