Skip to content
Browse files

MDL-32940 libraries: Replaced deprecated PARAM_NUMBER with PARAM_FLOAT

  • Loading branch information...
1 parent 3294034 commit 61cca0b7fc30dccf8925889038c93e9b6b479e38 @rajeshtaneja rajeshtaneja committed May 11, 2012
View
2 enrol/externallib.php
@@ -257,7 +257,7 @@ public static function get_enrolled_users_returns() {
return new external_multiple_structure(
new external_single_structure(
array(
- 'id' => new external_value(PARAM_NUMBER, 'ID of the user'),
+ 'id' => new external_value(PARAM_INT, 'ID of the user'),
'username' => new external_value(PARAM_RAW, 'Username policy is defined in Moodle security config', VALUE_OPTIONAL),
'firstname' => new external_value(PARAM_NOTAGS, 'The first name(s) of the user', VALUE_OPTIONAL),
'lastname' => new external_value(PARAM_NOTAGS, 'The family name of the user', VALUE_OPTIONAL),
View
2 grade/edit/tree/index.php
@@ -272,7 +272,7 @@
$aid = $matches[2];
$value = unformat_float($value);
- $value = clean_param($value, PARAM_NUMBER);
+ $value = clean_param($value, PARAM_FLOAT);
$grade_item = grade_item::fetch(array('id'=>$aid, 'courseid'=>$courseid));
View
2 lib/form/duration.php
@@ -188,7 +188,7 @@ function onQuickFormEvent($event, $arg, &$caller) {
if ($arg[2]['optional']) {
$caller->disabledIf($arg[0], $arg[0] . '[enabled]');
}
- $caller->setType($arg[0] . '[number]', PARAM_NUMBER);
+ $caller->setType($arg[0] . '[number]', PARAM_FLOAT);
return parent::onQuickFormEvent($event, $arg, $caller);
break;
View
2 lib/moodlelib.php
@@ -259,6 +259,7 @@
/**
* PARAM_NUMBER - deprecated alias of PARAM_FLOAT
+ * @deprecated since 2.0
*/
define('PARAM_NUMBER', 'float');
@@ -765,7 +766,6 @@ function clean_param($param, $type) {
return (int)$param; // Convert to integer
case PARAM_FLOAT:
- case PARAM_NUMBER:
return (float)$param; // Convert to float
case PARAM_ALPHA: // Remove everything not a-z
View
2 lib/portfoliolib.php
@@ -139,7 +139,7 @@ public function __construct($options=null) {
* @param array $argarray This can be an array or hash of arguments to pass
* back to the callback functions (passed by reference)
* these MUST be primatives to be added as hidden form fields.
- * and the values get cleaned to PARAM_ALPHAEXT or PARAM_NUMBER or PARAM_PATH
+ * and the values get cleaned to PARAM_ALPHAEXT or PARAM_FLOAT or PARAM_PATH
* @param string $file This can be autodetected if it's in the same file as your caller,
* but often, the caller is a script.php and the class in a lib.php
* so you can pass it here if necessary.
View
2 mod/quiz/mod_form.php
@@ -115,7 +115,7 @@ protected function definition() {
$mform->removeElement('grade');
$mform->addElement('hidden', 'grade', $quizconfig->maximumgrade);
- $mform->setType('grade', PARAM_NUMBER);
+ $mform->setType('grade', PARAM_FLOAT);
// Number of attempts.
$attemptoptions = array('0' => get_string('unlimited'));
View
2 portfolio/add.php
@@ -165,7 +165,7 @@
foreach (array_keys(array_merge($_GET, $_POST)) as $key) {
if (strpos($key, 'ca_') === 0) {
if (!$value = optional_param($key, false, PARAM_ALPHAEXT)) {
- if (!$value = optional_param($key, false, PARAM_NUMBER)) {
+ if (!$value = optional_param($key, false, PARAM_FLOAT)) {
$value = optional_param($key, false, PARAM_PATH);
}
}
View
8 question/behaviour/behaviourbase.php
@@ -232,7 +232,7 @@ public function get_expected_data() {
$vars = array('comment' => PARAM_RAW);
if ($this->qa->get_max_mark()) {
$vars['mark'] = question_attempt::PARAM_MARK;
- $vars['maxmark'] = PARAM_NUMBER;
+ $vars['maxmark'] = PARAM_FLOAT;
}
return $vars;
}
@@ -477,9 +477,9 @@ public function process_comment(question_attempt_pending_step $pendingstep) {
*/
public static function is_manual_grade_in_range($qubaid, $slot) {
$prefix = 'q' . $qubaid . ':' . $slot . '_';
- $mark = optional_param($prefix . '-mark', null, PARAM_NUMBER);
- $maxmark = optional_param($prefix . '-maxmark', null, PARAM_NUMBER);
- $minfraction = optional_param($prefix . ':minfraction', null, PARAM_NUMBER);
+ $mark = optional_param($prefix . '-mark', null, PARAM_FLOAT);
+ $maxmark = optional_param($prefix . '-maxmark', null, PARAM_FLOAT);
+ $minfraction = optional_param($prefix . ':minfraction', null, PARAM_FLOAT);
return is_null($mark) || ($mark >= $minfraction * $maxmark && $mark <= $maxmark);
}
View
6 question/engine/questionattempt.php
@@ -49,7 +49,7 @@ class question_attempt {
const USE_RAW_DATA = 'use raw data';
/**
- * @var string special value used by manual grading because {@link PARAM_NUMBER}
+ * @var string special value used by manual grading because {@link PARAM_FLOAT}
* converts '' to 0.
*/
const PARAM_MARK = 'parammark';
@@ -882,12 +882,12 @@ protected function get_resume_data() {
public function get_submitted_var($name, $type, $postdata = null) {
switch ($type) {
case self::PARAM_MARK:
- // Special case to work around PARAM_NUMBER converting '' to 0.
+ // Special case to work around PARAM_FLOAT converting '' to 0.
$mark = $this->get_submitted_var($name, PARAM_RAW_TRIMMED, $postdata);
if ($mark === '' || is_null($mark)) {
return $mark;
} else {
- return clean_param(str_replace(',', '.', $mark), PARAM_NUMBER);
+ return clean_param(str_replace(',', '.', $mark), PARAM_FLOAT);
}
case self::PARAM_FILES:
View
2 question/previewlib.php
@@ -148,7 +148,7 @@ protected function get_user_pref_fields() {
protected function get_field_types() {
return array(
'behaviour' => PARAM_ALPHA,
- 'maxmark' => PARAM_NUMBER,
+ 'maxmark' => PARAM_FLOAT,
'variant' => PARAM_INT,
'correctness' => PARAM_BOOL,
'marks' => PARAM_INT,
View
4 question/type/calculated/datasetitems_form.php
@@ -138,7 +138,7 @@ protected function definition() {
$name = get_string('wildcard', 'qtype_calculated', $datasetdef->name);
}
$mform->addElement('text', "number[$j]", $name);
- $mform->setType("number[$j]", PARAM_NUMBER);
+ $mform->setType("number[$j]", PARAM_FLOAT);
$this->qtypeobj->custom_generator_tools_part($mform, $idx, $j);
$idx++;
$mform->addElement('hidden', "definition[$j]");
@@ -288,7 +288,7 @@ protected function definition() {
} else {
$mform->addElement('hidden', "number[$j]" , '');
}
- $mform->setType("number[$j]", PARAM_NUMBER);
+ $mform->setType("number[$j]", PARAM_FLOAT);
$mform->addElement('hidden', "itemid[$j]");
$mform->setType("itemid[$j]", PARAM_INT);
View
4 question/type/calculated/questiontype.php
@@ -712,8 +712,8 @@ public function custom_generator_tools_part($mform, $idx, $j) {
get_string('calcmax', 'qtype_calculated'));
$mform->addGroup($minmaxgrp, 'minmaxgrp',
get_string('minmax', 'qtype_calculated'), ' - ', false);
- $mform->setType("calcmin[$idx]", PARAM_NUMBER);
- $mform->setType("calcmax[$idx]", PARAM_NUMBER);
+ $mform->setType("calcmin[$idx]", PARAM_FLOAT);
+ $mform->setType("calcmax[$idx]", PARAM_FLOAT);
$precisionoptions = range(0, 10);
$mform->addElement('select', "calclength[$idx]",
View
6 question/type/calculatedmulti/edit_calculatedmulti_form.php
@@ -82,7 +82,7 @@ public function get_per_answer_fields($mform, $label, $gradeoptions,
$addrepeated = array();
$addrepeated[] = $mform->createElement('hidden', 'tolerance');
$addrepeated[] = $mform->createElement('hidden', 'tolerancetype', 1);
- $repeatedoptions['tolerance']['type'] = PARAM_NUMBER;
+ $repeatedoptions['tolerance']['type'] = PARAM_FLOAT;
$repeatedoptions['tolerance']['default'] = 0.01;
$addrepeated[] = $mform->createElement('select', 'correctanswerlength',
@@ -157,8 +157,8 @@ protected function definition_inner($mform) {
optional_param("unit[$i]", '', PARAM_NOTAGS));
$mform->setType('unit'."[$i]", PARAM_NOTAGS);
$mform->addElement('hidden', 'multiplier'."[$i]",
- optional_param("multiplier[$i]", '', PARAM_NUMBER));
- $mform->setType("multiplier[$i]", PARAM_NUMBER);
+ optional_param("multiplier[$i]", '', PARAM_FLOAT));
+ $mform->setType("multiplier[$i]", PARAM_FLOAT);
}
$this->add_combined_feedback_fields(true);
View
12 question/type/calculatedsimple/edit_calculatedsimple_form.php
@@ -146,9 +146,9 @@ public function __construct($submiturl, $question, $category, $contexts, $formed
if ($dummyform->answer = optional_param_array('answer', '', PARAM_NOTAGS)) {
// there is always at least one answer...
- $fraction = optional_param_array('fraction', '', PARAM_NUMBER);
- $tolerance = optional_param_array('tolerance', '', PARAM_NUMBER);
- $tolerancetype = optional_param_array('tolerancetype', '', PARAM_NUMBER);
+ $fraction = optional_param_array('fraction', '', PARAM_FLOAT);
+ $tolerance = optional_param_array('tolerance', '', PARAM_FLOAT);
+ $tolerancetype = optional_param_array('tolerancetype', '', PARAM_FLOAT);
$correctanswerlength = optional_param_array('correctanswerlength', '', PARAM_INT);
$correctanswerformat = optional_param_array('correctanswerformat', '', PARAM_INT);
@@ -169,9 +169,9 @@ public function __construct($submiturl, $question, $category, $contexts, $formed
$this->datasetdefs = array();
// rebuild datasetdefs from old values
if ($olddef = optional_param_array('datasetdef', '', PARAM_RAW)) {
- $calcmin = optional_param_array('calcmin', '', PARAM_NUMBER);
+ $calcmin = optional_param_array('calcmin', '', PARAM_FLOAT);
$calclength = optional_param_array('calclength', '', PARAM_INT);
- $calcmax = optional_param_array('calcmax', '', PARAM_NUMBER);
+ $calcmax = optional_param_array('calcmax', '', PARAM_FLOAT);
$oldoptions = optional_param_array('defoptions', '', PARAM_RAW);
$newdatasetvalues = false;
$sizeofolddef = count($olddef);
@@ -507,7 +507,7 @@ protected function definition_inner($mform) {
$mform->addElement('hidden', "number[$j]", get_string(
'wildcard', 'qtype_calculatedsimple', $datasetdef->name));
}
- $mform->setType("number[$j]", PARAM_NUMBER);
+ $mform->setType("number[$j]", PARAM_FLOAT);
$mform->addElement('hidden', "itemid[$j]");
$mform->setType("itemid[$j]", PARAM_INT);
View
4 question/type/calculatedsimple/questiontype.php
@@ -249,8 +249,8 @@ public function custom_generator_tools_part($mform, $idx, $j) {
get_string('calcmax', 'qtype_calculated'));
$mform->addGroup($minmaxgrp, 'minmaxgrp',
get_string('minmax', 'qtype_calculated'), ' - ', false);
- $mform->setType("calcmin[$idx]", PARAM_NUMBER);
- $mform->setType("calcmax[$idx]", PARAM_NUMBER);
+ $mform->setType("calcmin[$idx]", PARAM_FLOAT);
+ $mform->setType("calcmax[$idx]", PARAM_FLOAT);
$precisionoptions = range(0, 10);
$mform->addElement('select', "calclength[$idx]",
View
6 question/type/numerical/edit_numerical_form.php
@@ -55,7 +55,7 @@ protected function get_per_answer_fields($mform, $label, $gradeoptions,
$tolerance = $mform->createElement('text', 'tolerance',
get_string('acceptederror', 'qtype_numerical'));
- $repeatedoptions['tolerance']['type'] = PARAM_NUMBER;
+ $repeatedoptions['tolerance']['type'] = PARAM_FLOAT;
$repeatedoptions['tolerance']['default'] = 0;
array_splice($repeated, 3, 0, array($tolerance));
$repeated[1]->setSize(10);
@@ -83,7 +83,7 @@ protected function add_unit_options($mform) {
$penaltygrp = array();
$penaltygrp[] = $mform->createElement('text', 'unitpenalty',
get_string('unitpenalty', 'qtype_numerical'), array('size' => 6));
- $mform->setType('unitpenalty', PARAM_NUMBER);
+ $mform->setType('unitpenalty', PARAM_FLOAT);
$mform->setDefault('unitpenalty', 0.1000000);
$unitgradingtypes = array(
@@ -137,7 +137,7 @@ protected function add_unit_fields($mform) {
);
$repeatedoptions['unit']['type'] = PARAM_NOTAGS;
- $repeatedoptions['multiplier']['type'] = PARAM_NUMBER;
+ $repeatedoptions['multiplier']['type'] = PARAM_FLOAT;
$repeatedoptions['unit']['disabledif'] =
array('unitrole', 'eq', qtype_numerical::UNITNONE);
$repeatedoptions['multiplier']['disabledif'] =
View
2 question/type/numerical/questiontype.php
@@ -105,7 +105,7 @@ public function get_numerical_units(&$question) {
$units = array();
}
foreach ($units as $key => $unit) {
- $units[$key]->multiplier = clean_param($unit->multiplier, PARAM_NUMBER);
+ $units[$key]->multiplier = clean_param($unit->multiplier, PARAM_FLOAT);
}
$question->options->units = $units;
return true;
View
8 user/externallib.php
@@ -275,7 +275,7 @@ public static function update_users_parameters() {
'users' => new external_multiple_structure(
new external_single_structure(
array(
- 'id' => new external_value(PARAM_NUMBER, 'ID of the user'),
+ 'id' => new external_value(PARAM_INT, 'ID of the user'),
'username' => new external_value(PARAM_USERNAME, 'Username policy is defined in Moodle security config. Must be lowercase.', VALUE_OPTIONAL, '',NULL_NOT_ALLOWED),
'password' => new external_value(PARAM_RAW, 'Plain text password consisting of any characters', VALUE_OPTIONAL, '',NULL_NOT_ALLOWED),
'firstname' => new external_value(PARAM_NOTAGS, 'The first name(s) of the user', VALUE_OPTIONAL, '',NULL_NOT_ALLOWED),
@@ -446,7 +446,7 @@ public static function get_users_by_id_returns() {
return new external_multiple_structure(
new external_single_structure(
array(
- 'id' => new external_value(PARAM_NUMBER, 'ID of the user'),
+ 'id' => new external_value(PARAM_INT, 'ID of the user'),
'username' => new external_value(PARAM_RAW, 'Username policy is defined in Moodle security config', VALUE_OPTIONAL),
'firstname' => new external_value(PARAM_NOTAGS, 'The first name(s) of the user', VALUE_OPTIONAL),
'lastname' => new external_value(PARAM_NOTAGS, 'The family name of the user', VALUE_OPTIONAL),
@@ -466,7 +466,7 @@ public static function get_users_by_id_returns() {
'firstaccess' => new external_value(PARAM_INT, 'first access to the site (0 if never)', VALUE_OPTIONAL),
'lastaccess' => new external_value(PARAM_INT, 'last access to the site (0 if never)', VALUE_OPTIONAL),
'auth' => new external_value(PARAM_PLUGIN, 'Auth plugins include manual, ldap, imap, etc', VALUE_OPTIONAL),
- 'confirmed' => new external_value(PARAM_NUMBER, 'Active user: 1 if confirmed, 0 otherwise', VALUE_OPTIONAL),
+ 'confirmed' => new external_value(PARAM_INT, 'Active user: 1 if confirmed, 0 otherwise', VALUE_OPTIONAL),
'idnumber' => new external_value(PARAM_RAW, 'An arbitrary ID code number perhaps from the institution', VALUE_OPTIONAL),
'lang' => new external_value(PARAM_SAFEDIR, 'Language code such as "en", must exist on server', VALUE_OPTIONAL),
'theme' => new external_value(PARAM_PLUGIN, 'Theme name such as "standard", must exist on server', VALUE_OPTIONAL),
@@ -598,7 +598,7 @@ public static function get_course_user_profiles_returns() {
return new external_multiple_structure(
new external_single_structure(
array(
- 'id' => new external_value(PARAM_NUMBER, 'ID of the user'),
+ 'id' => new external_value(PARAM_INT, 'ID of the user'),
'username' => new external_value(PARAM_RAW, 'Username policy is defined in Moodle security config', VALUE_OPTIONAL),
'firstname' => new external_value(PARAM_NOTAGS, 'The first name(s) of the user', VALUE_OPTIONAL),
'lastname' => new external_value(PARAM_NOTAGS, 'The family name of the user', VALUE_OPTIONAL),

0 comments on commit 61cca0b

Please sign in to comment.
Something went wrong with that request. Please try again.