show submitted values for tried Station tasks
This commit is contained in:
parent
54ed53ac33
commit
b511a960c8
7 changed files with 104 additions and 5 deletions
|
@ -225,7 +225,7 @@
|
|||
$task = null;
|
||||
$stationtype = $this->Stationtypes->getStationtypeById($station['stationtype_id']);
|
||||
if(!is_null($stationtype['classname'])) {
|
||||
$task = $this->renderTask($stationtype['classname'], $seminary, $groupsgroup, $quest, $station, $charactergroup);
|
||||
$task = $this->renderTask($stationtype['classname'], $seminary, $groupsgroup, $quest, $station, $stationgroup);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -19,6 +19,10 @@
|
|||
*/
|
||||
class KeywordStationtypeController extends \hhu\z\controllers\StationtypeController
|
||||
{
|
||||
/**
|
||||
* Required models
|
||||
*/
|
||||
public $models = array('charactergroupsqueststations');
|
||||
/**
|
||||
* Required components
|
||||
*
|
||||
|
@ -79,6 +83,28 @@
|
|||
*/
|
||||
public function quest($seminary, $groupsgroup, $quest, $station, $charactergroup)
|
||||
{
|
||||
// Get submission
|
||||
$submission = null;
|
||||
if(!is_null($charactergroup)) {
|
||||
$submission = $this->Keyword->getCharactergroupSubmission(
|
||||
$station['id'],
|
||||
$charactergroup['id']
|
||||
);
|
||||
}
|
||||
|
||||
// Get status
|
||||
$tried = false;
|
||||
if(!is_null($charactergroup)) {
|
||||
$tried = $this->Charactergroupsqueststations->hasCharactergroupTriedStation(
|
||||
$station['id'],
|
||||
$charactergroup['id']
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// Pass data to view
|
||||
$this->set('submission', $submission);
|
||||
$this->set('tried', $tried);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -115,6 +115,31 @@
|
|||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get Character group’s submitted answer for a station.
|
||||
*
|
||||
* @param int $stationId ID of Station
|
||||
* @param int $charactergroupId ID of Character group
|
||||
* @return string Submitted answer
|
||||
*/
|
||||
public function getCharactergroupSubmission($stationId, $charactergroupId)
|
||||
{
|
||||
$data = $this->db->query(
|
||||
'SELECT keyword '.
|
||||
'FROM stationtypes_keyword_charactergroups '.
|
||||
'WHERE station_id = ? AND charactergroup_id = ?',
|
||||
'ii',
|
||||
$stationId, $charactergroupId
|
||||
);
|
||||
if(!empty($data)) {
|
||||
return $data[0]['keyword'];
|
||||
}
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
<form method="post" class="keyword">
|
||||
<input type="text" id="keyword" name="answer" />
|
||||
<input type="text" id="keyword" name="answer" <?php if(!is_null($submission)) : ?>value="<?=$submission?>"<?php endif ?> <?php if($tried) : ?>disabled="disabled"<?php endif ?>/>
|
||||
<?php if(!$tried) : ?>
|
||||
<input type="submit" name="submit" value="<?=_('solve')?>" />
|
||||
<?php endif ?>
|
||||
</form>
|
||||
|
|
|
@ -19,6 +19,10 @@
|
|||
*/
|
||||
class MultiplechoiceStationtypeController extends \hhu\z\controllers\StationtypeController
|
||||
{
|
||||
/**
|
||||
* Required models
|
||||
*/
|
||||
public $models = array('charactergroupsqueststations');
|
||||
|
||||
|
||||
|
||||
|
@ -98,10 +102,25 @@
|
|||
{
|
||||
// Get answers
|
||||
$answers = $this->Multiplechoice->getAnswers($station['id']);
|
||||
if(!is_null($charactergroup)) {
|
||||
foreach($answers as &$answer) {
|
||||
$answer['submission'] = $this->Multiplechoice->getCharactergroupSubmission(
|
||||
$answer['id'],
|
||||
$charactergroup['id']
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Get status
|
||||
$tried = $this->Charactergroupsqueststations->hasCharactergroupTriedStation(
|
||||
$station['id'],
|
||||
$charactergroup['id']
|
||||
);
|
||||
|
||||
|
||||
// Pass data to view
|
||||
$this->set('answers', $answers);
|
||||
$this->set('tried', $tried);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -116,9 +116,9 @@
|
|||
|
||||
|
||||
/**
|
||||
* Save Character group’s submitted answer for a station.
|
||||
* Save Character group’s submission for an answer
|
||||
*
|
||||
* @param int $stationId ID of Station
|
||||
* @param int $answerId ID of answer
|
||||
* @param int $charactergroupId ID of Character group
|
||||
* @param string $answer Submitted answer
|
||||
*/
|
||||
|
@ -136,6 +136,31 @@
|
|||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get Character group’s submission for an answer.
|
||||
*
|
||||
* @param int $answerId ID of answer
|
||||
* @param int $charactergroupId ID of Character group
|
||||
* @return boolean Submission
|
||||
*/
|
||||
public function getCharactergroupSubmission($answerId, $charactergroupId)
|
||||
{
|
||||
$data = $this->db->query(
|
||||
'SELECT ticked '.
|
||||
'FROM stationtypes_multiplechoice_charactergroups '.
|
||||
'WHERE stationtypes_multiplechoice_id = ? AND charactergroup_id = ?',
|
||||
'ii',
|
||||
$answerId, $charactergroupId
|
||||
);
|
||||
if(!empty($data)) {
|
||||
return boolval($data[0]['ticked']);
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
@ -2,10 +2,12 @@
|
|||
<ol class="mchoice">
|
||||
<?php foreach($answers as $i => &$answer) : ?>
|
||||
<li class="cf">
|
||||
<input type="checkbox" id="answer[<?=$i?>]" name="answer[<?=$i?>]" value="true" />
|
||||
<input type="checkbox" id="answer[<?=$i?>]" name="answer[<?=$i?>]" value="true" <?php if(array_key_exists('submission', $answer) && $answer['submission'] === true) : ?>checked="checked"<?php endif ?> <?php if($tried) : ?>disabled="disabled"<?php endif ?>/>
|
||||
<label for="answer[<?=$i?>]"><?=$t->t($answer['answer'])?></label>
|
||||
</li>
|
||||
<?php endforeach ?>
|
||||
</ol>
|
||||
<?php if(!$tried) : ?>
|
||||
<input type="submit" name="submit" value="<?=_('solve')?>" />
|
||||
<?php endif ?>
|
||||
</form>
|
||||
|
|
Loading…
Add table
Reference in a new issue