Skip to content

Commit

Permalink
Added some number rounding for grades to prevent PostgreSQL errors (M…
Browse files Browse the repository at this point in the history
…erged from MOODLE_15_STABLE mod/quiz/locallib.php)
  • Loading branch information
patrickslee committed Sep 19, 2005
1 parent 25c4cc5 commit 7b2523b
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions mod/quiz/questionlib.php
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit 7b2523b

Please sign in to comment.