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

Public Member Functions

 current ()
 iterator interface method More...
 
 rewind ()
 iterator interface method More...
 
 next ()
 iterator interface method More...
 
 key ()
 iterator interface method More...
 
 valid ()
 iterator interface method More...
 
 __construct ()
 Constructor. More...
 
 addHint (ilAssQuestionHint $questionHint)
 adds a question hint object to the current list instance More...
 
 getHint ($hintId)
 returns the question hint object relating to the passed hint id More...
 
 hintExists ($hintId)
 checks wether a question hint object relating to the passed id exists or not More...
 
 reIndex ()
 re-indexes the list's hints sequentially by current order (starting with index "1") More...
 
 getTableData ()
 returns an array with data of the hints in this list that is adopted to be used as table gui data More...
 

Static Public Member Functions

static duplicateListForQuestion ($originalQuestionId, $duplicateQuestionId)
 duplicates a hint list from given original question id to given duplicate question id and returns an array of duplicate hint ids mapped to the corresponding original hint ids More...
 
static getListByQuestionId ($questionId)
 instantiates a question hint list for the passed question id More...
 
static getListByHintIds ($hintIds)
 instantiates a question hint list for the passed hint ids More...
 
static getNextIndexByQuestionId ($questionId)
 determines the next index to be used for a new hint that is to be added to the list of existing hints regarding to the question with passed question id More...
 
static deleteHintsByQuestionIds ($questionIds)
 Deletes all question hints relating to questions included in given question ids. More...
 

Private Attributes

 $questionHints = array()
 

Detailed Description

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

Constructor & Destructor Documentation

◆ __construct()

ilAssQuestionHintList::__construct ( )

Constructor.

public

Definition at line 84 of file class.ilAssQuestionHintList.php.

85  {
86  }

Member Function Documentation

◆ addHint()

ilAssQuestionHintList::addHint ( ilAssQuestionHint  $questionHint)

adds a question hint object to the current list instance

public

Parameters
ilAssQuestionHint$questionHint

Definition at line 94 of file class.ilAssQuestionHintList.php.

Referenced by ilAssQuestionHintsGUI\pasteFromOrderingClipboardAfterCmd().

95  {
96  $this->questionHints[] = $questionHint;
97  }
+ Here is the caller graph for this function:

◆ current()

ilAssQuestionHintList::current ( )

iterator interface method

public

Returns
mixed

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

31  {
32  return current($this->questionHints);
33  }
current()
iterator interface method

◆ deleteHintsByQuestionIds()

static ilAssQuestionHintList::deleteHintsByQuestionIds (   $questionIds)
static

Deletes all question hints relating to questions included in given question ids.

ilDBInterface $ilDB

Parameters
array[integer]$questionIds

Definition at line 353 of file class.ilAssQuestionHintList.php.

References $DIC, $ilDB, and $query.

Referenced by assQuestion\delete().

354  {
355  global $DIC;
356  $ilDB = $DIC['ilDB'];
357 
358  $__qht_question_fi__IN__questionIds = $ilDB->in('qht_question_fi', $questionIds, false, 'integer');
359 
360  $query = "
361  DELETE FROM qpl_hints
362  WHERE $__qht_question_fi__IN__questionIds
363  ";
364 
365  return $ilDB->manipulate($query);
366  }
global $DIC
Definition: saml.php:7
$query
global $ilDB
+ Here is the caller graph for this function:

◆ duplicateListForQuestion()

static ilAssQuestionHintList::duplicateListForQuestion (   $originalQuestionId,
  $duplicateQuestionId 
)
static

duplicates a hint list from given original question id to given duplicate question id and returns an array of duplicate hint ids mapped to the corresponding original hint ids

Parameters
integer$originalQuestionId
integer$duplicateQuestionId
Returns
array $hintIds containing the map from original hint ids to duplicate hint ids

Definition at line 171 of file class.ilAssQuestionHintList.php.

Referenced by assQuestion\duplicateQuestionHints().

172  {
173  $hintIds = array();
174 
175  $questionHintList = self::getListByQuestionId($originalQuestionId);
176 
177  foreach ($questionHintList as $questionHint) {
178  /* @var $questionHint ilAssQuestionHint */
179 
180  $originalHintId = $questionHint->getId();
181 
182  $questionHint->setId(null);
183  $questionHint->setQuestionId($duplicateQuestionId);
184 
185  $questionHint->save();
186 
187  $duplicateHintId = $questionHint->getId();
188 
189  $hintIds[$originalHintId] = $duplicateHintId;
190  }
191 
192  return $hintIds;
193  }
+ Here is the caller graph for this function:

◆ getHint()

ilAssQuestionHintList::getHint (   $hintId)

returns the question hint object relating to the passed hint id

public

Parameters
integer$hintId
Returns
ilAssQuestionHint $questionHint

Definition at line 106 of file class.ilAssQuestionHintList.php.

107  {
108  foreach ($this as $questionHint) {
109  /* @var $questionHint ilAssQuestionHint */
110 
111  if ($questionHint->getId() == $hintId) {
112  return $questionHint;
113  }
114  }
115 
116  require_once 'Modules/TestQuestionPool/exceptions/class.ilTestQuestionPoolException.php';
117  throw new ilTestQuestionPoolException("hint with id $hintId does not exist in this list");
118  }

◆ getListByHintIds()

static ilAssQuestionHintList::getListByHintIds (   $hintIds)
static

instantiates a question hint list for the passed hint ids

public ilDBInterface $ilDB

Parameters
array$hintIds
Returns
self $questionHintList

Definition at line 276 of file class.ilAssQuestionHintList.php.

References $DIC, $ilDB, $query, $res, $row, and ilAssQuestionHint\assignDbRow().

Referenced by ilAssQuestionPreviewHintTracking\getRequestedHintsList(), and ilAssQuestionHintTracking\getRequestedHintsList().

277  {
278  global $DIC;
279  $ilDB = $DIC['ilDB'];
280 
281  $qht_hint_id__IN__hintIds = $ilDB->in('qht_hint_id', $hintIds, false, 'integer');
282 
283  $query = "
284  SELECT qht_hint_id,
285  qht_question_fi,
286  qht_hint_index,
287  qht_hint_points,
288  qht_hint_text
289 
290  FROM qpl_hints
291 
292  WHERE $qht_hint_id__IN__hintIds
293 
294  ORDER BY qht_hint_index ASC
295  ";
296 
297  $res = $ilDB->query($query);
298 
299  $questionHintList = new self();
300 
301  while ($row = $ilDB->fetchAssoc($res)) {
302  $questionHint = new ilAssQuestionHint();
303 
304  ilAssQuestionHint::assignDbRow($questionHint, $row);
305 
306  $questionHintList->addHint($questionHint);
307  }
308 
309  return $questionHintList;
310  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$query
$row
static assignDbRow(self $questionHint, $hintDbRow)
assigns the field elements of passed hint db row array to the corresponding hint object properties of...
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getListByQuestionId()

static ilAssQuestionHintList::getListByQuestionId (   $questionId)
static

instantiates a question hint list for the passed question id

public ilDBInterface $ilDB

Parameters
integer$questionId
Returns
self $questionHintList

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

References $DIC, $ilDB, $query, $res, $row, and ilAssQuestionHint\assignDbRow().

Referenced by ilAssQuestionHintsGUI\checkForExistingHintRelatingToCurrentQuestionAndRedirectOnFailure(), ilAssQuestionHintsGUI\confirmDeleteCmd(), assQuestion\getRTETextWithMediaObjects(), ilAssQuestionHintsGUI\pasteFromOrderingClipboardAfterCmd(), ilAssQuestionHintsGUI\pasteFromOrderingClipboardBeforeCmd(), ilAssQuestionHintsGUI\performDeleteCmd(), ilAssQuestionHintsGUI\saveListOrderCmd(), and ilAssQuestionHintsGUI\showListCmd().

230  {
231  global $DIC;
232  $ilDB = $DIC['ilDB'];
233 
234  $query = "
235  SELECT qht_hint_id,
236  qht_question_fi,
237  qht_hint_index,
238  qht_hint_points,
239  qht_hint_text
240 
241  FROM qpl_hints
242 
243  WHERE qht_question_fi = %s
244 
245  ORDER BY qht_hint_index ASC
246  ";
247 
248  $res = $ilDB->queryF(
249  $query,
250  array('integer'),
251  array((int) $questionId)
252  );
253 
254  $questionHintList = new self();
255 
256  while ($row = $ilDB->fetchAssoc($res)) {
257  $questionHint = new ilAssQuestionHint();
258 
259  ilAssQuestionHint::assignDbRow($questionHint, $row);
260 
261  $questionHintList->addHint($questionHint);
262  }
263 
264  return $questionHintList;
265  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$query
$row
static assignDbRow(self $questionHint, $hintDbRow)
assigns the field elements of passed hint db row array to the corresponding hint object properties of...
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getNextIndexByQuestionId()

static ilAssQuestionHintList::getNextIndexByQuestionId (   $questionId)
static

determines the next index to be used for a new hint that is to be added to the list of existing hints regarding to the question with passed question id

public ilDBInterface $ilDB

Parameters
integer$questionId
Returns
integer $nextIndex

Definition at line 323 of file class.ilAssQuestionHintList.php.

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

Referenced by ilAssQuestionHintGUI\saveFormCmd().

324  {
325  global $DIC;
326  $ilDB = $DIC['ilDB'];
327 
328  $query = "
329  SELECT 1 + COALESCE( MAX(qht_hint_index), 0 ) next_index
330 
331  FROM qpl_hints
332 
333  WHERE qht_question_fi = %s
334  ";
335 
336  $res = $ilDB->queryF(
337  $query,
338  array('integer'),
339  array((int) $questionId)
340  );
341 
342  $row = $ilDB->fetchAssoc($res);
343 
344  return $row['next_index'];
345  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$query
$row
global $ilDB
+ Here is the caller graph for this function:

◆ getTableData()

ilAssQuestionHintList::getTableData ( )

returns an array with data of the hints in this list that is adopted to be used as table gui data

public

Returns
array $tableData

Definition at line 202 of file class.ilAssQuestionHintList.php.

Referenced by ilAssQuestionHintsTableGUI\__construct().

203  {
204  $tableData = array();
205 
206  foreach ($this as $questionHint) {
207  /* @var $questionHint ilAssQuestionHint */
208 
209  $tableData[] = array(
210  'hint_id' => $questionHint->getId(),
211  'hint_index' => $questionHint->getIndex(),
212  'hint_points' => $questionHint->getPoints(),
213  'hint_text' => $questionHint->getText()
214  );
215  }
216 
217  return $tableData;
218  }
+ Here is the caller graph for this function:

◆ hintExists()

ilAssQuestionHintList::hintExists (   $hintId)

checks wether a question hint object relating to the passed id exists or not

public

Parameters
integer$hintId
Returns
boolean $hintExists

Definition at line 128 of file class.ilAssQuestionHintList.php.

129  {
130  foreach ($this as $questionHint) {
131  /* @var $questionHint ilAssQuestionHint */
132 
133  if ($questionHint->getId() == $hintId) {
134  return true;
135  }
136  }
137 
138  return false;
139  }

◆ key()

ilAssQuestionHintList::key ( )

iterator interface method

public

Returns
mixed

Definition at line 63 of file class.ilAssQuestionHintList.php.

Referenced by valid().

64  {
65  return key($this->questionHints);
66  }
key()
iterator interface method
+ Here is the caller graph for this function:

◆ next()

ilAssQuestionHintList::next ( )

iterator interface method

public

Returns
mixed

Definition at line 52 of file class.ilAssQuestionHintList.php.

53  {
54  return next($this->questionHints);
55  }
next()
iterator interface method

◆ reIndex()

ilAssQuestionHintList::reIndex ( )

re-indexes the list's hints sequentially by current order (starting with index "1")

ATTENTION: it also persists this index to db by performing an update of hint object via id. do not re-index any hint list objects unless this lists contain ALL hint objects for a SINGLE question and no more hints apart of that.

public

Definition at line 150 of file class.ilAssQuestionHintList.php.

151  {
152  $counter = 0;
153 
154  foreach ($this as $questionHint) {
155  /* @var $questionHint ilAssQuestionHint */
156 
157  $questionHint->setIndex(++$counter);
158  $questionHint->save();
159  }
160  }

◆ rewind()

ilAssQuestionHintList::rewind ( )

iterator interface method

public

Returns
mixed

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

42  {
43  return reset($this->questionHints);
44  }

◆ valid()

ilAssQuestionHintList::valid ( )

iterator interface method

public

Returns
boolean

Definition at line 74 of file class.ilAssQuestionHintList.php.

References key().

75  {
76  return key($this->questionHints) !== null;
77  }
key()
iterator interface method
+ Here is the call graph for this function:

Field Documentation

◆ $questionHints

ilAssQuestionHintList::$questionHints = array()
private

Definition at line 22 of file class.ilAssQuestionHintList.php.


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