ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
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 28 of file class.ilAssQuestionHint.php.

Constructor & Destructor Documentation

◆ __construct()

ilAssQuestionHint::__construct ( )

Constructor.

public

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

80  {
81  }

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

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

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

References getId().

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

References $DIC, $ilDB, and $query.

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

◆ getHintIndexLabel()

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

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

References ilLanguage\txt().

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

388  : string
389  {
390  return sprintf($lng->txt('tst_question_hints_index_column_label'), $hintIndex);
391  }
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 393 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 89 of file class.ilAssQuestionHint.php.

References $id.

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

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

◆ getIndex()

ilAssQuestionHint::getIndex ( )

returns the ordering index of hint

public

Returns
integer $index

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

References $index.

Referenced by insert(), and update().

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

References load().

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

377  {
378  $questionHint = new self();
379  $questionHint->load($hintId);
380  return $questionHint;
381  }
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 383 of file class.ilAssQuestionHint.php.

383  : string
384  {
385  return self::PAGE_OBJECT_TYPE;
386  }

◆ getPoints()

ilAssQuestionHint::getPoints ( )

returns the points to ground-off for this hint

public

Returns
float $points

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

References $points.

Referenced by insert(), and update().

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

References $questionId.

Referenced by insert(), and update().

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

◆ getText()

ilAssQuestionHint::getText ( )

returns the hint text

public

Returns
string $text

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

References $text.

Referenced by insert(), and update().

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

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

Referenced by save().

289  : bool
290  {
291  global $DIC;
292  $ilDB = $DIC['ilDB'];
293 
294  $this->setId($ilDB->nextId('qpl_hints'));
295 
296  return $ilDB->insert('qpl_hints', array(
297  'qht_hint_id' => array('integer', $this->getId()),
298  'qht_question_fi' => array('integer', $this->getQuestionId()),
299  'qht_hint_index' => array('integer', $this->getIndex()),
300  'qht_hint_points' => array('float', $this->getPoints()),
301  'qht_hint_text' => array('clob', $this->getText())
302  ));
303  }
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
global $DIC
Definition: feed.php:28
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 204 of file class.ilAssQuestionHint.php.

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

Referenced by getInstanceById().

204  : bool
205  {
206  global $DIC;
207  $ilDB = $DIC['ilDB'];
208 
209  $query = "
210  SELECT qht_hint_id,
211  qht_question_fi,
212  qht_hint_index,
213  qht_hint_points,
214  qht_hint_text
215 
216  FROM qpl_hints
217 
218  WHERE qht_hint_id = %s
219  ";
220 
221  $res = $ilDB->queryF(
222  $query,
223  array('integer'),
224  array((int) $id)
225  );
226 
227  while ($row = $ilDB->fetchAssoc($res)) {
228  self::assignDbRow($this, $row);
229 
230  return true;
231  }
232 
233  return false;
234  }
$res
Definition: ltiservices.php:69
global $DIC
Definition: feed.php:28
$query
+ 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 245 of file class.ilAssQuestionHint.php.

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

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

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

Referenced by insert().

100  : void
101  {
102  $this->id = (int) $id;
103  }
+ 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 144 of file class.ilAssQuestionHint.php.

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

144  : void
145  {
146  $this->index = (int) $index;
147  }
+ 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 166 of file class.ilAssQuestionHint.php.

References $points.

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

◆ setQuestionId()

ilAssQuestionHint::setQuestionId (   $questionId)

sets the passed question id so hint relates to it

public

Parameters
integer$questionId

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

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

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

◆ setText()

ilAssQuestionHint::setText (   $text)

sets the passed hint text

public

Parameters
string$text

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

References $text, and getHtmlQuestionContentPurifier().

188  : void
189  {
190  if ($text !== null) {
191  $this->text = $this->getHtmlQuestionContentPurifier()->purify($text);
192  }
193  }
+ 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 262 of file class.ilAssQuestionHint.php.

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

Referenced by save().

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

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

◆ $index

ilAssQuestionHint::$index = null
private

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

Referenced by getIndex(), and setIndex().

◆ $points

ilAssQuestionHint::$points = null
private

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

Referenced by getPoints(), and setPoints().

◆ $questionId

ilAssQuestionHint::$questionId = null
private

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

Referenced by getQuestionId(), and setQuestionId().

◆ $text

ilAssQuestionHint::$text = null
private

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

Referenced by getText(), and setText().

◆ PAGE_OBJECT_TYPE

const ilAssQuestionHint::PAGE_OBJECT_TYPE = 'qht'

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


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