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
|
|
@ -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>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue