Permalink
Browse files

Added some number rounding for grades to prevent PostgreSQL errors (M…

…erged from MOODLE_15_STABLE mod/quiz/locallib.php)
  • Loading branch information...
1 parent 25c4cc5 commit 7b2523bdba4d77ecbd4ceb2c3e1f15597617dc85 patrickslee committed Sep 19, 2005
Showing with 10 additions and 0 deletions.
  1. +10 −0 mod/quiz/questionlib.php
View
@@ -321,6 +321,11 @@ function quiz_save_question_session(&$question, &$state) {
// Set the legacy answer field
$state->answer = isset($state->responses['']) ? $state->responses[''] : '';
+ // Round long raw_grade
+ if (strlen($state->raw_grade) > 10 && floatval($state->raw_grade) < 1) {
+ $state->raw_grade = strval(round($state->raw_grade,2));
+ }
+
// Save the state
if (isset($state->update)) {
update_record('quiz_states', $state);
@@ -658,6 +663,11 @@ function quiz_process_responses(&$question, &$state, $action, $cmoptions, &$atte
$attempt->sumgrades += (float)$state->last_graded->grade;
}
$attempt->timemodified = $action->timestamp;
+ // Round long sumgrades
+ if (strlen($attempt->sumgrades) > 10 && floatval($attempt->sumgrades) < 1) {
+ $attempt->sumgrades = strval(round($attempt->sumgrades,2));
+ }
+
return true;
}

0 comments on commit 7b2523b

Please sign in to comment.