ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilAssQuestionHint Class Reference
+ Collaboration diagram for ilAssQuestionHint:

Public Member Functions

 __construct ()
 Constructor. More...
 
 getId ()
 returns the hint id More...
 
 setId ($id)
 sets the passed hint id More...
 
 getQuestionId ()
 returns the question id the hint currently relates to More...
 
 setQuestionId ($questionId)
 sets the passed question id so hint relates to it More...
 
 getIndex ()
 returns the ordering index of hint More...
 
 setIndex ($index)
 sets the passed hint ordering index More...
 
 getPoints ()
 returns the points to ground-off for this hint More...
 
 setPoints ($points)
 sets the passed points to ground-off for this hint More...
 
 getText ()
 returns the hint text More...
 
 setText ($text)
 sets the passed hint text More...
 
 load ($id)
 loads the hint dataset with passed id from database and assigns it the to this hint object instance More...
 
 save ()
 saves the current hint object state to database. More...
 
 delete ()
 deletes the persisted hint object in database by deleting the hint dataset identified by hint id More...
 
 getPageObjectType ()
 

Static Public Member Functions

static assignDbRow (self $questionHint, $hintDbRow)
 assigns the field elements of passed hint db row array to the corresponding hint object properties of passed hint object instance More...
 
static deleteById ($hintId)
 deletes the persisted hint object in database by deleting the hint dataset identified by hint id More...
 
static getInstanceById ($hintId)
 creates a hint object instance, loads the persisted hint dataset identified by passed hint id from database and assigns it as object state More...
 
static getHintIndexLabel (ilLanguage $lng, $hintIndex)
 

Data Fields

const PAGE_OBJECT_TYPE = 'qht'
 

Private Member Functions

 update ()
 persists the current object state to database by updating an existing dataset identified by hint id More...
 
 insert ()
 persists the current object state to database by inserting a new dataset with a new hint id fetched from primary key sequence More...
 

Private Attributes

 $id = null
 
 $questionId = null
 
 $index = null
 
 $points = null
 
 $text = null
 

Detailed Description

Definition at line 14 of file class.ilAssQuestionHint.php.

Constructor & Destructor Documentation

◆ __construct()

ilAssQuestionHint::__construct ( )

Constructor.

public

Definition at line 65 of file class.ilAssQuestionHint.php.

66  {
67  }

Member Function Documentation

◆ assignDbRow()

static ilAssQuestionHint::assignDbRow ( self  $questionHint,
  $hintDbRow 
)
static

assigns the field elements of passed hint db row array to the corresponding hint object properties of passed hint object instance

public

Parameters
self$questionHint
array$hintDbRow

Definition at line 309 of file class.ilAssQuestionHint.php.

Referenced by ilAssQuestionHintList\getListByHintIds(), and ilAssQuestionHintList\getListByQuestionId().

310  {
311  foreach ($hintDbRow as $field => $value) {
312  switch ($field) {
313  case 'qht_hint_id': $questionHint->setId($value); break;
314  case 'qht_question_fi': $questionHint->setQuestionId($value); break;
315  case 'qht_hint_index': $questionHint->setIndex($value); break;
316  case 'qht_hint_points': $questionHint->setPoints($value); break;
317  case 'qht_hint_text': $questionHint->setText($value); break;
318 
319  default: throw new ilTestQuestionPoolException("invalid db field identifier ($field) given!");
320  }
321  }
322  }
+ Here is the caller graph for this function:

◆ delete()

ilAssQuestionHint::delete ( )

deletes the persisted hint object in database by deleting the hint dataset identified by hint id

Returns
integer $affectedRows

Definition at line 295 of file class.ilAssQuestionHint.php.

References getId().

296  {
297  return self::deleteById($this->getId());
298  }
getId()
returns the hint id
+ Here is the call graph for this function:

◆ deleteById()

static ilAssQuestionHint::deleteById (   $hintId)
static

deletes the persisted hint object in database by deleting the hint dataset identified by hint id

public ilDBInterface $ilDB

Parameters
integer$hintId
Returns
integer $affectedRows

Definition at line 334 of file class.ilAssQuestionHint.php.

References $DIC, $ilDB, and $query.

335  {
336  global $DIC;
337  $ilDB = $DIC['ilDB'];
338 
339  $query = "
340  DELETE FROM qpl_hints
341  WHERE qht_hint_id = %s
342  ";
343 
344  return $ilDB->manipulateF(
345  $query,
346  array('integer'),
347  array($hintId)
348  );
349  }
global $DIC
Definition: saml.php:7
$query
global $ilDB

◆ getHintIndexLabel()

static ilAssQuestionHint::getHintIndexLabel ( ilLanguage  $lng,
  $hintIndex 
)
static

Definition at line 372 of file class.ilAssQuestionHint.php.

References ilLanguage\txt().

Referenced by ilAssQuestionHintPageObjectCommandForwarder\buildPreviewPresentationPageObjectGUI(), ilAssQuestionHintPageObjectCommandForwarder\buildRequestPresentationPageObjectGUI(), and ilAssQuestionHintsTableGUI\fillRow().

373  {
374  return sprintf($lng->txt('tst_question_hints_index_column_label'), $hintIndex);
375  }
txt($a_topic, $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getId()

ilAssQuestionHint::getId ( )

returns the hint id

public

Returns
integer $id

Definition at line 75 of file class.ilAssQuestionHint.php.

References $id.

Referenced by delete(), insert(), save(), ilAssQuestionPreviewHintTracking\storeRequest(), ilAssQuestionHintTracking\storeRequest(), and update().

76  {
77  return $this->id;
78  }
+ Here is the caller graph for this function:

◆ getIndex()

ilAssQuestionHint::getIndex ( )

returns the ordering index of hint

public

Returns
integer $index

Definition at line 119 of file class.ilAssQuestionHint.php.

References $index.

Referenced by insert(), and update().

120  {
121  return $this->index;
122  }
+ Here is the caller graph for this function:

◆ getInstanceById()

static ilAssQuestionHint::getInstanceById (   $hintId)
static

creates a hint object instance, loads the persisted hint dataset identified by passed hint id from database and assigns it as object state

public

Parameters
integer$hintId
Returns
self $hintInstance

Definition at line 360 of file class.ilAssQuestionHint.php.

Referenced by ilAssQuestionPreviewHintTracking\getNextRequestableHint(), ilAssQuestionHintTracking\getNextRequestableHint(), ilAssQuestionHintsGUI\initHintOrderingClipboardNotification(), ilAssQuestionHintsGUI\pasteFromOrderingClipboardAfterCmd(), ilAssQuestionHintsGUI\pasteFromOrderingClipboardBeforeCmd(), ilAssQuestionHintRequestGUI\showHintCmd(), and ilAssQuestionHintsGUI\showHintCmd().

361  {
362  $questionHint = new self();
363  $questionHint->load($hintId);
364  return $questionHint;
365  }
+ Here is the caller graph for this function:

◆ getPageObjectType()

ilAssQuestionHint::getPageObjectType ( )

Definition at line 367 of file class.ilAssQuestionHint.php.

368  {
369  return self::PAGE_OBJECT_TYPE;
370  }

◆ getPoints()

ilAssQuestionHint::getPoints ( )

returns the points to ground-off for this hint

public

Returns
integer $points

Definition at line 141 of file class.ilAssQuestionHint.php.

References $points.

Referenced by insert(), and update().

142  {
143  return $this->points;
144  }
+ Here is the caller graph for this function:

◆ getQuestionId()

ilAssQuestionHint::getQuestionId ( )

returns the question id the hint currently relates to

public

Returns
integer $questionId

Definition at line 97 of file class.ilAssQuestionHint.php.

References $questionId.

Referenced by insert(), and update().

98  {
99  return $this->questionId;
100  }
+ Here is the caller graph for this function:

◆ getText()

ilAssQuestionHint::getText ( )

returns the hint text

public

Returns
string $text

Definition at line 163 of file class.ilAssQuestionHint.php.

References $text.

Referenced by insert(), and update().

164  {
165  return $this->text;
166  }
+ Here is the caller graph for this function:

◆ insert()

ilAssQuestionHint::insert ( )
private

persists the current object state to database by inserting a new dataset with a new hint id fetched from primary key sequence

private ilDBInterface $ilDB

Returns
boolean $success

Definition at line 273 of file class.ilAssQuestionHint.php.

References $DIC, $ilDB, getId(), getIndex(), getPoints(), getQuestionId(), getText(), and setId().

Referenced by save().

274  {
275  global $DIC;
276  $ilDB = $DIC['ilDB'];
277 
278  $this->setId($ilDB->nextId('qpl_hints'));
279 
280  return $ilDB->insert('qpl_hints', array(
281  'qht_hint_id' => array('integer', $this->getId()),
282  'qht_question_fi' => array('integer', $this->getQuestionId()),
283  'qht_hint_index' => array('integer', $this->getIndex()),
284  'qht_hint_points' => array('float', $this->getPoints()),
285  'qht_hint_text' => array('clob', $this->getText())
286  ));
287  }
setId($id)
sets the passed hint id
global $DIC
Definition: saml.php:7
getIndex()
returns the ordering index of hint
getQuestionId()
returns the question id the hint currently relates to
getId()
returns the hint id
getPoints()
returns the points to ground-off for this hint
global $ilDB
getText()
returns the hint text
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ load()

ilAssQuestionHint::load (   $id)

loads the hint dataset with passed id from database and assigns it the to this hint object instance

public ilDBInterface $ilDB

Parameters
integer$id
Returns
boolean $success

Definition at line 188 of file class.ilAssQuestionHint.php.

References $DIC, $id, $ilDB, $query, $res, and $row.

189  {
190  global $DIC;
191  $ilDB = $DIC['ilDB'];
192 
193  $query = "
194  SELECT qht_hint_id,
195  qht_question_fi,
196  qht_hint_index,
197  qht_hint_points,
198  qht_hint_text
199 
200  FROM qpl_hints
201 
202  WHERE qht_hint_id = %s
203  ";
204 
205  $res = $ilDB->queryF(
206  $query,
207  array('integer'),
208  array((int) $id)
209  );
210 
211  while ($row = $ilDB->fetchAssoc($res)) {
212  self::assignDbRow($this, $row);
213 
214  return true;
215  }
216 
217  return false;
218  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$query
$row
global $ilDB

◆ save()

ilAssQuestionHint::save ( )

saves the current hint object state to database.

it performs an insert or update, depending on the current initialisation of the hint id property

a valid initialised id leads to an update, a non or invalid initialised id leads to an insert

public

Returns
boolean $success

Definition at line 229 of file class.ilAssQuestionHint.php.

References getId(), insert(), and update().

230  {
231  if ($this->getId()) {
232  return $this->update();
233  } else {
234  return $this->insert();
235  }
236  }
update()
persists the current object state to database by updating an existing dataset identified by hint id ...
getId()
returns the hint id
insert()
persists the current object state to database by inserting a new dataset with a new hint id fetched f...
+ Here is the call graph for this function:

◆ setId()

ilAssQuestionHint::setId (   $id)

sets the passed hint id

public

Parameters
integer$id

Definition at line 86 of file class.ilAssQuestionHint.php.

References $id.

Referenced by insert().

87  {
88  $this->id = (int) $id;
89  }
+ Here is the caller graph for this function:

◆ setIndex()

ilAssQuestionHint::setIndex (   $index)

sets the passed hint ordering index

public

Parameters
integer$index

Definition at line 130 of file class.ilAssQuestionHint.php.

References $index.

131  {
132  $this->index = (int) $index;
133  }

◆ setPoints()

ilAssQuestionHint::setPoints (   $points)

sets the passed points to ground-off for this hint

public

Parameters
integer$points

Definition at line 152 of file class.ilAssQuestionHint.php.

References $points.

153  {
154  $this->points = (float) $points;
155  }

◆ setQuestionId()

ilAssQuestionHint::setQuestionId (   $questionId)

sets the passed question id so hint relates to it

public

Parameters
integer$questionId

Definition at line 108 of file class.ilAssQuestionHint.php.

References $questionId.

109  {
110  $this->questionId = (int) $questionId;
111  }

◆ setText()

ilAssQuestionHint::setText (   $text)

sets the passed hint text

public

Parameters
string$text

Definition at line 174 of file class.ilAssQuestionHint.php.

References $text.

175  {
176  $this->text = $text;
177  }

◆ update()

ilAssQuestionHint::update ( )
private

persists the current object state to database by updating an existing dataset identified by hint id

private ilDBInterface $ilDB

Returns
boolean $success

Definition at line 246 of file class.ilAssQuestionHint.php.

References $DIC, $ilDB, getId(), getIndex(), getPoints(), getQuestionId(), and getText().

Referenced by save().

247  {
248  global $DIC;
249  $ilDB = $DIC['ilDB'];
250 
251  return $ilDB->update(
252  'qpl_hints',
253  array(
254  'qht_question_fi' => array('integer', $this->getQuestionId()),
255  'qht_hint_index' => array('integer', $this->getIndex()),
256  'qht_hint_points' => array('float', $this->getPoints()),
257  'qht_hint_text' => array('clob', $this->getText())
258  ),
259  array(
260  'qht_hint_id' => array('integer', $this->getId())
261  )
262  );
263  }
global $DIC
Definition: saml.php:7
getIndex()
returns the ordering index of hint
getQuestionId()
returns the question id the hint currently relates to
getId()
returns the hint id
getPoints()
returns the points to ground-off for this hint
global $ilDB
getText()
returns the hint text
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $id

ilAssQuestionHint::$id = null
private

Definition at line 24 of file class.ilAssQuestionHint.php.

Referenced by getId(), load(), and setId().

◆ $index

ilAssQuestionHint::$index = null
private

Definition at line 41 of file class.ilAssQuestionHint.php.

Referenced by getIndex(), and setIndex().

◆ $points

ilAssQuestionHint::$points = null
private

Definition at line 50 of file class.ilAssQuestionHint.php.

Referenced by getPoints(), and setPoints().

◆ $questionId

ilAssQuestionHint::$questionId = null
private

Definition at line 32 of file class.ilAssQuestionHint.php.

Referenced by getQuestionId(), and setQuestionId().

◆ $text

ilAssQuestionHint::$text = null
private

Definition at line 58 of file class.ilAssQuestionHint.php.

Referenced by getText(), and setText().

◆ PAGE_OBJECT_TYPE

const ilAssQuestionHint::PAGE_OBJECT_TYPE = 'qht'

Definition at line 16 of file class.ilAssQuestionHint.php.


The documentation for this class was generated from the following file: