update Quest page: show everything on one page
This commit is contained in:
parent
f20fd8a877
commit
ada39e3f1e
10 changed files with 111 additions and 144 deletions
|
|
@ -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')));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -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"
|
||||
|
||||
|
|
|
|||
|
|
@ -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']);
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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']);
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -6,12 +6,12 @@
|
|||
<?=$questgroupshierarchypath?>
|
||||
<h1><?=$quest['title']?></h1>
|
||||
|
||||
<?php if(count($questtexts) > 0) : ?>
|
||||
<?php if(array_key_exists('Prolog', $questtexts) && count($questtexts['Prolog']) > 0) : ?>
|
||||
<section>
|
||||
<h1 id="questtext"><?=$questtexttype['type']?></h1>
|
||||
<h1 id="questtext"><?=_('Prolog')?></h1>
|
||||
<div id="qtextbox">
|
||||
<?php $mediaShown = false; ?>
|
||||
<?php foreach($questtexts as &$questtext) : ?>
|
||||
<?php foreach($questtexts['Prolog'] as &$questtext) : ?>
|
||||
<p class="qtext cf">
|
||||
<?php if(array_key_exists('media', $questtext)) : ?>
|
||||
<a href="<?=$linker->link(array('media','seminary',$seminary['url'],$media['url']))?>"><img src="<?=$linker->link(array('media','seminary',$seminary['url'],$questtext['media']['url']))?>" /></a>
|
||||
|
|
@ -36,43 +36,65 @@
|
|||
</section>
|
||||
<?php endif ?>
|
||||
|
||||
<?php if(!is_null($queststatus)) : ?>
|
||||
<?php if($queststatus == 'solved') : ?>
|
||||
<section class="success">
|
||||
<p class="fwb"><i class="fa fa-check-circle fa-fw"></i><?=_('solved')?></p>
|
||||
<p><small><?=sprintf(_('Quest completed. You have earned %d XPs.'), $quest['xps'])?></small></p>
|
||||
<?php elseif($queststatus == 'unsolved') : ?>
|
||||
<section class="error">
|
||||
<p class="fwb"><i class="fa fa-times-circle fa-fw"></i><?=_('unsolved')?></p>
|
||||
<p><small><?=\hhu\z\Utils::t($quest['wrong_text'])?></small></p>
|
||||
<?php endif ?>
|
||||
</section>
|
||||
<?php endif ?>
|
||||
|
||||
<?php if($questtexttype['type'] == 'Prolog') : ?>
|
||||
<?php if(!is_null($task)) : ?>
|
||||
<section>
|
||||
<?php if(!is_null($task)) : ?>
|
||||
<h1 id="task"><?=_('Task')?></h1>
|
||||
<?php if(!is_null($queststatus)) : ?>
|
||||
<?php if($queststatus == 'solved') : ?>
|
||||
<div class="success">
|
||||
<p class="fwb"><i class="fa fa-check-circle fa-fw"></i><?=_('solved')?></p>
|
||||
<p><small><?=sprintf(_('Quest completed. You have earned %d XPs.'), $quest['xps'])?></small></p>
|
||||
</div>
|
||||
<?php elseif($queststatus == 'unsolved') : ?>
|
||||
<div class="error">
|
||||
<p class="fwb"><i class="fa fa-times-circle fa-fw"></i><?=_('unsolved')?></p>
|
||||
<p><small><?=\hhu\z\Utils::t($quest['wrong_text'])?></small></p>
|
||||
</div>
|
||||
<?php endif ?>
|
||||
<?php endif ?>
|
||||
|
||||
<?php if($queststatus != 'solved') : ?>
|
||||
<p><?=$t->t($quest['task'])?></p>
|
||||
<?=$task?>
|
||||
|
||||
<?php if($solved) : ?>
|
||||
<?php if($solved && empty($queststatus)) : ?>
|
||||
<div class="solvdmsg">
|
||||
<p><?=_('Task already successfully solved')?>:
|
||||
<nav class="admin">
|
||||
<?php if($solved) : ?>
|
||||
<li><a href="<?=$linker->link(null,0,false,array('show-answer'=>'true'),true,'task')?>"><?=_('Show answer')?></a></li>
|
||||
<li><a href="<?=$linker->link('Epilog',5)?>"><?=_('Skip task')?></a></l>
|
||||
<?php endif ?>
|
||||
</nav>
|
||||
</div>
|
||||
<?php endif ?>
|
||||
<?php elseif($hasEpilog) : ?>
|
||||
<p><a href="<?=$linker->link('Epilog',5)?>"><?=_('continue')?></a></p>
|
||||
<?php endif ?>
|
||||
</section>
|
||||
<?php endif ?>
|
||||
|
||||
<?php if(array_key_exists('Epilog', $questtexts) && count($questtexts['Epilog']) > 0) : ?>
|
||||
<section>
|
||||
<h1 id="questtext"><?=_('Epilog')?></h1>
|
||||
<div id="qtextbox">
|
||||
<?php foreach($questtexts['Epilog'] as &$questtext) : ?>
|
||||
<p class="qtext cf">
|
||||
<?php if(array_key_exists('media', $questtext)) : ?>
|
||||
<a href="<?=$linker->link(array('media','seminary',$seminary['url'],$media['url']))?>"><img src="<?=$linker->link(array('media','seminary',$seminary['url'],$questtext['media']['url']))?>" /></a>
|
||||
<?php endif ?>
|
||||
<?=\hhu\z\Utils::t($questtext['text'])?>
|
||||
</p>
|
||||
<?php if(count($questtext['relatedQuestsgroups']) > 0 || !empty($questtext['abort_text'])) : ?>
|
||||
<ul>
|
||||
<?php foreach($questtext['relatedQuestsgroups'] as &$relatedQuestgroup) : ?>
|
||||
<li><a href="<?=$linker->link(array('questgroups','questgroup',$seminary['url'],$relatedQuestgroup['url']))?>"><?=$relatedQuestgroup['entry_text']?></a></li>
|
||||
<?php endforeach ?>
|
||||
<?php if(!empty($questtext['abort_text'])) : ?>
|
||||
<li><a href="<?=$linker->link(array('quest',$seminary['url'],$relatedquesttext['quest']['questgroup_url'],$relatedquesttext['quest']['url'],$relatedquesttext['type_url']),1)?>"><?=$questtext['abort_text']?></a></li>
|
||||
<?php endif ?>
|
||||
</ul>
|
||||
<?php endif ?>
|
||||
<?php endforeach ?>
|
||||
</div>
|
||||
</section>
|
||||
<?php endif ?>
|
||||
|
||||
<?php if(!is_null($nextquests) || !is_null($nextquestgroup)) : ?>
|
||||
<section>
|
||||
<h1><?=_('Continuation')?></h1>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue