Constants

QUESTGROUP_STATUS_ENTERED

QUESTGROUP_STATUS_ENTERED

Questgroup-status: Entered

Properties

$models

$models : array

Required models

Type

array

$db

$db : \nre\models\DatabaseDriver

Database connection

Type

\nre\models\DatabaseDriver

Methods

__construct()

__construct() 

Construct a new QuestgroupsModel.

TODO Catch exception

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

factory()

factory(string  $modelName) 

Instantiate a Model (Factory Pattern).

Parameters

string $modelName

Name of the Model to instantiate

getQuestgroupsForHierarchy()

getQuestgroupsForHierarchy(integer  $hierarchyId, integer  $parentQuestgroupId = null) : array

Get all Questgroups for a Questgroup hierarchy.

Parameters

integer $hierarchyId

ID of the Questgroup hierarchy to get Questgroups for

integer $parentQuestgroupId

ID of the parent Questgroup hierarchy

Returns

array —

Questgroups for the given hierarchy

getQuestgroupsForSeminary()

getQuestgroupsForSeminary(integer  $seminaryId) : array

Get all Questgroups for a Seminary.

Parameters

integer $seminaryId

ID of Seminary

Returns

array —

List of Questgroups

getQuestgroupById()

getQuestgroupById(integer  $questgroupId) : array

Get a Questgroup by its ID.

Parameters

integer $questgroupId

ID of a Questgroup

Throws

\nre\exceptions\IdNotFoundException

Returns

array —

Questgroup data

getQuestgroupByUrl()

getQuestgroupByUrl(integer  $seminaryId,   $questgroupUrl) : array

Get a Questgroup by its URL.

Parameters

integer $seminaryId

ID of the corresponding seminary

$questgroupUrl

Throws

\nre\exceptions\IdNotFoundException

Returns

array —

Questgroup data

getNextQuestgroup()

getNextQuestgroup(integer  $questgroupId) : array

Get the next Questgroup.

Determine the next Questgroup. If there is no next Questgroup on the same level as the given Quest then the followed-up Questgroup from a higher hierarchy level is returned.

Parameters

integer $questgroupId

ID of Questgroup to get next Questgroup of

Returns

array —

Questgroup data

getPreviousQuestgroup()

getPreviousQuestgroup(integer  $questgroupId) : array

Get the previous Questgroup.

Determine the previous Questgroup. If there is no previous Questgroup on the same level as the given Quest then the followed-up Questgroup from a higher hierarchy level is returned.

Parameters

integer $questgroupId

ID of Questgroup to get previous Questgroup of

Returns

array —

Questgroup data

setQuestgroupEntered()

setQuestgroupEntered(  $questgroupId, integer  $characterId) 

Mark a Questgroup as entered for a Character.

Parameters

$questgroupId
integer $characterId

ID of Character that entered the Quest

hasCharacterEnteredQuestgroup()

hasCharacterEnteredQuestgroup(integer  $questgroupId, integer  $characterId) 

Determine if the given Character has entered a Questgroup.

Parameters

integer $questgroupId

ID of Questgroup to check

integer $characterId

ID of Character to check

hasCharacterSolvedQuestgroup()

hasCharacterSolvedQuestgroup(integer  $questgroupId, integer  $characterId) 

Determine if the given Character has solved a Questgroup.

Parameters

integer $questgroupId

ID of Questgroup to check

integer $characterId

ID of Character to check

getRelatedQuestsgroupsOfQuesttext()

getRelatedQuestsgroupsOfQuesttext(integer  $questtextId) : array

Get all related Questgroups of a Questtext.

Parameters

integer $questtextId

ID of the Questtext

Returns

array —

Related Questgroups for the Questtext

getRelatedQuestsgroupsOfQuest()

getRelatedQuestsgroupsOfQuest(integer  $questId) : array

Get all related Questgroups of a Quest.

Parameters

integer $questId

ID of the Quest

Returns

array —

Related Quests for the Quest

getRelatedQuestsgroupsOfQuestgroup()

getRelatedQuestsgroupsOfQuestgroup(integer  $questgroupId) : array

Get all related Questgroups of a Questgroup.

Parameters

integer $questgroupId

ID of the Questgroup

Returns

array —

Related Questgroups for the Questgroup

getAchievedXPsForQuestgroup()

getAchievedXPsForQuestgroup(integer  $questgroupId, integer  $characterId) : integer

Summarize XPs of all Quests for a Questgroup and its sub-Questgroups solved by a Character.

Parameters

integer $questgroupId

ID of Questgroup

integer $characterId

ID of Character

Returns

integer —

Sum of XPs

questgroupTitleExists()

questgroupTitleExists(integer  $seminaryId, string  $title, integer  $questgroupId = null) : boolean

Check if a Questgroups title already exists for a Seminary.

Parameters

integer $seminaryId

ID of Seminary

string $title

Questgroup title to check

integer $questgroupId

Do not check this ID (for editing)

Returns

boolean —

Whether Questgroup title exists or not

createQuestgroup()

createQuestgroup(integer  $userId, integer  $seminaryId, string  $title) : integer

Create a new Questgroup.

Parameters

integer $userId

User-ID that creates the new character

integer $seminaryId

ID of Seminary

string $title

Title for new Questgroup

Returns

integer —

ID of new Questgroup

setMoodpicForQuestgroup()

setMoodpicForQuestgroup(integer  $questgroupId, integer  $mediaId) 

Set the moodpic for a Questgroup.

Parameters

integer $questgroupId

ID of Questgroup to set moodpic for

integer $mediaId

ID of moodpic media

addQuestgroupToHierarchy()

addQuestgroupToHierarchy(integer  $questgroupId, integer  $hierarchyId, integer  $parentQuestgroupId) 

Add a Questgroup to a Questgroupshierarchy.

Parameters

integer $questgroupId

Id of Questgroup to add

integer $hierarchyId

Id of Hierarchy to add Questgroup to

integer $parentQuestgroupId

Id of parent Questgroup

moveQuestgroup()

moveQuestgroup(array  $questgroup, boolean  $up) 

Move a Questgroup up (decrement position) or down (increment position).

Parameters

array $questgroup

Questgroup to move

boolean $up

True for moving up, false for down

editQuestgroup()

editQuestgroup(integer  $questgroupId, string  $title) 

Edit a Questgroup.

Parameters

integer $questgroupId

ID of Questgroup to edit

string $title

New title of Questgroup

Throws

\nre\exceptions\DatamodelException

deleteQuestgroup()

deleteQuestgroup(integer  $questgroupId) 

Delete a Questgroup.

Parameters

integer $questgroupId

ID of Questgroup to delete

calculateXPsForQuestgroup()

calculateXPsForQuestgroup(integer  $questgroupId, array  $calculatedQuests = array()) : integer

Calculate the total amount of achievable XPs for a Questgroup, its sub-Questgroups, related Questgroups etc. and store this value in the database.

Parameters

integer $questgroupId

ID of Questgroup

array $calculatedQuests

Already calculated Quests

Returns

integer —

Sum of calculated XPs

loadDriver()

loadDriver(string  $driverName) 

Load the database driver.

Parameters

string $driverName

Name of the database driver

Throws

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

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

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

loadModels()

loadModels() 

Load the Models of this Model.

Throws

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

_getNextQuestgroup()

_getNextQuestgroup(integer  $parentQuestgroupId, integer  $questgroupPos) : array

Get the next (direct) Questgroup.

Parameters

integer $parentQuestgroupId

ID of parent Questgroup to get next Questgroup of

integer $questgroupPos

Position of Questgroup to get next Questgroup of

Returns

array —

Data of next Questgroup or NULL

_getPreviousQuestgroup()

_getPreviousQuestgroup(integer  $parentQuestgroupId, integer  $questgroupPos) : array

Get the previous (direct) Questgroup.

Parameters

integer $parentQuestgroupId

ID of parent Questgroup to get previous Questgroup of

integer $questgroupPos

Position of Questgroup to get previous Questgroup of

Returns

array —

Data of previous Questgroup or NULL

setQuestgroupStatus()

setQuestgroupStatus(integer  $questgroupId, integer  $characterId, integer  $status, boolean  $repeated = true) 

Mark a Questgroup for a Character.

Parameters

integer $questgroupId

ID of Questgroup to mark

integer $characterId

ID of Character to mark the Questgroup for

integer $status

Questgroup status to mark

boolean $repeated

Insert although status is already set for this Questgroup and Character

_getAchievedXPsForQuestgroup()

_getAchievedXPsForQuestgroup(integer  $questgroupId, integer  $characterId) : integer

Get the sum of XPs of Quests for a Questgroup solved by a Character.

Parameters

integer $questgroupId

ID of Questgroup

integer $characterId

ID of Character

Returns

integer —

Sum of XPs of Quests

_calculateXPsForQuestgroup()

_calculateXPsForQuestgroup(integer  $quest, array  $calculatedQuests = array()) : integer

Calculate the total amount of achievable XPs for a Quest and its following Quests by choosing the path with the highest amount of XPs.

Parameters

integer $quest

Quest data

array $calculatedQuests

Already calculated Quests

Returns

integer —

Sum of calculated XPs

setXPsForQuestgroup()

setXPsForQuestgroup(integer  $questgroupId, integer  $xps) 

Set achievable XPs for a Questgroup.

Parameters

integer $questgroupId

ID of Questgroup

integer $xps

XPs to set