From 61cca0b7fc30dccf8925889038c93e9b6b479e38 Mon Sep 17 00:00:00 2001 From: Rajesh Taneja Date: Fri, 11 May 2012 11:34:34 +0800 Subject: [PATCH] MDL-32940 libraries: Replaced deprecated PARAM_NUMBER with PARAM_FLOAT --- enrol/externallib.php | 2 +- grade/edit/tree/index.php | 2 +- lib/form/duration.php | 2 +- lib/moodlelib.php | 2 +- lib/portfoliolib.php | 2 +- mod/quiz/mod_form.php | 2 +- portfolio/add.php | 2 +- question/behaviour/behaviourbase.php | 8 ++++---- question/engine/questionattempt.php | 6 +++--- question/previewlib.php | 2 +- question/type/calculated/datasetitems_form.php | 4 ++-- question/type/calculated/questiontype.php | 4 ++-- .../calculatedmulti/edit_calculatedmulti_form.php | 6 +++--- .../calculatedsimple/edit_calculatedsimple_form.php | 12 ++++++------ question/type/calculatedsimple/questiontype.php | 4 ++-- question/type/numerical/edit_numerical_form.php | 6 +++--- question/type/numerical/questiontype.php | 2 +- user/externallib.php | 8 ++++---- 18 files changed, 38 insertions(+), 38 deletions(-) diff --git a/enrol/externallib.php b/enrol/externallib.php index 147383c9808e4..7587484505e4c 100644 --- a/enrol/externallib.php +++ b/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), diff --git a/grade/edit/tree/index.php b/grade/edit/tree/index.php index 801c9efb310d8..ea83969cc5d59 100644 --- a/grade/edit/tree/index.php +++ b/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)); diff --git a/lib/form/duration.php b/lib/form/duration.php index 06cd85ad329a9..9f1b9669dfa08 100644 --- a/lib/form/duration.php +++ b/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; diff --git a/lib/moodlelib.php b/lib/moodlelib.php index b2c6223bb4630..648c87ceda9aa 100644 --- a/lib/moodlelib.php +++ b/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 diff --git a/lib/portfoliolib.php b/lib/portfoliolib.php index dc7473a0a637a..45e9a78b49795 100644 --- a/lib/portfoliolib.php +++ b/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. diff --git a/mod/quiz/mod_form.php b/mod/quiz/mod_form.php index a07451486fc40..cd917375a8f8b 100644 --- a/mod/quiz/mod_form.php +++ b/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')); diff --git a/portfolio/add.php b/portfolio/add.php index b5a1c4a4e25b4..8cca63565bfe8 100644 --- a/portfolio/add.php +++ b/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); } } diff --git a/question/behaviour/behaviourbase.php b/question/behaviour/behaviourbase.php index cd527ef3a74ab..39d6c0247819a 100644 --- a/question/behaviour/behaviourbase.php +++ b/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); } diff --git a/question/engine/questionattempt.php b/question/engine/questionattempt.php index 54c4d9f8390fc..61da7e51072e5 100644 --- a/question/engine/questionattempt.php +++ b/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: diff --git a/question/previewlib.php b/question/previewlib.php index f763557d8d7ff..9683cae73a78f 100644 --- a/question/previewlib.php +++ b/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, diff --git a/question/type/calculated/datasetitems_form.php b/question/type/calculated/datasetitems_form.php index 6cf349a485d23..3ff97505cc311 100644 --- a/question/type/calculated/datasetitems_form.php +++ b/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); diff --git a/question/type/calculated/questiontype.php b/question/type/calculated/questiontype.php index e6a24148000ac..9083ae3d53b5c 100644 --- a/question/type/calculated/questiontype.php +++ b/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]", diff --git a/question/type/calculatedmulti/edit_calculatedmulti_form.php b/question/type/calculatedmulti/edit_calculatedmulti_form.php index bdfa2504763d1..7a802eeb8d07e 100644 --- a/question/type/calculatedmulti/edit_calculatedmulti_form.php +++ b/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); diff --git a/question/type/calculatedsimple/edit_calculatedsimple_form.php b/question/type/calculatedsimple/edit_calculatedsimple_form.php index 7ca68f0c1f1d6..e12a7119c204d 100644 --- a/question/type/calculatedsimple/edit_calculatedsimple_form.php +++ b/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); diff --git a/question/type/calculatedsimple/questiontype.php b/question/type/calculatedsimple/questiontype.php index 92eb65c87657a..035df5cd2dd5c 100644 --- a/question/type/calculatedsimple/questiontype.php +++ b/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]", diff --git a/question/type/numerical/edit_numerical_form.php b/question/type/numerical/edit_numerical_form.php index 24ec05c440ff0..ccd501a14fdb6 100644 --- a/question/type/numerical/edit_numerical_form.php +++ b/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'] = diff --git a/question/type/numerical/questiontype.php b/question/type/numerical/questiontype.php index 2e9d385a1323b..c02e91f6a7267 100644 --- a/question/type/numerical/questiontype.php +++ b/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; diff --git a/user/externallib.php b/user/externallib.php index c1d57bc07e717..4f3c0a6fdbd78 100644 --- a/user/externallib.php +++ b/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),