function _math_captcha_addition_challenge in CAPTCHA Pack 5
Same name and namespace in other branches
- 8 math_captcha/math_captcha.challenge.inc \_math_captcha_addition_challenge()
- 6 math_captcha/math_captcha.challenge.inc \_math_captcha_addition_challenge()
- 7 math_captcha/math_captcha.challenge.inc \_math_captcha_addition_challenge()
function for addition challenges
File
- math_captcha/
math_captcha.module, line 222
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);
}