show Questtexts for Quests

This commit is contained in:
coderkun 2014-02-12 10:31:05 +01:00
commit 6a356d2dec
4 changed files with 117 additions and 5 deletions

View file

@ -43,7 +43,7 @@
public function getQuestsForQuestgroup($questgroupId)
{
return $this->db->query(
'SELECT id, questtype_id, title, url, xps, text '.
'SELECT id, questtype_id, title, url, xps, task '.
'FROM quests '.
'WHERE questgroup_id = ?',
'i',
@ -64,7 +64,7 @@
public function getQuestByUrl($seminaryId, $questgroupId, $questUrl)
{
$data = $this->db->query(
'SELECT quests.id, quests.questtype_id, quests.title, quests.url, quests.xps, quests.text '.
'SELECT quests.id, quests.questtype_id, quests.title, quests.url, quests.xps, quests.task '.
'FROM quests '.
'LEFT JOIN questgroups ON questgroups.id = quests.questgroup_id '.
'LEFT JOIN questgroupshierarchy ON questgroupshierarchy.id = questgroups.questgroupshierarchy_id '.

View file

@ -0,0 +1,80 @@
<?php
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
namespace hhu\z\models;
/**
* Model to interact with Questtexts-table.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class QuesttextsModel extends \hhu\z\Model
{
/**
* Construct a new QuesttextsModel.
*/
public function __construct()
{
parent::__construct();
}
/**
* Get a Questtext for a Quest by its URL.
*
* @throws IdNotFoundException
* @param int $questId ID of the Quest to get text for
* @param string $questtexttypeUrl URL of the Questtexttype
* @param int $pos Position of Questtexttype
* @return array Questtexttype data
*/
public function getQuesttextByUrl($questId, $questtexttypeUrl, $pos)
{
$data = $this->db->query(
'SELECT questtexts.id, questtexts.text, questtexts.out_text, questtexttypes.type '.
'FROM questtexts '.
'LEFT JOIN questtexttypes ON questtexttypes.id = questtexts.questtexttype_id '.
'WHERE questtexts.quest_id = ? AnD questtexttypes.url = ? AND questtexts.pos = ?',
'isi',
$questId, $questtexttypeUrl, $pos
);
if(empty($data)) {
throw new \nre\exceptions\IdNotFoundException($questtexttypeUrl);
}
return $data = $data[0];
}
/**
* Get all registered Questtexttypes.
*
* @return array Registered Questtexttypes
*/
public function getQuesttexttypes()
{
return $this->db->query(
'SELECT id, type, url '.
'FROM questtexttypes'
);
}
}
?>