Skip to content

Commit

Permalink
Merge pull request #30 from Taitava/master
Browse files Browse the repository at this point in the history
Create allow_numeric_answer option
  • Loading branch information
Damian Mooyman committed Aug 31, 2015
2 parents c7b0e87 + 644360c commit 76b5639
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion code/MathSpamProtectorField.php
Expand Up @@ -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);
Expand Down Expand Up @@ -126,7 +133,7 @@ public static function correct_answer($answer){

$word = MathSpamProtectorField::digit_to_word($v1 + $v2);

return ($word == strtolower($answer) || ($v1 + $v2) == $answer);
return ($word == strtolower($answer) || (Config::inst()->get('MathSpamProtectorField', 'allow_numeric_answer') && (($v1 + $v2) == $answer)));
}

/**
Expand Down

0 comments on commit 76b5639

Please sign in to comment.