diff --git a/locale/de_DE/LC_MESSAGES/The Legend of Z.mo b/locale/de_DE/LC_MESSAGES/The Legend of Z.mo index 2f802ca9..0c8ddb68 100644 Binary files a/locale/de_DE/LC_MESSAGES/The Legend of Z.mo and b/locale/de_DE/LC_MESSAGES/The Legend of Z.mo differ diff --git a/locale/de_DE/LC_MESSAGES/The Legend of Z.po b/locale/de_DE/LC_MESSAGES/The Legend of Z.po index b8f9924c..96ddc4a2 100644 --- a/locale/de_DE/LC_MESSAGES/The Legend of Z.po +++ b/locale/de_DE/LC_MESSAGES/The Legend of Z.po @@ -2,7 +2,7 @@ msgid "" msgstr "" "Project-Id-Version: The Legend of Z\n" "POT-Creation-Date: 2015-04-19 14:15+0100\n" -"PO-Revision-Date: 2015-04-19 14:16+0100\n" +"PO-Revision-Date: 2015-04-20 21:06+0100\n" "Last-Translator: \n" "Language-Team: \n" "Language: de_DE\n" @@ -342,7 +342,7 @@ msgstr "Felder" #: questtypes/textinput/html/quest.tpl:13 #, php-format msgid "You filled %d of %d fields correctly" -msgstr "Du hast %d von %d Feldern korrekt ausgefüllt" +msgstr "Du hast %d von %d Felder korrekt ausgefüllt" #: views/ajax/quests/index.tpl:9 views/html/quests/create.tpl:79 #: views/html/quests/edit.tpl:82 views/html/quests/index.tpl:27 diff --git a/questtypes/textinput/TextinputQuesttypeController.inc b/questtypes/textinput/TextinputQuesttypeController.inc index 271eb238..3f44302a 100644 --- a/questtypes/textinput/TextinputQuesttypeController.inc +++ b/questtypes/textinput/TextinputQuesttypeController.inc @@ -24,7 +24,15 @@ * * @var array */ - public $components = array('validation'); + public $components = array('validation', 'questtypedata'); + /** + * Count of correct answers + * + * @var int + */ + const KEY_QUESTTYPEDATA_N_CORRECT_ANSWRES = 'nCorrectAnswers'; + + private $nCorrectAnswers = null; @@ -81,22 +89,31 @@ { // Get right answers $fields = $this->Textinput->getTextinputFields($quest['id']); - + // Match regexs with user answers + $nCorrectAnswers = 0; foreach($fields as &$field) { $pos = intval($field['number']) - 1; if(!array_key_exists($pos, $answers)) { - return false; + continue; } if(!$this->isMatching($field['regex'], $answers[$pos])) { - return false; + continue; } + $nCorrectAnswers++; } + + // Save count of correct answers + $this->Questtypedata->set( + $quest['id'], + self::KEY_QUESTTYPEDATA_N_CORRECT_ANSWRES, + $nCorrectAnswers + ); // All answers right - return true; + return ($nCorrectAnswers == count($fields)); } @@ -124,26 +141,26 @@ $solved = $this->Quests->hasCharacterSolvedQuest($quest['id'], $character['id']); // Get Character answers - $correctAnswersCount = null; if(!$solved || $this->request->getGetParam('show-answer') == 'true' || $this->request->getGetParam('status') == 'solved') { - $correctAnswersCount = 0; - foreach($fields as &$field) - { + foreach($fields as &$field) { $field['answer'] = $this->Textinput->getCharacterSubmission($field['id'], $character['id']); - $correctAnswersCount += $this->isMatching($field['regex'], $field['answer']); } } - // Show count - $showcount = (count($this->request->getGetParams()) > 1); + // Get count of last correct answers + $nCorrectAnswers = $this->Questtypedata->get($quest['id'], self::KEY_QUESTTYPEDATA_N_CORRECT_ANSWRES); + $this->Questtypedata->set( + $quest['id'], + self::KEY_QUESTTYPEDATA_N_CORRECT_ANSWRES, + null + ); // Pass data to view $this->set('task', $task); $this->set('fields', $fields); - $this->set('count', $correctAnswersCount); - $this->set('showcount', $showcount); + $this->set('nCorrectAnswers', $nCorrectAnswers); } diff --git a/questtypes/textinput/html/quest.tpl b/questtypes/textinput/html/quest.tpl index 4cbcc7f9..55cee466 100644 --- a/questtypes/textinput/html/quest.tpl +++ b/questtypes/textinput/html/quest.tpl @@ -9,8 +9,8 @@ t(mb_substr($task['text'], $posStart, mb_strlen($task['text'], 'UTF-8')-$posStart, 'UTF-8'))?>

- -

.

+ +

.