You are here

function _quiz_is_int in Quiz 7.5

Same name and namespace in other branches
  1. 8.4 quiz.module \_quiz_is_int()
  2. 6.4 quiz.module \_quiz_is_int()
  3. 7.6 quiz.module \_quiz_is_int()
  4. 7 quiz.module \_quiz_is_int()
  5. 7.4 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

bool TRUE if integer in the allowed range. FALSE otherwise.

8 calls to _quiz_is_int()
matching_config_validate in question_types/matching/matching.module
Validate the long_answer 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.
quiz_categorized_form_validate in ./quiz.admin.inc
Validate the categorized form.
quiz_questions_form_validate in ./quiz.admin.inc
Validate that the supplied questions are real.

... See full list

File

./quiz.module, line 3304
quiz.module Main file for the 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;
}