From ada39e3f1e012bbdc700c480741184a84b1a944e Mon Sep 17 00:00:00 2001 From: coderkun Date: Thu, 24 Apr 2014 18:06:57 +0200 Subject: [PATCH] update Quest page: show everything on one page --- app/QuesttypeController.inc | 53 ----------- controllers/QuestsController.inc | 84 ++++++++---------- locale/de_DE/LC_MESSAGES/The Legend of Z.mo | Bin 10124 -> 10100 bytes locale/de_DE/LC_MESSAGES/The Legend of Z.po | 38 ++++---- .../ChoiceinputQuesttypeController.inc | 2 +- .../CrosswordQuesttypeController.inc | 2 +- .../DragndropQuesttypeController.inc | 2 +- .../MultiplechoiceQuesttypeController.inc | 2 +- .../TextinputQuesttypeController.inc | 2 +- views/html/quests/quest.tpl | 70 ++++++++++----- 10 files changed, 111 insertions(+), 144 deletions(-) diff --git a/app/QuesttypeController.inc b/app/QuesttypeController.inc index 9b13512e..fadfded0 100644 --- a/app/QuesttypeController.inc +++ b/app/QuesttypeController.inc @@ -303,59 +303,6 @@ $this->view = QuesttypeView::loadAndFactory($layoutName, $controllerName, $action); } - - /** - * Mark the current Quest as solved and redirect to solved page. - */ - protected function setQuestSolved() - { - // Get seminary - $seminary = $this->Seminaries->getSeminaryByUrl($this->request->getParam(3)); - - // Get Questgroup - $questgroup = $this->Questgroups->getQuestgroupByUrl($seminary['id'], $this->request->getParam(4)); - - // Get Quest - $quest = $this->Quests->getQuestByUrl($seminary['id'], $questgroup['id'], $this->request->getParam(5)); - - // Character - $character = $this->Characters->getCharacterForUserAndSeminary($this->Auth->getUserId(), $seminary['id']); - - // Set solved - $this->Quests->setQuestSolved($quest['id'], $character['id']); - - - // Redirect - $this->redirect($this->linker->link('Epilog', $sidequest != null ? 6 : 5, true, array('status'=>'solved'))); - } - - - /** - * Mark the current Quest as unsolved and redirect to unsolved - * page. - */ - protected function setQuestUnsolved() - { - // Get seminary - $seminary = $this->Seminaries->getSeminaryByUrl($this->request->getParam(3)); - - // Get Questgroup - $questgroup = $this->Questgroups->getQuestgroupByUrl($seminary['id'], $this->request->getParam(4)); - - // Get Quest - $quest = $this->Quests->getQuestByUrl($seminary['id'], $questgroup['id'], $this->request->getParam(5)); - - // Character - $character = $this->Characters->getCharacterForUserAndSeminary($this->Auth->getUserId(), $seminary['id']); - - // Set solved - $this->Quests->setQuestUnsolved($quest['id'], $character['id']); - - - // Redirect - $this->redirect($this->linker->link('Prolog', $sidequest != null ? 6 : 5, true, array('status'=>'unsolved'))); - } - } ?> diff --git a/controllers/QuestsController.inc b/controllers/QuestsController.inc index b0804a89..8a60b3bc 100644 --- a/controllers/QuestsController.inc +++ b/controllers/QuestsController.inc @@ -195,39 +195,29 @@ // Set status “entered” $this->Quests->setQuestEntered($quest['id'], $character['id']); - // Get (related) Questtext - $relatedQuesttext = $this->Questtexts->getRelatedQuesttextForQuestgroup($questgroup['id']); - if(!empty($relatedQuesttext)) { - $relatedQuesttext['quest'] = $this->Quests->getQuestById($relatedQuesttext['quest_id']); - if(!empty($relatedQuesttext['quest'])) { - $relatedQuesttext['quest']['questgroup_url'] = $this->Questgroups->getQuestgroupById($relatedQuesttext['quest']['questgroup_id'])['url']; - } - } + // Has Character solved quest? + $solved = $this->Quests->hasCharacterSolvedQuest($quest['id'], $character['id']); // Get Questtexts - if(is_null($questtexttypeUrl)) { - $questtexttypeUrl = 'Prolog'; + $questtexts = array(); + $questtexts['Prolog'] = $this->Questtexts->getQuesttextsOfQuest($quest['id'], 'Prolog'); + if($solved) { + $questtexts['Epilog'] = $this->Questtexts->getQuesttextsOfQuest($quest['id'], 'Epilog'); } - $questtexttypes = $this->Questtexts->getQuesttexttypes(); - if(($questtexttypeIndex = array_search($questtexttypeUrl, array_map(function($t) { return $t['url']; }, $questtexttypes))) === false) { - throw new ParamsNotValidException($questtexttypeUrl); - } - $questtexttype = $questtexttypes[$questtexttypeIndex]; - $questtexts = $this->Questtexts->getQuesttextsOfQuest($quest['id'], $questtexttypeUrl); - foreach($questtexts as &$questtext) + foreach($questtexts as &$questtextList) { - // Questtext media - if(!is_null($questtext['questsmedia_id'])) { - $questtext['media'] = $this->Media->getSeminaryMediaById($questtext['questsmedia_id']); - } + foreach($questtextList as &$questtext) + { + // Questtext media + if(!is_null($questtext['questsmedia_id'])) { + $questtext['media'] = $this->Media->getSeminaryMediaById($questtext['questsmedia_id']); + } - // Related Questgroups - $questtext['relatedQuestsgroups'] = $this->Questgroups->getRelatedQuestsgroupsOfQuesttext($questtext['id']); + // Related Questgroups + $questtext['relatedQuestsgroups'] = $this->Questgroups->getRelatedQuestsgroupsOfQuesttext($questtext['id']); + } } - // Has Epilog? - $hasEpilog = ($this->Questtexts->getQuesttextCountOfQuest($quest['id'], 'Epilog') > 0); - // Quest status $questStatus = $this->request->getGetParam('status'); @@ -239,29 +229,31 @@ // Task $task = null; - if($questtexttypeUrl == 'Prolog') + $questtype = $this->Questtypes->getQuesttypeById($quest['questtype_id']); + if(!is_null($questtype['classname'])) { + $task = $this->renderTask($questtype['classname'], $seminary, $questgroup, $quest, $character); + } + else { - // Questtype - $questtype = $this->Questtypes->getQuesttypeById($quest['questtype_id']); - - // Render task - if(!is_null($questtype['classname'])) { - $task = $this->renderTask($questtype['classname'], $seminary, $questgroup, $quest, $character); - } - else { - // Mark Quest as solved - $this->Quests->setQuestSolved($quest['id'], $character['id']); - } + // Mark Quest as solved + $this->Quests->setQuestSolved($quest['id'], $character['id']); + $solved = true; } - // Has Character solved quest? - $solved = $this->Quests->hasCharacterSolvedQuest($quest['id'], $character['id']); + // Get (related) Questtext + $relatedQuesttext = $this->Questtexts->getRelatedQuesttextForQuestgroup($questgroup['id']); + if(!empty($relatedQuesttext)) { + $relatedQuesttext['quest'] = $this->Quests->getQuestById($relatedQuesttext['quest_id']); + if(!empty($relatedQuesttext['quest'])) { + $relatedQuesttext['quest']['questgroup_url'] = $this->Questgroups->getQuestgroupById($relatedQuesttext['quest']['questgroup_id'])['url']; + } + } // Next Quest/Questgroup $nextQuests = null; $charactedHasChoosenNextQuest = false; $nextQuestgroup = null; - if($questtexttypeUrl == 'Epilog' || (is_null($questtype['classname']) && !$hasEpilog)) + if($solved) { // Next Quest $nextQuests = $this->Quests->getNextQuests($quest['id']); @@ -296,9 +288,9 @@ // Pass data to view $this->set('seminary', $seminary); $this->set('questgroup', $questgroup); - $this->set('questtexttype', $questtexttype); + //$this->set('questtexttype', $questtexttype); $this->set('questtexts', $questtexts); - $this->set('hasEpilog', $hasEpilog); + //$this->set('hasEpilog', $hasEpilog); $this->set('quest', $quest); $this->set('queststatus', $questStatus); $this->set('relatedquesttext', $relatedQuesttext); @@ -610,7 +602,7 @@ $this->Quests->setQuestSolved($quest['id'], $character['id']); // Redirect - $this->redirect($this->linker->link('Epilog', 5, true, array('status'=>'solved'))); + $this->redirect($this->linker->link(array(), 5, true, array('status'=>'solved'), false, 'task')); } elseif($status === false) { @@ -618,14 +610,14 @@ $this->Quests->setQuestUnsolved($quest['id'], $character['id']); // Redirect - $this->redirect($this->linker->link('Prolog', 5, true, array('status'=>'unsolved'))); + $this->redirect($this->linker->link(array(), 5, true, array('status'=>'unsolved'), false, 'task')); } else { // Mark Quest as submitted $this->Quests->setQuestSubmitted($quest['id'], $character['id']); // Redirect - $this->redirect($this->linker->link('Prolog', 5, true)); + $this->redirect($this->linker->link(array(), 5, true, false, 'task')); } } catch(\hhu\z\exceptions\SubmissionNotValidException $e) { 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 df2c161487e13f364061d59f3851f83fc6cedc1f..90a7e3fd3d8faa04c555988aaf8e3f9cd788a9cf 100644 GIT binary patch delta 2988 zcmZwHdrXyO0LSqM&H)7u$T<>61d)ppWD4Y+L_xDKMIp)yAxdfn632U9!dFcVld?E; z0XFBxMw_kWLMvyrrfZf#)4AqKw;Ic0j+Sd>x!mmg<2?M=yYoAr=e<4eb9>+BC4VkH zSrz6)8e<~j33@OEeaO$`@;4TXa1^e_B;1L*E{I+{Y0sZS5Bt}UpXui>8tD?C8~lNd%hN<*x!nyaSyt&4OQPU9FF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AnSvU@Qq%<+QH5?n-P;gq29BVYTXxKzKh3mh=ECe$$PcJOucBt?Pt+~H<o8} zk%2hIPeb=Qi0WvMb-z8|iJFO1s1CnEUEm68Mt;O%?7?zOWd&=bHK+o87qXQL|3!`DKI&E_9c0`m zEkaFo(0;xhJsdA31%z#+na6$_SxKgomq_n6iN>c_wnYtDMD#HC zZfj_42vzh;cbaLjUL%{I{fi_-CPvPE7+x-UbGVUSE%A|k6os_gMzOd+q5btHzAla_F7q9;0>m~=TR{9DRVkGH9DZC22?zA3zE!1k!V zYnp?N%`N`Wy+Lr)%&w9oUiu> c)~^jTHivg*XGD7&)&znLzEy$HTe;o;0TYlJ6951J 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 445f46f9..161d34d7 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-04-24 16:46+0100\n" -"PO-Revision-Date: 2014-04-24 16:46+0100\n" +"POT-Creation-Date: 2014-04-24 18:05+0100\n" +"PO-Revision-Date: 2014-04-24 18:06+0100\n" "Last-Translator: \n" "Language-Team: \n" "Language: de_DE\n" @@ -105,12 +105,12 @@ msgstr "Kommentar von %s am %s um %s Uhr" msgid "Comment" msgstr "Kommentar" -#: questtypes/submit/html/submission.tpl:30 views/html/quests/quest.tpl:42 +#: questtypes/submit/html/submission.tpl:30 views/html/quests/quest.tpl:45 #: views/html/quests/submissions.tpl:28 msgid "solved" msgstr "Richtig!" -#: questtypes/submit/html/submission.tpl:31 views/html/quests/quest.tpl:46 +#: questtypes/submit/html/submission.tpl:31 views/html/quests/quest.tpl:50 #: views/html/quests/submissions.tpl:19 msgid "unsolved" msgstr "Leider falsch!" @@ -486,7 +486,7 @@ msgstr "Einstiegstext" msgid "Wrong text" msgstr "Text für falsche Antwort" -#: views/html/quests/create.tpl:40 views/html/quests/quest.tpl:55 +#: views/html/quests/create.tpl:40 views/html/quests/quest.tpl:41 msgid "Task" msgstr "Aufgabe" @@ -502,12 +502,16 @@ msgstr "Filter anwenden" msgid "Reset filters" msgstr "Filter zurücksetzen" -#: views/html/quests/quest.tpl:43 +#: views/html/quests/quest.tpl:11 +msgid "Prolog" +msgstr "Prolog" + +#: views/html/quests/quest.tpl:46 #, php-format msgid "Quest completed. You have earned %d XPs." msgstr "Quest abgeschlossen. Du hast %d XP erhalten." -#: views/html/quests/quest.tpl:61 +#: views/html/quests/quest.tpl:62 msgid "Task already successfully solved" msgstr "Du hast die Aufgabe bereits erfolgreich gelöst" @@ -515,19 +519,15 @@ msgstr "Du hast die Aufgabe bereits erfolgreich gelöst" msgid "Show answer" msgstr "Lösung anzeigen" -#: views/html/quests/quest.tpl:65 -msgid "Skip task" -msgstr "Aufgabe überspringen" +#: views/html/quests/quest.tpl:74 +msgid "Epilog" +msgstr "Epilog" -#: views/html/quests/quest.tpl:71 -msgid "continue" -msgstr "fortfahren" - -#: views/html/quests/quest.tpl:78 +#: views/html/quests/quest.tpl:100 msgid "Continuation" msgstr "Fortsetzung" -#: views/html/quests/quest.tpl:84 views/html/quests/quest.tpl:97 +#: views/html/quests/quest.tpl:106 views/html/quests/quest.tpl:119 msgid "Quest" msgstr "Quest" @@ -743,6 +743,12 @@ msgstr "Registrieren" msgid "Roles" msgstr "Rollen" +#~ msgid "Skip task" +#~ msgstr "Aufgabe überspringen" + +#~ msgid "continue" +#~ msgstr "fortfahren" + #~ msgid "Character type" #~ msgstr "Charaktertyp" diff --git a/questtypes/choiceinput/ChoiceinputQuesttypeController.inc b/questtypes/choiceinput/ChoiceinputQuesttypeController.inc index d7b2556d..a7edf905 100644 --- a/questtypes/choiceinput/ChoiceinputQuesttypeController.inc +++ b/questtypes/choiceinput/ChoiceinputQuesttypeController.inc @@ -119,7 +119,7 @@ } // Get Character answers - if($this->request->getGetParam('show-answer') == 'true' || !$this->Quests->hasCharacterSolvedQuest($quest['id'], $character['id'])) + if($this->request->getGetParam('show-answer') == 'true' || !$this->Quests->hasCharacterSolvedQuest($quest['id'], $character['id']) || $this->request->getGetParam('status') == 'solved') { foreach($choiceLists as &$list) { $list['answer'] = $this->Choiceinput->getCharacterSubmission($list['id'], $character['id']); diff --git a/questtypes/crossword/CrosswordQuesttypeController.inc b/questtypes/crossword/CrosswordQuesttypeController.inc index 9a2f7dcc..e5510786 100644 --- a/questtypes/crossword/CrosswordQuesttypeController.inc +++ b/questtypes/crossword/CrosswordQuesttypeController.inc @@ -181,7 +181,7 @@ $maxY = 0; foreach($words as $index => &$word) { - if($this->request->getGetParam('show-answer') == 'true' || !$this->Quests->hasCharacterSolvedQuest($quest['id'], $character['id'])) { + if($this->request->getGetParam('show-answer') == 'true' || !$this->Quests->hasCharacterSolvedQuest($quest['id'], $character['id']) || $this->request->getGetParam('status') == 'solved') { $word['answer'] = $this->Crossword->getCharacterSubmission($word['id'], $character['id']); } // Insert word diff --git a/questtypes/dragndrop/DragndropQuesttypeController.inc b/questtypes/dragndrop/DragndropQuesttypeController.inc index f3e973d7..4f359faa 100644 --- a/questtypes/dragndrop/DragndropQuesttypeController.inc +++ b/questtypes/dragndrop/DragndropQuesttypeController.inc @@ -144,7 +144,7 @@ $drops = $this->Dragndrop->getDrops($dndField['quest_id']); // Get Character answers - if($this->request->getGetParam('show-answer') == 'true' || !$this->Quests->hasCharacterSolvedQuest($quest['id'], $character['id'])) + if($this->request->getGetParam('show-answer') == 'true' || !$this->Quests->hasCharacterSolvedQuest($quest['id'], $character['id']) || $this->request->getGetParam('status') == 'solved') { foreach($drops as &$drop) { diff --git a/questtypes/multiplechoice/MultiplechoiceQuesttypeController.inc b/questtypes/multiplechoice/MultiplechoiceQuesttypeController.inc index cb384167..09dbfe41 100644 --- a/questtypes/multiplechoice/MultiplechoiceQuesttypeController.inc +++ b/questtypes/multiplechoice/MultiplechoiceQuesttypeController.inc @@ -171,7 +171,7 @@ // Get previous user answers - if($this->request->getGetParam('show-answer') == 'true' || !$this->Quests->hasCharacterSolvedQuest($quest['id'], $character['id'])) + if($this->request->getGetParam('show-answer') == 'true' || !$this->Quests->hasCharacterSolvedQuest($quest['id'], $character['id']) || $this->request->getGetParam('status') == 'solved') { foreach($question['answers'] as &$answer) { $answer['useranswer'] = $this->Multiplechoice->getCharacterSubmission($answer['id'], $character['id']); diff --git a/questtypes/textinput/TextinputQuesttypeController.inc b/questtypes/textinput/TextinputQuesttypeController.inc index 11512432..aa666790 100644 --- a/questtypes/textinput/TextinputQuesttypeController.inc +++ b/questtypes/textinput/TextinputQuesttypeController.inc @@ -123,7 +123,7 @@ // Get Character answers $regexs = null; - if(!$solved || $this->request->getGetParam('show-answer') == 'true') + if(!$solved || $this->request->getGetParam('show-answer') == 'true' || $this->request->getGetParam('status') == 'solved') { $regexs = $this->Textinput->getTextinputRegexs($quest['id']); foreach($regexs as &$regex) { diff --git a/views/html/quests/quest.tpl b/views/html/quests/quest.tpl index 3408da26..664d7d52 100644 --- a/views/html/quests/quest.tpl +++ b/views/html/quests/quest.tpl @@ -6,12 +6,12 @@

- 0) : ?> + 0) : ?>
-

+

- +

@@ -36,43 +36,65 @@

- - -
-

-

- -
-

-

- -
- - - +
-

+ + +
+

+

+
+ +
+

+

+
+ + + +

t($quest['task'])?>

- +

:

- -

+ 0) : ?> +
+

+
+ +

+ + + + +

+ 0 || !empty($questtext['abort_text'])) : ?> +
    + +
  • + + +
  • + +
+ + +
+
+ +