function _quiz_is_int in Quiz 6.4
Same name and namespace in other branches
- 8.4 quiz.module \_quiz_is_int()
- 7.6 quiz.module \_quiz_is_int()
- 7 quiz.module \_quiz_is_int()
- 7.4 quiz.module \_quiz_is_int()
- 7.5 quiz.module \_quiz_is_int()
Helper function used when validating integers.
Parameters
$value: The value to be validated.
$min: The minimum value $value is allowed to be.
$max: The maximum value $value is allowed to be.
Return value
TRUE if integer in the allowed range. FALSE otherwise.
17 calls to _quiz_is_int()
- long_answer_report_validate in question_types/
long_answer/ long_answer.module - Validation function for the report form
- long_answer_score_form_validate in question_types/
long_answer/ long_answer.admin.inc - Validates the long answer score form
- matching_config_validate in question_types/
matching/ matching.module - Validate the matching config form values
- MultichoiceQuestion::forgive in question_types/
multichoice/ multichoice.classes.inc - Forgive some possible logical flaws in the user input.
- multichoice_config_validate in question_types/
multichoice/ multichoice.module - Validate the multichoice config form values
File
- ./
quiz.module, line 4063 - Quiz Module
Code
function _quiz_is_int($value, $min = 1, $max = NULL) {
$to_return = (string) $value === (string) (int) $value;
// $value is not an integer.
if (!$to_return) {
return FALSE;
}
// $value is too small.
if ($value < $min) {
return FALSE;
}
// $value is too big.
if (isset($max)) {
if ($value > $max) {
return FALSE;
}
}
// $value is an integer in the allowed range.
return TRUE;
}