diff --git a/questtypes/textinput/TextinputQuesttypeController.inc b/questtypes/textinput/TextinputQuesttypeController.inc index ad4073ce..52acdb25 100644 --- a/questtypes/textinput/TextinputQuesttypeController.inc +++ b/questtypes/textinput/TextinputQuesttypeController.inc @@ -40,25 +40,33 @@ // Check for submission if($this->request->getRequestMethod() == 'POST' && !is_null($this->request->getPostParam('submit'))) { + // Get answers + $answers = $this->request->getPostParam('answers'); + + // Store answers in session + $_SESSION['answers'][$questId] = $answers; + // Get right answers - $answers = array(); $regexs = $this->Textinput->getTextinputRegexs($questId); // Match regexs with user answers $allSolved = true; - for($i=0; $i &$regex) { - $answer = $this->request->getPostParam('answer-'.strval($i+1)); - $answers[] = $answer; - $score = preg_match($regexs[$i]['regex'], $answer); - if($score === 0 || $score === false) { + if(!array_key_exists($i, $answers)) + { $allSolved = false; + break; + } + + $score = preg_match($regex['regex'], $answers[$i]); + if($score === 0 || $score === false) + { + $allSolved = false; + break; } } - // Store answers in session - $_SESSION['answers'][$questId] = $answers; - // Set status if($allSolved) { $this->setQuestSolved(); @@ -77,7 +85,7 @@ // Pass data to view - $this->set('text', $textParts); + $this->set('texts', $textParts); $this->set('answers', $answers); } diff --git a/questtypes/textinput/html/index.tpl b/questtypes/textinput/html/index.tpl index 714d828d..40f0d213 100644 --- a/questtypes/textinput/html/index.tpl +++ b/questtypes/textinput/html/index.tpl @@ -1,10 +1,10 @@
- + &$text) : ?> 0) : ?> - + - - + +

diff --git a/views/html/quests/quest.tpl b/views/html/quests/quest.tpl index 66110f7b..42d218d1 100644 --- a/views/html/quests/quest.tpl +++ b/views/html/quests/quest.tpl @@ -76,6 +76,6 @@

-

+