Skip to content

Commit

Permalink
MDL-32940 libraries: Replaced deprecated PARAM_NUMBER with PARAM_FLOAT
Browse files Browse the repository at this point in the history
  • Loading branch information
Rajesh Taneja committed Jul 23, 2012
1 parent 3294034 commit 61cca0b
Show file tree
Hide file tree
Showing 18 changed files with 38 additions and 38 deletions.
2 changes: 1 addition & 1 deletion enrol/externallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion grade/edit/tree/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand Down
2 changes: 1 addition & 1 deletion lib/form/duration.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion lib/moodlelib.php
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@

/**
* PARAM_NUMBER - deprecated alias of PARAM_FLOAT
* @deprecated since 2.0
*/
define('PARAM_NUMBER', 'float');

Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/portfoliolib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion mod/quiz/mod_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
Expand Down
2 changes: 1 addition & 1 deletion portfolio/add.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
8 changes: 4 additions & 4 deletions question/behaviour/behaviourbase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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);
}

Expand Down
6 changes: 3 additions & 3 deletions question/engine/questionattempt.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion question/previewlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions question/type/calculated/datasetitems_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]");
Expand Down Expand Up @@ -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);

Expand Down
4 changes: 2 additions & 2 deletions question/type/calculated/questiontype.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]",
Expand Down
6 changes: 3 additions & 3 deletions question/type/calculatedmulti/edit_calculatedmulti_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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);
Expand Down
12 changes: 6 additions & 6 deletions question/type/calculatedsimple/edit_calculatedsimple_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions question/type/calculatedsimple/questiontype.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]",
Expand Down
6 changes: 3 additions & 3 deletions question/type/numerical/edit_numerical_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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'] =
Expand Down
2 changes: 1 addition & 1 deletion question/type/numerical/questiontype.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions user/externallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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),
Expand All @@ -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),
Expand Down Expand Up @@ -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),
Expand Down

0 comments on commit 61cca0b

Please sign in to comment.