diff --git a/controllers/CharactergroupsqueststationsController.inc b/controllers/CharactergroupsqueststationsController.inc index 3a180d22..60c3610b 100644 --- a/controllers/CharactergroupsqueststationsController.inc +++ b/controllers/CharactergroupsqueststationsController.inc @@ -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 { diff --git a/stationtypes/keyword/KeywordStationtypeController.inc b/stationtypes/keyword/KeywordStationtypeController.inc index c5a2609b..cd1b53aa 100644 --- a/stationtypes/keyword/KeywordStationtypeController.inc +++ b/stationtypes/keyword/KeywordStationtypeController.inc @@ -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); } diff --git a/stationtypes/keyword/KeywordStationtypeModel.inc b/stationtypes/keyword/KeywordStationtypeModel.inc index eef2e2e8..c61995e7 100644 --- a/stationtypes/keyword/KeywordStationtypeModel.inc +++ b/stationtypes/keyword/KeywordStationtypeModel.inc @@ -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; + } + } ?> diff --git a/stationtypes/keyword/html/quest.tpl b/stationtypes/keyword/html/quest.tpl index 20ee3c20..b09b6c7f 100644 --- a/stationtypes/keyword/html/quest.tpl +++ b/stationtypes/keyword/html/quest.tpl @@ -1,4 +1,6 @@
- + value="" disabled="disabled"/> + +
diff --git a/stationtypes/multiplechoice/MultiplechoiceStationtypeController.inc b/stationtypes/multiplechoice/MultiplechoiceStationtypeController.inc index c1f0bc75..1d7a4cf8 100644 --- a/stationtypes/multiplechoice/MultiplechoiceStationtypeController.inc +++ b/stationtypes/multiplechoice/MultiplechoiceStationtypeController.inc @@ -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); } diff --git a/stationtypes/multiplechoice/MultiplechoiceStationtypeModel.inc b/stationtypes/multiplechoice/MultiplechoiceStationtypeModel.inc index 6756bc05..2e3c637e 100644 --- a/stationtypes/multiplechoice/MultiplechoiceStationtypeModel.inc +++ b/stationtypes/multiplechoice/MultiplechoiceStationtypeModel.inc @@ -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; + } + } ?> diff --git a/stationtypes/multiplechoice/html/quest.tpl b/stationtypes/multiplechoice/html/quest.tpl index 79872785..6255cf05 100644 --- a/stationtypes/multiplechoice/html/quest.tpl +++ b/stationtypes/multiplechoice/html/quest.tpl @@ -2,10 +2,12 @@
    &$answer) : ?>
  1. - + checked="checked" disabled="disabled"/>
+ +