unset($this->_form->_defaultValues["tolerance[{$key}]"]);
$question->tolerance[$key] = $answer->tolerance;
+
+ if (is_numeric($question->answer[$key])) {
+ $question->answer[$key] = format_float($question->answer[$key], strlen($question->answer[$key]), true, true);
+ }
+
$key++;
}
}
/**
- * @return book If the student's response contains a '.' or a ',' that
+ * @return bool If the student's response contains a '.' or a ',' that
* matches the thousands separator in the current locale. In this case, the
* parsing in apply_unit can give a result that the student did not expect.
*/
if (strpos($response, '.') !== false || substr_count($response, ',') > 1) {
$response = str_replace(',', '', $response);
} else {
- $response = str_replace(',', '.', $response);
+ $response = str_replace([$this->thousandssep, $this->decsep, ','], ['', '.', '.'], $response);
}
$regex = '[+-]?(?:\d+(?:\\.\d*)?|\\.\d+)(?:e[-+]?\d+)?';