restore Character answres for all Questtypes if Character has not already solved the Quest
This commit is contained in:
parent
d4c127d4dd
commit
aba2100fb3
6 changed files with 11 additions and 9 deletions
|
|
@ -119,13 +119,15 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get Character answers
|
// Get Character answers
|
||||||
if($this->request->getGetParam('show-answer') == 'true')
|
if($this->request->getGetParam('show-answer') == 'true' || !$this->Quests->hasCharacterSolvedQuest($quest['id'], $character['id']))
|
||||||
{
|
{
|
||||||
foreach($choiceLists as &$list) {
|
foreach($choiceLists as &$list) {
|
||||||
$list['answer'] = $this->Choiceinput->getCharacterSubmission($list['id'], $character['id']);
|
$list['answer'] = $this->Choiceinput->getCharacterSubmission($list['id'], $character['id']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
print_r($choiceLists);
|
||||||
|
|
||||||
|
|
||||||
// Pass data to view
|
// Pass data to view
|
||||||
$this->set('texts', $textParts);
|
$this->set('texts', $textParts);
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
<?php if($i > 0) : ?>
|
<?php if($i > 0) : ?>
|
||||||
<select name="answers[<?=$i-1?>]">
|
<select name="answers[<?=$i-1?>]">
|
||||||
<?php foreach($choiceLists[$i-1]['values'] as &$choice) : ?>
|
<?php foreach($choiceLists[$i-1]['values'] as &$choice) : ?>
|
||||||
<option value="<?=$choice['id']?>" <?php if(array_key_exists('answer', $choiceLists[$i-1]) && $choiceLists[$i-1] == $choice['id']) : ?>selected="selected"<?php endif ?>><?=$choice['text']?></option>
|
<option value="<?=$choice['id']?>" <?php if(array_key_exists('answer', $choiceLists[$i-1]) && $choiceLists[$i-1]['answer'] == $choice['id']) : ?>selected="selected"<?php endif ?>><?=$choice['text']?></option>
|
||||||
<?php endforeach ?>
|
<?php endforeach ?>
|
||||||
</select>
|
</select>
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
|
|
|
||||||
|
|
@ -181,7 +181,7 @@
|
||||||
$maxY = 0;
|
$maxY = 0;
|
||||||
foreach($words as $index => &$word)
|
foreach($words as $index => &$word)
|
||||||
{
|
{
|
||||||
if($this->request->getGetParam('show-answer') == 'true') {
|
if($this->request->getGetParam('show-answer') == 'true' || !$this->Quests->hasCharacterSolvedQuest($quest['id'], $character['id'])) {
|
||||||
$word['answer'] = $this->Crossword->getCharacterSubmission($word['id'], $character['id']);
|
$word['answer'] = $this->Crossword->getCharacterSubmission($word['id'], $character['id']);
|
||||||
}
|
}
|
||||||
// Insert word
|
// Insert word
|
||||||
|
|
|
||||||
|
|
@ -144,7 +144,7 @@
|
||||||
$drops = $this->Dragndrop->getDrops($dndField['quest_id']);
|
$drops = $this->Dragndrop->getDrops($dndField['quest_id']);
|
||||||
|
|
||||||
// Get Character answers
|
// Get Character answers
|
||||||
if($this->request->getGetParam('show-answer') == 'true')
|
if($this->request->getGetParam('show-answer') == 'true' || !$this->Quests->hasCharacterSolvedQuest($quest['id'], $character['id']))
|
||||||
{
|
{
|
||||||
foreach($drops as &$drop)
|
foreach($drops as &$drop)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -171,7 +171,7 @@
|
||||||
|
|
||||||
|
|
||||||
// Get previous user answers
|
// Get previous user answers
|
||||||
if($this->request->getGetParam('show-answer') == 'true')
|
if($this->request->getGetParam('show-answer') == 'true' || !$this->Quests->hasCharacterSolvedQuest($quest['id'], $character['id']))
|
||||||
{
|
{
|
||||||
foreach($question['answers'] as &$answer) {
|
foreach($question['answers'] as &$answer) {
|
||||||
$answer['useranswer'] = $this->Multiplechoice->getCharacterSubmission($answer['id'], $character['id']);
|
$answer['useranswer'] = $this->Multiplechoice->getCharacterSubmission($answer['id'], $character['id']);
|
||||||
|
|
|
||||||
|
|
@ -118,9 +118,12 @@
|
||||||
// Process text
|
// Process text
|
||||||
$textParts = preg_split('/(\$\$)/', ' '.$task['text'].' ', -1, PREG_SPLIT_NO_EMPTY);
|
$textParts = preg_split('/(\$\$)/', ' '.$task['text'].' ', -1, PREG_SPLIT_NO_EMPTY);
|
||||||
|
|
||||||
|
// Has Character already solved Quest?
|
||||||
|
$solved = $this->Quests->hasCharacterSolvedQuest($quest['id'], $character['id']);
|
||||||
|
|
||||||
// Get Character answers
|
// Get Character answers
|
||||||
$regexs = null;
|
$regexs = null;
|
||||||
if($this->request->getGetParam('show-answer') == 'true')
|
if(!$solved || $this->request->getGetParam('show-answer') == 'true')
|
||||||
{
|
{
|
||||||
$regexs = $this->Textinput->getTextinputRegexs($quest['id']);
|
$regexs = $this->Textinput->getTextinputRegexs($quest['id']);
|
||||||
foreach($regexs as &$regex) {
|
foreach($regexs as &$regex) {
|
||||||
|
|
@ -128,9 +131,6 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Has Character already solved Quest?
|
|
||||||
$solved = $this->Quests->hasCharacterSolvedQuest($quest['id'], $character['id']);
|
|
||||||
|
|
||||||
|
|
||||||
// Pass data to view
|
// Pass data to view
|
||||||
$this->set('texts', $textParts);
|
$this->set('texts', $textParts);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue