Permalink
Browse files

Merge branch 'MDL-33532_22' of git://github.com/timhunt/moodle into M…

…OODLE_22_STABLE
  • Loading branch information...
2 parents 50eb136 + a41848a commit 1e93a653a474398020cf33a21214b640c0df22ef @danpoltawski danpoltawski committed Jun 7, 2012
Showing with 11 additions and 3 deletions.
  1. +8 −0 lib/moodlelib.php
  2. +3 −3 mod/quiz/edit.php
View
8 lib/moodlelib.php
@@ -133,6 +133,14 @@
/**
* PARAM_FLOAT - a real/floating point number.
+ *
+ * Note that you should not use PARAM_FLOAT for numbers typed in by the user.
+ * It does not work for languages that use , as a decimal separator.
+ * Instead, do something like
+ * $rawvalue = required_param('name', PARAM_RAW);
+ * // ... other code including require_login, which sets current lang ...
+ * $realvalue = unformat_float($rawvalue);
+ * // ... then use $realvalue
*/
define('PARAM_FLOAT', 'float');
View
6 mod/quiz/edit.php
@@ -318,7 +318,7 @@ function module_specific_controls($totalnumber, $recurse, $category, $cmid, $cmo
if (preg_match('!^g([0-9]+)$!', $key, $matches)) {
// Parse input for question -> grades
$questionid = $matches[1];
- $quiz->grades[$questionid] = clean_param($value, PARAM_FLOAT);
+ $quiz->grades[$questionid] = unformat_float($value);
quiz_update_question_instance($quiz->grades[$questionid], $questionid, $quiz);
$deletepreviews = true;
$recomputesummarks = true;
@@ -384,8 +384,8 @@ function module_specific_controls($totalnumber, $recurse, $category, $cmid, $cmo
$deletepreviews = true;
}
- // If rescaling is required save the new maximum
- $maxgrade = optional_param('maxgrade', -1, PARAM_FLOAT);
+ // If rescaling is required save the new maximum.
+ $maxgrade = unformat_float(optional_param('maxgrade', -1, PARAM_RAW));
if ($maxgrade >= 0) {
quiz_set_grade($maxgrade, $quiz);
}

0 comments on commit 1e93a65

Please sign in to comment.