function _math_captcha_subtraction_challenge in CAPTCHA Pack 6
Same name and namespace in other branches
- 8 math_captcha/math_captcha.challenge.inc \_math_captcha_subtraction_challenge()
- 5 math_captcha/math_captcha.module \_math_captcha_subtraction_challenge()
- 7 math_captcha/math_captcha.challenge.inc \_math_captcha_subtraction_challenge()
function for subtraction challenges
File
- math_captcha/
math_captcha.challenge.inc, line 24
Code
function _math_captcha_subtraction_challenge() {
$argmax = intval(variable_get('math_captcha_subtraction_argmax', 10));
if (variable_get('math_captcha_subtraction_allow_negative', FALSE)) {
$x = mt_rand(-$argmax, $argmax);
$y = mt_rand(-$argmax, $argmax);
}
else {
$y = mt_rand(0, $argmax);
$x = mt_rand($y, $argmax);
}
$solution = $x - $y;
$maxlength = strlen(strval($argmax + $argmax)) + intval(variable_get('math_captcha_subtraction_allow_negative', FALSE));
return _math_captcha_build_captcha($x, $y, '-', $solution, $maxlength);
}