Added some number rounding for grades to prevent PostgreSQL errors (Merged from MOODLE_15_STABLE mod/quiz/locallib.php)

This commit is contained in:
patrickslee
2005-09-19 00:26:23 +00:00
parent 25c4cc57f8
commit 7b2523bdba
+10
View File
@@ -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;
}