ILIAS  trunk Revision v5.2.0beta1-34115-g3a2438be29
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'
 

Protected Member Functions

 getHtmlQuestionContentPurifier ()
 

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 26 of file class.ilAssQuestionHint.php.

Constructor & Destructor Documentation

◆ __construct()

ilAssQuestionHint::__construct ( )

Constructor.

public

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

78  {
79  }

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 323 of file class.ilAssQuestionHint.php.

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

323  : void
324  {
325  foreach ($hintDbRow as $field => $value) {
326  switch ($field) {
327  case 'qht_hint_id': $questionHint->setId($value);
328  break;
329  case 'qht_question_fi': $questionHint->setQuestionId($value);
330  break;
331  case 'qht_hint_index': $questionHint->setIndex($value);
332  break;
333  case 'qht_hint_points': $questionHint->setPoints($value);
334  break;
335  case 'qht_hint_text': $questionHint->setText($value);
336  break;
337 
338  default: throw new ilTestQuestionPoolException("invalid db field identifier ($field) given!");
339  }
340  }
341  }
+ 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 309 of file class.ilAssQuestionHint.php.

References getId().

309  : int
310  {
311  return self::deleteById($this->getId());
312  }
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 353 of file class.ilAssQuestionHint.php.

References $DIC, and $ilDB.

353  : int
354  {
355  global $DIC;
356  $ilDB = $DIC['ilDB'];
357 
358  $query = "
359  DELETE FROM qpl_hints
360  WHERE qht_hint_id = %s
361  ";
362 
363  return $ilDB->manipulateF(
364  $query,
365  array('integer'),
366  array($hintId)
367  );
368  }
$DIC
Definition: xapitoken.php:62

◆ getHintIndexLabel()

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

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

References ilLanguage\txt().

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

391  : string
392  {
393  return sprintf($lng->txt('tst_question_hints_index_column_label'), $hintIndex);
394  }
txt(string $a_topic, string $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:

◆ getHtmlQuestionContentPurifier()

ilAssQuestionHint::getHtmlQuestionContentPurifier ( )
protected

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

References ilHtmlPurifierFactory\getInstanceByType().

Referenced by setText().

+ 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 87 of file class.ilAssQuestionHint.php.

References $id.

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

87  : ?int
88  {
89  return $this->id;
90  }
+ Here is the caller graph for this function:

◆ getIndex()

ilAssQuestionHint::getIndex ( )

returns the ordering index of hint

public

Returns
integer $index

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

References $index.

Referenced by insert(), and update().

131  : ?int
132  {
133  return $this->index;
134  }
+ 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 379 of file class.ilAssQuestionHint.php.

References load().

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

380  {
381  $questionHint = new self();
382  $questionHint->load($hintId);
383  return $questionHint;
384  }
load($id)
loads the hint dataset with passed id from database and assigns it the to this hint object instance ...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getPageObjectType()

ilAssQuestionHint::getPageObjectType ( )

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

386  : string
387  {
388  return self::PAGE_OBJECT_TYPE;
389  }

◆ getPoints()

ilAssQuestionHint::getPoints ( )

returns the points to ground-off for this hint

public

Returns
float $points

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

References $points.

Referenced by insert(), and update().

153  : ?float
154  {
155  return $this->points;
156  }
+ 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 109 of file class.ilAssQuestionHint.php.

References $questionId.

Referenced by insert(), and update().

109  : ?int
110  {
111  return $this->questionId;
112  }
+ Here is the caller graph for this function:

◆ getText()

ilAssQuestionHint::getText ( )

returns the hint text

public

Returns
string $text

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

References $text.

Referenced by insert(), and update().

175  : ?string
176  {
177  return $this->text;
178  }
+ 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 287 of file class.ilAssQuestionHint.php.

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

Referenced by save().

287  : bool
288  {
289  global $DIC;
290  $ilDB = $DIC['ilDB'];
291 
292  $this->setId($ilDB->nextId('qpl_hints'));
293 
294  return $ilDB->insert('qpl_hints', array(
295  'qht_hint_id' => array('integer', $this->getId()),
296  'qht_question_fi' => array('integer', $this->getQuestionId()),
297  'qht_hint_index' => array('integer', $this->getIndex()),
298  'qht_hint_points' => array('float', $this->getPoints()),
299  'qht_hint_text' => array('clob', $this->getText())
300  ));
301  }
setId($id)
sets the passed hint id
getIndex()
returns the ordering index of hint
getQuestionId()
returns the question id the hint currently relates to
getId()
returns the hint id
$DIC
Definition: xapitoken.php:62
getPoints()
returns the points to ground-off for this hint
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 202 of file class.ilAssQuestionHint.php.

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

Referenced by getInstanceById().

202  : bool
203  {
204  global $DIC;
205  $ilDB = $DIC['ilDB'];
206 
207  $query = "
208  SELECT qht_hint_id,
209  qht_question_fi,
210  qht_hint_index,
211  qht_hint_points,
212  qht_hint_text
213 
214  FROM qpl_hints
215 
216  WHERE qht_hint_id = %s
217  ";
218 
219  $res = $ilDB->queryF(
220  $query,
221  array('integer'),
222  array((int) $id)
223  );
224 
225  while ($row = $ilDB->fetchAssoc($res)) {
226  self::assignDbRow($this, $row);
227 
228  return true;
229  }
230 
231  return false;
232  }
$res
Definition: ltiservices.php:67
$DIC
Definition: xapitoken.php:62
+ Here is the caller graph for this function:

◆ 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 243 of file class.ilAssQuestionHint.php.

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

243  : bool
244  {
245  if ($this->getId()) {
246  return $this->update();
247  } else {
248  return $this->insert();
249  }
250  }
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 98 of file class.ilAssQuestionHint.php.

References $id, and ILIAS\Repository\int().

Referenced by insert().

98  : void
99  {
100  $this->id = (int) $id;
101  }
+ Here is the call graph for this function:
+ 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 142 of file class.ilAssQuestionHint.php.

References $index, and ILIAS\Repository\int().

142  : void
143  {
144  $this->index = (int) $index;
145  }
+ Here is the call graph for this function:

◆ setPoints()

ilAssQuestionHint::setPoints (   $points)

sets the passed points to ground-off for this hint

public

Parameters
float$points

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

References $points.

164  : void
165  {
166  $this->points = abs((float) $points);
167  }

◆ setQuestionId()

ilAssQuestionHint::setQuestionId (   $questionId)

sets the passed question id so hint relates to it

public

Parameters
integer$questionId

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

References $questionId, and ILIAS\Repository\int().

120  : void
121  {
122  $this->questionId = (int) $questionId;
123  }
+ Here is the call graph for this function:

◆ setText()

ilAssQuestionHint::setText (   $text)

sets the passed hint text

public

Parameters
string$text

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

References $text, and getHtmlQuestionContentPurifier().

186  : void
187  {
188  if ($text !== null) {
189  $this->text = $this->getHtmlQuestionContentPurifier()->purify($text);
190  }
191  }
+ Here is the call graph for this function:

◆ 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 260 of file class.ilAssQuestionHint.php.

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

Referenced by save().

260  : bool
261  {
262  global $DIC;
263  $ilDB = $DIC['ilDB'];
264 
265  return $ilDB->update(
266  'qpl_hints',
267  array(
268  'qht_question_fi' => array('integer', $this->getQuestionId()),
269  'qht_hint_index' => array('integer', $this->getIndex()),
270  'qht_hint_points' => array('float', $this->getPoints()),
271  'qht_hint_text' => array('clob', $this->getText())
272  ),
273  array(
274  'qht_hint_id' => array('integer', $this->getId())
275  )
276  );
277  }
getIndex()
returns the ordering index of hint
getQuestionId()
returns the question id the hint currently relates to
getId()
returns the hint id
$DIC
Definition: xapitoken.php:62
getPoints()
returns the points to ground-off for this hint
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 36 of file class.ilAssQuestionHint.php.

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

◆ $index

ilAssQuestionHint::$index = null
private

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

Referenced by getIndex(), and setIndex().

◆ $points

ilAssQuestionHint::$points = null
private

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

Referenced by getPoints(), and setPoints().

◆ $questionId

ilAssQuestionHint::$questionId = null
private

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

Referenced by getQuestionId(), and setQuestionId().

◆ $text

ilAssQuestionHint::$text = null
private

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

Referenced by getText(), and setText().

◆ PAGE_OBJECT_TYPE

const ilAssQuestionHint::PAGE_OBJECT_TYPE = 'qht'

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


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