Permalink
Browse files

MDL-31594 question manual grading: did not handle comma as decimal.

  • Loading branch information...
1 parent 832626d commit 7d0f9cef347952bb38aea769fef606a6a2f8c01b @timhunt timhunt committed Mar 15, 2012
Showing with 12 additions and 2 deletions.
  1. +2 −2 question/engine/questionattempt.php
  2. +10 −0 question/engine/simpletest/testquestionattempt.php
@@ -884,10 +884,10 @@ public function get_submitted_var($name, $type, $postdata = null) {
case self::PARAM_MARK:
// Special case to work around PARAM_NUMBER converting '' to 0.
$mark = $this->get_submitted_var($name, PARAM_RAW_TRIMMED, $postdata);
- if ($mark === '') {
+ if ($mark === '' || is_null($mark)) {
return $mark;
} else {
- return $this->get_submitted_var($name, PARAM_NUMBER, $postdata);
+ return clean_param(str_replace(',', '.', $mark), PARAM_NUMBER);
}
case self::PARAM_FILES:
@@ -123,6 +123,16 @@ public function test_get_submitted_var_param_mark_number() {
'name', question_attempt::PARAM_MARK, array('name' => '123')));
}
+ public function test_get_submitted_var_param_mark_number_uk_decimal() {
+ $this->assertIdentical(123.45, $this->qa->get_submitted_var(
+ 'name', question_attempt::PARAM_MARK, array('name' => '123.45')));
+ }
+
+ public function test_get_submitted_var_param_mark_number_eu_decimal() {
+ $this->assertIdentical(123.45, $this->qa->get_submitted_var(
+ 'name', question_attempt::PARAM_MARK, array('name' => '123,45')));
+ }
+
public function test_get_submitted_var_param_mark_invalid() {
$this->assertIdentical(0.0, $this->qa->get_submitted_var(
'name', question_attempt::PARAM_MARK, array('name' => 'frog')));

0 comments on commit 7d0f9ce

Please sign in to comment.