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