Questtype ?Textinput?: trim answers for regex matching
This commit is contained in:
parent
e936685724
commit
a17b5999a2
1 changed files with 8 additions and 1 deletions
|
|
@ -172,9 +172,16 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if an Character answer matches a Regex.
|
||||||
|
*
|
||||||
|
* @param string $regex Regex to match against
|
||||||
|
* @param string $answer Character answer to match
|
||||||
|
* @return boolean Whether answer matches Regex or not
|
||||||
|
*/
|
||||||
private function isMatching($regex, $answer)
|
private function isMatching($regex, $answer)
|
||||||
{
|
{
|
||||||
$score = preg_match($regex, $answer);
|
$score = preg_match($regex, trim($answer));
|
||||||
|
|
||||||
|
|
||||||
return ($score !== false && $score > 0);
|
return ($score !== false && $score > 0);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue