Properties

$db

$db : \nre\models\DatabaseDriver

Database connection

Type

\nre\models\DatabaseDriver

Methods

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

checkClass()

checkClass(string  $className, string  $parentClassName) 

Check inheritance of the QuesttypeModel-class.

Parameters

string $className

Name of the class to check

string $parentClassName

Name of the parent class

Throws

\nre\exceptions\ClassNotValidException

getQuestionsCountOfQuest()

getQuestionsCountOfQuest(integer  $questId) : integer

Get the count of multiple choice questions for a Quest.

Parameters

integer $questId

ID of Quest to get count for

Returns

integer —

Conut of questions

getQuestionsOfQuest()

getQuestionsOfQuest(integer  $questId) : array

Get all multiple choice questions of a Quest.

Parameters

integer $questId

ID of Quest

Returns

array —

Multiple choice questions

getQuestionOfQuest()

getQuestionOfQuest(integer  $questId, integer  $pos) : array

Get one multiple choice question of a Quest.

Parameters

integer $questId

ID of Quest

integer $pos

Position of question

Returns

array —

Question data

getAnswersOfQuestion()

getAnswersOfQuestion(integer  $questionId) : array

Get all answers of a multiple choice question.

Parameters

integer $questionId

ID of multiple choice question

Returns

array —

Answers of question

setCharacterSubmission()

setCharacterSubmission(integer  $answerId, integer  $characterId, boolean  $answer) 

Save Character’s submitted answer for one option.

Parameters

integer $answerId

ID of multiple choice answer

integer $characterId

ID of Character

boolean $answer

Submitted answer for this option

getCharacterSubmission()

getCharacterSubmission(integer  $answerId, integer  $characterId) : boolean

Get answer of one option submitted by Character.

Parameters

integer $answerId

ID of multiple choice answer

integer $characterId

ID of Character

Returns

boolean —

Submitted answer of Character or false

setQuestionForQuest()

setQuestionForQuest(integer  $userId, integer  $questId, integer  $pos, string  $question) 

Set a question for a multiplechoice Quest.

Parameters

integer $userId

ID of user

integer $questId

ID of Quest to set question for

integer $pos

Position of question

string $question

Question text

deleteQuestionsOfQuest()

deleteQuestionsOfQuest(integer  $questId, integer  $offset) 

Delete questions of a Quest.

Parameters

integer $questId

ID of Quest to delete question of

integer $offset

Only delete questions after this position

setAnswerForQuestion()

setAnswerForQuestion(integer  $userId, integer  $questId, integer  $questionPos, integer  $answerPos, string  $answer, boolean  $tick) 

Set an answer for a question.

Parameters

integer $userId

ID of user

integer $questId

ID of Quest to set answer for

integer $questionPos

Position of question

integer $answerPos

Position of answer

string $answer

Answer text

boolean $tick

Whether answer is correct or not

deleteAnswersOfQuestion()

deleteAnswersOfQuestion(integer  $questId, integer  $questionPos, integer  $offset) 

Delete answers of a question.

Parameters

integer $questId

ID of Quest to delete answers for

integer $questionPos

Position of question

integer $offset

Only delete answers after this position

__construct()

__construct() 

Construct a new Model.

TODO Catch exception

Throws

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

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

loadClass()

loadClass(string  $questtypeName, string  $fullClassName) 

Load the class of a QuesttypeModel.

Parameters

string $questtypeName

Name of the QuesttypeModel to load

string $fullClassName

Name of the class to load

Throws

\nre\exceptions\ClassNotFoundException

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

loadModels()

loadModels() 

Load the Models of this Model.

Throws

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