Create allow_numeric_answer option

This option allows you to stop accepting numeric answers as they do not always prevent spam. By default, numeric answers are accepted, so this commit does not make any unintended changes to the behaviour of this field.
This commit is contained in:
Jarkko Linnanvirta 2015-08-26 21:58:40 +03:00
parent c7b0e8741e
commit a1b85b0d97
1 changed files with 9 additions and 1 deletions

View File

@ -22,6 +22,13 @@ class MathSpamProtectorField extends TextField {
*/
private static $question_prefix;
/**
* @config
*
* @var bool $allow_numeric_answer
*/
private static $allow_numeric_answer = true;
public function Field($properties = array()) {
if(Config::inst()->get('MathSpamProtectorField', 'enabled')) {
return parent::Field($properties);
@ -126,7 +133,8 @@ class MathSpamProtectorField extends TextField {
$word = MathSpamProtectorField::digit_to_word($v1 + $v2);
return ($word == strtolower($answer) || ($v1 + $v2) == $answer);
$allow_numeric_answer = Config::inst()->get('MathSpamProtectorField', 'allow_numeric_answer');
return ($word == strtolower($answer) || ((($v1 + $v2) == $answer) and $allow_numeric_answer));
}
/**