From 918a3d40f9470fe8cfff1a028b95a2a78e70a273 Mon Sep 17 00:00:00 2001 From: coderkun Date: Sat, 22 Mar 2014 21:19:25 +0100 Subject: [PATCH] show correct answer only with link (Issue #46) --- controllers/QuestsController.inc | 6 ++- locale/de_DE/LC_MESSAGES/The Legend of Z.mo | Bin 2720 -> 2782 bytes locale/de_DE/LC_MESSAGES/The Legend of Z.po | 50 +++++++++--------- .../DragndropQuesttypeController.inc | 1 - questtypes/dragndrop/html/quest.tpl | 2 +- .../MultiplechoiceQuesttypeController.inc | 9 +++- questtypes/multiplechoice/html/quest.tpl | 4 +- .../TextinputQuesttypeController.inc | 11 ++-- questtypes/textinput/html/quest.tpl | 4 +- views/html/quests/quest.tpl | 2 +- 10 files changed, 48 insertions(+), 41 deletions(-) diff --git a/controllers/QuestsController.inc b/controllers/QuestsController.inc index ca8622f7..3204bb7c 100644 --- a/controllers/QuestsController.inc +++ b/controllers/QuestsController.inc @@ -347,13 +347,15 @@ $questtypeAgent = $this->loadQuesttypeAgent($questtypeClassname, $request, $response); // Solve Quest - if($this->request->getRequestMethod() == 'POST' && !is_null($this->request->getPostParam('submit')) && !$this->Quests->hasCharacterSolvedQuest($quest['id'], $character['id'])) + if($this->request->getRequestMethod() == 'POST' && !is_null($this->request->getPostParam('submit'))) { // Get user answers $answers = $this->request->getPostParam('answers'); // Save answers in database - $questtypeAgent->saveAnswersOfCharacter($seminary, $questgroup, $quest, $character, $answers); + if(!$this->Quests->hasCharacterSolvedQuest($quest['id'], $character['id'])) { + $questtypeAgent->saveAnswersOfCharacter($seminary, $questgroup, $quest, $character, $answers); + } // Match answers with correct ones $status = $questtypeAgent->matchAnswersofCharacter($seminary, $questgroup, $quest, $character, $answers); 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 b612a21739e55e3deb8c3bba452f3d7ea3a6415c..1192a6534877b0811d705ef9721053ec44e8748f 100644 GIT binary patch delta 1088 zcmXxiJ7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byZSwT KQWTyf_D%swFHScA 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 390e7ef1..56d1ec82 100644 --- a/locale/de_DE/LC_MESSAGES/The Legend of Z.po +++ b/locale/de_DE/LC_MESSAGES/The Legend of Z.po @@ -1,8 +1,8 @@ msgid "" msgstr "" "Project-Id-Version: The Legend of Z\n" -"POT-Creation-Date: 2014-03-22 14:37+0100\n" -"PO-Revision-Date: 2014-03-22 14:37+0100\n" +"POT-Creation-Date: 2014-03-22 21:17+0100\n" +"PO-Revision-Date: 2014-03-22 21:18+0100\n" "Last-Translator: \n" "Language-Team: \n" "Language: de_DE\n" @@ -20,20 +20,6 @@ msgstr "" msgid "Error" msgstr "Fehler" -#: ../../../views/html/charactergroups/group.tpl:1 -#: ../../../views/html/charactergroups/groupsgroup.tpl:1 -#: ../../../views/html/charactergroups/index.tpl:1 -#: ../../../views/html/charactergroupsquests/quest.tpl:1 -#: ../../../views/html/menu/index.tpl:4 ../../../views/html/quests/quest.tpl:1 -#: ../../../views/html/quests/submission.tpl:1 -#: ../../../views/html/quests/submissions.tpl:1 -#: ../../../views/html/seminaries/create.tpl:1 -#: ../../../views/html/seminaries/delete.tpl:1 -#: ../../../views/html/seminaries/edit.tpl:1 -#: ../../../views/html/seminaries/index.tpl:1 -msgid "Seminaries" -msgstr "Kurse" - #: ../../../views/html/charactergroups/group.tpl:3 #: ../../../views/html/charactergroups/groupsgroup.tpl:3 #: ../../../views/html/charactergroups/index.tpl:3 @@ -103,6 +89,14 @@ msgstr "Einführung" msgid "Users" msgstr "Benutzer" +#: ../../../views/html/menu/index.tpl:4 +#: ../../../views/html/seminaries/create.tpl:1 +#: ../../../views/html/seminaries/delete.tpl:1 +#: ../../../views/html/seminaries/edit.tpl:1 +#: ../../../views/html/seminaries/index.tpl:1 +msgid "Seminaries" +msgstr "Kurse" + #: ../../../views/html/menu/index.tpl:10 ../../../views/html/users/login.tpl:2 #: ../../../views/html/users/login.tpl:11 msgid "Login" @@ -118,34 +112,38 @@ msgstr "Logout" msgid "locked" msgstr "gesperrt" -#: ../../../views/html/quests/quest.tpl:21 -#: ../../../views/html/quests/submissions.tpl:28 +#: ../../../views/html/quests/quest.tpl:20 +#: ../../../views/html/quests/submissions.tpl:27 msgid "solved" msgstr "gelöst" -#: ../../../views/html/quests/quest.tpl:23 -#: ../../../views/html/quests/submissions.tpl:19 +#: ../../../views/html/quests/quest.tpl:22 +#: ../../../views/html/quests/submissions.tpl:18 msgid "unsolved" msgstr "ungelöst" -#: ../../../views/html/quests/quest.tpl:60 +#: ../../../views/html/quests/quest.tpl:59 msgid "Task" msgstr "Aufgabe" -#: ../../../views/html/quests/quest.tpl:68 +#: ../../../views/html/quests/quest.tpl:67 msgid "Task successfully solved" msgstr "Du hast die Aufgabe erfolgreich gelöst" -#: ../../../views/html/quests/quest.tpl:69 +#: ../../../views/html/quests/quest.tpl:67 +msgid "Show correct answer" +msgstr "Richtige Lösung anzeigen" + +#: ../../../views/html/quests/quest.tpl:68 msgid "Go on" msgstr "Hier geht es weiter" -#: ../../../views/html/quests/quest.tpl:74 -#: ../../../views/html/quests/quest.tpl:76 +#: ../../../views/html/quests/quest.tpl:73 +#: ../../../views/html/quests/quest.tpl:75 msgid "Quest" msgstr "Quest" -#: ../../../views/html/quests/submission.tpl:11 +#: ../../../views/html/quests/submission.tpl:10 #, php-format msgid "Submission of %s" msgstr "Lösungen von %s" diff --git a/questtypes/dragndrop/DragndropQuesttypeController.inc b/questtypes/dragndrop/DragndropQuesttypeController.inc index f0a031f9..fa801be2 100644 --- a/questtypes/dragndrop/DragndropQuesttypeController.inc +++ b/questtypes/dragndrop/DragndropQuesttypeController.inc @@ -125,7 +125,6 @@ $this->set('field', $dndField); $this->set('drops', $drops); $this->set('drags', $drags); - $this->set('solved', $solved); } diff --git a/questtypes/dragndrop/html/quest.tpl b/questtypes/dragndrop/html/quest.tpl index 0f665414..74e497c7 100644 --- a/questtypes/dragndrop/html/quest.tpl +++ b/questtypes/dragndrop/html/quest.tpl @@ -13,5 +13,5 @@
- /> + diff --git a/questtypes/multiplechoice/MultiplechoiceQuesttypeController.inc b/questtypes/multiplechoice/MultiplechoiceQuesttypeController.inc index e70d4ae1..57f60e82 100644 --- a/questtypes/multiplechoice/MultiplechoiceQuesttypeController.inc +++ b/questtypes/multiplechoice/MultiplechoiceQuesttypeController.inc @@ -96,8 +96,13 @@ { // Get questions $questions = $this->Multiplechoice->getQuestionsOfQuest($quest['id']); - foreach($questions as &$question) { - $question['answer'] = $this->Multiplechoice->getCharacterSubmission($question['id'], $character['id']); + + // Get user answers + if($this->request->getGetParam('show-answer') == 'true') + { + foreach($questions as &$question) { + $question['answer'] = $this->Multiplechoice->getCharacterSubmission($question['id'], $character['id']); + } } // Has Character already solved Quest? diff --git a/questtypes/multiplechoice/html/quest.tpl b/questtypes/multiplechoice/html/quest.tpl index 15254ad9..59c1743d 100644 --- a/questtypes/multiplechoice/html/quest.tpl +++ b/questtypes/multiplechoice/html/quest.tpl @@ -2,10 +2,10 @@
    &$question) : ?>
  1. - /> + />
- /> + diff --git a/questtypes/textinput/TextinputQuesttypeController.inc b/questtypes/textinput/TextinputQuesttypeController.inc index c502b424..580de65c 100644 --- a/questtypes/textinput/TextinputQuesttypeController.inc +++ b/questtypes/textinput/TextinputQuesttypeController.inc @@ -104,9 +104,13 @@ $textParts = preg_split('/(\$\$)/', $task['text'], -1, PREG_SPLIT_NO_EMPTY); // Get Character answers - $regexs = $this->Textinput->getTextinputRegexs($quest['id']); - foreach($regexs as &$regex) { - $regex['answer'] = $this->Textinput->getCharacterSubmission($regex['id'], $character['id']); + $regexs = null; + if($this->request->getGetParam('show-answer') == 'true') + { + $regexs = $this->Textinput->getTextinputRegexs($quest['id']); + foreach($regexs as &$regex) { + $regex['answer'] = $this->Textinput->getCharacterSubmission($regex['id'], $character['id']); + } } // Has Character already solved Quest? @@ -116,7 +120,6 @@ // Pass data to view $this->set('texts', $textParts); $this->set('regexs', $regexs); - $this->set('solved', $solved); } diff --git a/questtypes/textinput/html/quest.tpl b/questtypes/textinput/html/quest.tpl index c61bd50c..53b7bd08 100644 --- a/questtypes/textinput/html/quest.tpl +++ b/questtypes/textinput/html/quest.tpl @@ -1,11 +1,11 @@
&$text) : ?> 0) : ?> - /> +

- /> +
diff --git a/views/html/quests/quest.tpl b/views/html/quests/quest.tpl index 6cc357d4..70155c13 100644 --- a/views/html/quests/quest.tpl +++ b/views/html/quests/quest.tpl @@ -64,7 +64,7 @@
-

+

()

0) : ?>