# \hhu\z\modelsQuestsModel

Model to interact with Quests-table.

## Summary

Methods
Properties
Constants
__construct()
load()
factory()
getQuestByUrl()
getQuestById()
getFirstQuestOfQuestgroup()
getLastQuestsOfQuestgroup()
getNextQuests()
getPreviousQuests()
setPreviousQuest()
setQuestEntered()
setQuestSubmitted()
setQuestUnsolved()
setQuestSolved()
hasCharacterEnteredQuest()
hasCharacterTriedQuest()
hasCharacterSolvedQuest()
getLastQuestForCharacter()
getQuestsForSeminary()
getCountForQuestsForSeminaryByOpenSubmissions()
getQuestsForSeminaryByOpenSubmissions()
getQuestsForQuesttopic()
getLastQuestStatus()
questTitleExists()
createQuest()
setQuestmedia()
editQuest()
deleteQuest()
No public properties found
QUEST_STATUS_ENTERED
QUEST_STATUS_SUBMITTED
QUEST_STATUS_UNSOLVED
QUEST_STATUS_SOLVED
No protected methods found
$db
N/A
loadDriver()
connect()
getClassName()
loadModels()
setQuestStatus()
No private properties found
N/A

File
  models/QuestsModel.inc
Package
  Default
Class hierarchy
  \nre\core\Model
  \nre\models\DatabaseModel
  \hhu\z\Model
  \hhu\z\models\QuestsModel

## Tags

author | Oliver Hanraths oliver.hanraths@uni-duesseldorf.de

## Constants

### QUEST_STATUS_ENTERED

    QUEST_STATUS_ENTERED

Quest-status: Entered

#

## Tags

None found

### QUEST_STATUS_SUBMITTED

    QUEST_STATUS_SUBMITTED

Quest-status: submitted

#

## Tags

None found

### QUEST_STATUS_UNSOLVED

    QUEST_STATUS_UNSOLVED

Quest-status: Unsolved

#

## Tags

None found

### QUEST_STATUS_SOLVED

    QUEST_STATUS_SOLVED

Quest-status: Solved

#

## Tags

None found

## Properties

### $db

    $db : \nre\models\DatabaseDriver

Database connection

#### Type

\nre\models\DatabaseDriver

#

Inherited from
  \nre\models\DatabaseModel

## Tags

static |

## Methods

### __construct()

    __construct()

Construct a new QuestsModel.

TODO Catch exception

#

## Tags

None found

### load()

    load(string  $modelName)

Load the class of a Model.

#### Parameters

string | $modelName | Name of the Model to load

#### Throws

\nre\exceptions\ModelNotFoundException
\nre\exceptions\ModelNotValidException

#

static

Inherited from
  \nre\core\Model

## Tags

None found

### factory()

    factory(string  $modelName)

Instantiate a Model (Factory Pattern).

#### Parameters

string | $modelName | Name of the Model to instantiate

#

static

Inherited from
  \nre\core\Model

## Tags

None found

### getQuestByUrl()

    getQuestByUrl(integer  $seminaryId, integer  $questgroupId,   $questUrl) : array

Get a Quest and its data by its URL.

#### Parameters

integer | $seminaryId | ID of the corresponding Seminary
integer | $questgroupId | ID of the corresponding Questgroup
| $questUrl |

#### Throws

\nre\exceptions\IdNotFoundException

#### Returns

array —

Quest data

#

## Tags

None found

### getQuestById()

    getQuestById(string  $questId) : array

Get a Quest and its data by its ID.

#### Parameters

string | $questId | ID of a Quest

#### Throws

\nre\exceptions\IdNotFoundException

#### Returns

array —

Quest data

#

## Tags

None found

### getFirstQuestOfQuestgroup()

    getFirstQuestOfQuestgroup(  $questgroupId) : array

Get the first Quest of a Qusetgroup.

#### Parameters

| $questgroupId |

#### Returns

array —

Data of first Quest

#

## Tags

None found

### getLastQuestsOfQuestgroup()

    getLastQuestsOfQuestgroup(  $questgroupId) : array

Get all Quests a Qusetgroup that do not have a following Quest.

#### Parameters

| $questgroupId |

#### Returns

array —

List of last Quests

#

## Tags

None found

### getNextQuests()

    getNextQuests(integer  $questId) : array

Get Quests that follow-up a Quest.

#### Parameters

integer | $questId | ID of Quest to get next Quests of

#### Returns

array —

Quests data

#

## Tags

None found

### getPreviousQuests()

    getPreviousQuests(integer  $questId) : array

Get Quests that the given Quests follows-up to.

#### Parameters

integer | $questId | ID of Quest to get previous Quests of

#### Returns

array —

Quests data

#

## Tags

None found

### setPreviousQuest()

    setPreviousQuest(integer  $questId, integer  $previousQuestId)

Set the previous Quest for a Quest.

#### Parameters

integer | $questId | ID of Quest to set previous Quest for
integer | $previousQuestId | Id of previous Quest

#

## Tags

None found

### setQuestEntered()

    setQuestEntered(integer  $questId, integer  $characterId)

Mark a Quest as entered for a Character.

#### Parameters

integer | $questId | ID of Quest to mark as entered
integer | $characterId | ID of Character that entered the Quest

#

## Tags

None found

### setQuestSubmitted()

    setQuestSubmitted(integer  $questId, integer  $characterId)

Mark a Quest as submitted for a Character.

#### Parameters

integer | $questId | ID of Quest to mark as unsolved
integer | $characterId | ID of Character that unsolved the Quest

#

## Tags

None found

### setQuestUnsolved()

    setQuestUnsolved(integer  $questId, integer  $characterId)

Mark a Quest as unsolved for a Character.

#### Parameters

integer | $questId | ID of Quest to mark as unsolved
integer | $characterId | ID of Character that unsolved the Quest

#

## Tags

None found

### setQuestSolved()

    setQuestSolved(integer  $questId, integer  $characterId)

Mark a Quest as solved for a Character.

#### Parameters

integer | $questId | ID of Quest to mark as solved
integer | $characterId | ID of Character that solved the Quest

#

## Tags

None found

### hasCharacterEnteredQuest()

    hasCharacterEnteredQuest(integer  $questId, integer  $characterId)

Determine if the given Character has entered a Quest.

#### Parameters

integer | $questId | ID of Quest to check
integer | $characterId | ID of Character to check

#

## Tags

result | boolean Whether Character has entered the Quest or not

### hasCharacterTriedQuest()

    hasCharacterTriedQuest(integer  $questId, integer  $characterId)

Determine if the given Character has tried to solve a Quest.

#### Parameters

integer | $questId | ID of Quest to check
integer | $characterId | ID of Character to check

#

## Tags

result | boolean Whether Character has tried to solved the Quest or not

### hasCharacterSolvedQuest()

    hasCharacterSolvedQuest(integer  $questId, integer  $characterId)

Determine if the given Character has solved the given Quest.

#### Parameters

integer | $questId | ID of Quest to check
integer | $characterId | ID of Character to check

#

## Tags

result | boolean Whether Character has solved the Quest or not

### getLastQuestForCharacter()

    getLastQuestForCharacter(integer  $characterId)

Get the last Quests for a Character.

#### Parameters

integer | $characterId | ID of Character

#

## Tags

retrun | array Quest data

### getQuestsForSeminary()

    getQuestsForSeminary(integer  $seminaryId) : array

Get all Quests for a Seminary.

#### Parameters

integer | $seminaryId | ID of Seminary

#### Returns

array —

Quests for this Seminary

#

## Tags

None found

### getCountForQuestsForSeminaryByOpenSubmissions()

    getCountForQuestsForSeminaryByOpenSubmissions(integer  $seminaryId, integer  $questgroupId = null, integer  $questtypeId = null, string  $title = null) : integer

Get count of all Quests for a Seminary.

#### Parameters

integer | $seminaryId | ID of Seminary
integer | $questgroupId | ID of Questgroup (optional)
integer | $questtypeId | ID of Questtype (optional)
string | $title | Part of the title to filter for (optional)

#### Returns

integer —

Count of Quests for this Seminary

#

## Tags

None found

### getQuestsForSeminaryByOpenSubmissions()

    getQuestsForSeminaryByOpenSubmissions(integer  $seminaryId, integer  $questgroupId = null, integer  $questtypeId = null, string  $title = null, integer  $limit = null, integer  $offset) : array

Get all Quests for a Seminary order by their count of open submissions.

#### Parameters

integer | $seminaryId | ID of Seminary
integer | $questgroupId | ID of Questgroup (optional)
integer | $questtypeId | ID of Questtype (optional)
string | $title | Part of title to filter for (optional)
integer | $limit | Limit amount of Quests (optional)
integer | $offset | Offset (optional)

#### Returns

array —

Quests for this Seminary

#

## Tags

None found

### getQuestsForQuesttopic()

    getQuestsForQuesttopic(integer  $questtopicId) : array

Get all Quests that are linked to a Questtopic.

#### Parameters

integer | $questtopicId | ID of Questtopic

#### Returns

array —

Quests for this Questtopic

#

## Tags

None found

### getLastQuestStatus()

    getLastQuestStatus(integer  $questId, integer  $characterId) : integer

Get the last status of a Quest for a Character.

#### Parameters

integer | $questId | ID of Quest
integer | $characterId | ID of Character to get status for

#### Returns

integer —

Last status

#

## Tags

None found

### questTitleExists()

    questTitleExists(string  $title, integer  $seminaryId, integer  $questId = null) : boolean

Check if a Quest title already exists.

#### Parameters

string | $title | Quest title to check
integer | $seminaryId | ID of Seminary
integer | $questId | Do not check this ID (for editing)

#### Returns

boolean —

Whether Quest title exists or not

#

## Tags

None found

### createQuest()

    createQuest(integer  $userId, integer  $questgroupId, integer  $questtypeId, string  $title, integer  $xps, string  $task, string  $entrytext, string  $wrongtext) : integer

Create a new Quest.

#### Parameters

integer | $userId | User-ID that creates the new character
integer | $questgroupId | ID of Questgroup
integer | $questtypeId | ID of Questtype
string | $title | Title for new Quest
integer | $xps | XPs for new Quest
string | $task | Task for new Quest
string | $entrytext | Entrytext for new Quest
string | $wrongtext | Wrongtext for new Quest

#### Returns

integer —

ID of new Quest

#

## Tags

None found

### setQuestmedia()

    setQuestmedia(integer  $questId,   $questsmediaId)

Set the media for a Quest.

#### Parameters

integer | $questId | ID of Quest to set media for
| $questsmediaId |

#

## Tags

None found

### editQuest()

    editQuest(integer  $questId, integer  $questtypeId, string  $title, integer  $xps, string  $task, string  $entrytext, string  $wrongtext)

Edit a new Quest.

#### Parameters

integer | $questId | ID of Quest to edit
integer | $questtypeId | ID of Questtype
string | $title | New title for Quest
integer | $xps | XPs for Quest
string | $task | New task for Quest
string | $entrytext | New entrytext for Quest
string | $wrongtext | New wrongtext for Quest

#

## Tags

None found

### deleteQuest()

    deleteQuest(integer  $questId)

Delete a Quest of a Seminary.

#### Parameters

integer | $questId | ID of Quest to delete

#

## Tags

None found

### loadDriver()

    loadDriver(string  $driverName)

Load the database driver.

#### Parameters

string | $driverName | Name of the database driver

#### Throws

\nre\exceptions\DriverNotFoundException
\nre\exceptions\DriverNotValidException

#

Inherited from
  \nre\models\DatabaseModel

## Tags

None found

### connect()

    connect(string  $driverName, array  $config)

Establish a connection to the database.

#### Parameters

string | $driverName | Name of the database driver
array | $config | Connection settings

#### Throws

\nre\exceptions\DatamodelException

#

Inherited from
  \nre\models\DatabaseModel

## Tags

None found

### getClassName()

    getClassName(string  $modelName) : string

Determine the classname for the given Model name.

#### Parameters

string | $modelName | Model name to get classname of

#### Returns

string —

Classname fore the Model name

#

static

Inherited from
  \nre\core\Model

## Tags

None found

### loadModels()

    loadModels()

Load the Models of this Model.

#### Throws

\nre\exceptions\DatamodelException
\nre\exceptions\DriverNotFoundException
\nre\exceptions\DriverNotValidException
\nre\exceptions\ModelNotValidException
\nre\exceptions\ModelNotFoundException

#

Inherited from
  \nre\core\Model

## Tags

None found

### setQuestStatus()

    setQuestStatus(integer  $questId, integer  $characterId, integer  $status, boolean  $repeated = true)

Mark a Quest for a Character.

#### Parameters

integer | $questId | ID of Quest to mark
integer | $characterId | ID of Character to mark the Quest for
integer | $status | Quest status to mark
boolean | $repeated | Insert although status is already set for this Quest and Character

#

## Tags

None found

### QuestsModel.inc