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

Constructor & Destructor Documentation

◆ __construct()

ilAssQuestionHintList::__construct ( )

Constructor.

public

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

98  {
99  }

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 107 of file class.ilAssQuestionHintList.php.

Referenced by ilAssQuestionHintsGUI\pasteFromOrderingClipboardAfterCmd().

107  : void
108  {
109  $this->questionHints[] = $questionHint;
110  }
+ Here is the caller graph for this function:

◆ current()

ilAssQuestionHintList::current ( )

iterator interface method

public

Returns
mixed

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

44  {
45  return current($this->questionHints);
46  }
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 366 of file class.ilAssQuestionHintList.php.

References $DIC, $ilDB, and $query.

Referenced by assQuestion\delete().

367  {
368  global $DIC;
369  $ilDB = $DIC['ilDB'];
370 
371  $__qht_question_fi__IN__questionIds = $ilDB->in('qht_question_fi', $questionIds, false, 'integer');
372 
373  $query = "
374  DELETE FROM qpl_hints
375  WHERE $__qht_question_fi__IN__questionIds
376  ";
377 
378  return $ilDB->manipulate($query);
379  }
global $DIC
Definition: feed.php:28
$query
+ 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 184 of file class.ilAssQuestionHintList.php.

Referenced by assQuestion\duplicateQuestionHints().

184  : array
185  {
186  $hintIds = array();
187 
188  $questionHintList = self::getListByQuestionId($originalQuestionId);
189 
190  foreach ($questionHintList as $questionHint) {
191  /* @var $questionHint ilAssQuestionHint */
192 
193  $originalHintId = $questionHint->getId();
194 
195  $questionHint->setId(null);
196  $questionHint->setQuestionId($duplicateQuestionId);
197 
198  $questionHint->save();
199 
200  $duplicateHintId = $questionHint->getId();
201 
202  $hintIds[$originalHintId] = $duplicateHintId;
203  }
204 
205  return $hintIds;
206  }
+ 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 119 of file class.ilAssQuestionHintList.php.

120  {
121  foreach ($this as $questionHint) {
122  /* @var $questionHint ilAssQuestionHint */
123 
124  if ($questionHint->getId() == $hintId) {
125  return $questionHint;
126  }
127  }
128 
129  require_once 'Modules/TestQuestionPool/exceptions/class.ilTestQuestionPoolException.php';
130  throw new ilTestQuestionPoolException("hint with id $hintId does not exist in this list");
131  }

◆ 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 289 of file class.ilAssQuestionHintList.php.

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

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

290  {
291  global $DIC;
292  $ilDB = $DIC['ilDB'];
293 
294  $qht_hint_id__IN__hintIds = $ilDB->in('qht_hint_id', (array) $hintIds, false, 'integer');
295 
296  $query = "
297  SELECT qht_hint_id,
298  qht_question_fi,
299  qht_hint_index,
300  qht_hint_points,
301  qht_hint_text
302 
303  FROM qpl_hints
304 
305  WHERE $qht_hint_id__IN__hintIds
306 
307  ORDER BY qht_hint_index ASC
308  ";
309 
310  $res = $ilDB->query($query);
311 
312  $questionHintList = new self();
313 
314  while ($row = $ilDB->fetchAssoc($res)) {
315  $questionHint = new ilAssQuestionHint();
316 
317  ilAssQuestionHint::assignDbRow($questionHint, $row);
318 
319  $questionHintList->addHint($questionHint);
320  }
321 
322  return $questionHintList;
323  }
$res
Definition: ltiservices.php:69
global $DIC
Definition: feed.php:28
$query
static assignDbRow(self $questionHint, $hintDbRow)
assigns the field elements of passed hint db row array to the corresponding hint object properties of...
+ 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 242 of file class.ilAssQuestionHintList.php.

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

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

243  {
244  global $DIC;
245  $ilDB = $DIC['ilDB'];
246 
247  $query = "
248  SELECT qht_hint_id,
249  qht_question_fi,
250  qht_hint_index,
251  qht_hint_points,
252  qht_hint_text
253 
254  FROM qpl_hints
255 
256  WHERE qht_question_fi = %s
257 
258  ORDER BY qht_hint_index ASC
259  ";
260 
261  $res = $ilDB->queryF(
262  $query,
263  array('integer'),
264  array((int) $questionId)
265  );
266 
267  $questionHintList = new self();
268 
269  while ($row = $ilDB->fetchAssoc($res)) {
270  $questionHint = new ilAssQuestionHint();
271 
272  ilAssQuestionHint::assignDbRow($questionHint, $row);
273 
274  $questionHintList->addHint($questionHint);
275  }
276 
277  return $questionHintList;
278  }
$res
Definition: ltiservices.php:69
global $DIC
Definition: feed.php:28
$query
static assignDbRow(self $questionHint, $hintDbRow)
assigns the field elements of passed hint db row array to the corresponding hint object properties of...
+ 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 336 of file class.ilAssQuestionHintList.php.

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

Referenced by ilAssQuestionHintGUI\saveFormCmd().

336  : int
337  {
338  global $DIC;
339  $ilDB = $DIC['ilDB'];
340 
341  $query = "
342  SELECT 1 + COALESCE( MAX(qht_hint_index), 0 ) next_index
343 
344  FROM qpl_hints
345 
346  WHERE qht_question_fi = %s
347  ";
348 
349  $res = $ilDB->queryF(
350  $query,
351  array('integer'),
352  array((int) $questionId)
353  );
354 
355  $row = $ilDB->fetchAssoc($res);
356 
357  return $row['next_index'];
358  }
$res
Definition: ltiservices.php:69
global $DIC
Definition: feed.php:28
$query
+ 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 215 of file class.ilAssQuestionHintList.php.

Referenced by ilAssQuestionHintsTableGUI\__construct().

215  : array
216  {
217  $tableData = array();
218 
219  foreach ($this as $questionHint) {
220  /* @var $questionHint ilAssQuestionHint */
221 
222  $tableData[] = array(
223  'hint_id' => $questionHint->getId(),
224  'hint_index' => $questionHint->getIndex(),
225  'hint_points' => $questionHint->getPoints(),
226  'hint_text' => $questionHint->getText()
227  );
228  }
229 
230  return $tableData;
231  }
+ 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 141 of file class.ilAssQuestionHintList.php.

141  : bool
142  {
143  foreach ($this as $questionHint) {
144  /* @var $questionHint ilAssQuestionHint */
145 
146  if ($questionHint->getId() == $hintId) {
147  return true;
148  }
149  }
150 
151  return false;
152  }

◆ key()

ilAssQuestionHintList::key ( )

iterator interface method

public

Returns
mixed

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

Referenced by valid().

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

◆ next()

ilAssQuestionHintList::next ( )

iterator interface method

public

Returns
mixed

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

66  {
67  return next($this->questionHints);
68  }
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 163 of file class.ilAssQuestionHintList.php.

163  : void
164  {
165  $counter = 0;
166 
167  foreach ($this as $questionHint) {
168  /* @var $questionHint ilAssQuestionHint */
169 
170  $questionHint->setIndex(++$counter);
171  $questionHint->save();
172  }
173  }

◆ rewind()

ilAssQuestionHintList::rewind ( )

iterator interface method

public

Returns
mixed

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

55  {
56  return reset($this->questionHints);
57  }

◆ valid()

ilAssQuestionHintList::valid ( )

iterator interface method

public

Returns
boolean

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

References key().

87  : bool
88  {
89  return key($this->questionHints) !== null;
90  }
key()
iterator interface method
+ Here is the call graph for this function:

Field Documentation

◆ $questionHints

ilAssQuestionHintList::$questionHints = array()
private

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


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