ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 350 of file class.ilAssQuestionHintList.php.

References $ilDB, and $query.

Referenced by assQuestion\delete().

351  {
352  global $ilDB;
353 
354  $__qht_question_fi__IN__questionIds = $ilDB->in('qht_question_fi', $questionIds, false, 'integer');
355 
356  $query = "
357  DELETE FROM qpl_hints
358  WHERE $__qht_question_fi__IN__questionIds
359  ";
360 
361  return $ilDB->manipulate($query);
362  }
$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.

References array.

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  }
Create styles array
The data for the language used.
+ 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 275 of file class.ilAssQuestionHintList.php.

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

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

276  {
277  global $ilDB;
278 
279  $qht_hint_id__IN__hintIds = $ilDB->in('qht_hint_id', $hintIds, false, 'integer');
280 
281  $query = "
282  SELECT qht_hint_id,
283  qht_question_fi,
284  qht_hint_index,
285  qht_hint_points,
286  qht_hint_text
287 
288  FROM qpl_hints
289 
290  WHERE $qht_hint_id__IN__hintIds
291 
292  ORDER BY qht_hint_index ASC
293  ";
294 
295  $res = $ilDB->query($query);
296 
297  $questionHintList = new self();
298 
299  while ($row = $ilDB->fetchAssoc($res)) {
300  $questionHint = new ilAssQuestionHint();
301 
302  ilAssQuestionHint::assignDbRow($questionHint, $row);
303 
304  $questionHintList->addHint($questionHint);
305  }
306 
307  return $questionHintList;
308  }
foreach($_POST as $key=> $value) $res
$query
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 $ilDB, $query, $res, $row, array, 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 $ilDB;
232 
233  $query = "
234  SELECT qht_hint_id,
235  qht_question_fi,
236  qht_hint_index,
237  qht_hint_points,
238  qht_hint_text
239 
240  FROM qpl_hints
241 
242  WHERE qht_question_fi = %s
243 
244  ORDER BY qht_hint_index ASC
245  ";
246 
247  $res = $ilDB->queryF(
248  $query,
249  array('integer'),
250  array((int) $questionId)
251  );
252 
253  $questionHintList = new self();
254 
255  while ($row = $ilDB->fetchAssoc($res)) {
256  $questionHint = new ilAssQuestionHint();
257 
258  ilAssQuestionHint::assignDbRow($questionHint, $row);
259 
260  $questionHintList->addHint($questionHint);
261  }
262 
263  return $questionHintList;
264  }
foreach($_POST as $key=> $value) $res
$query
Create styles array
The data for the language used.
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 321 of file class.ilAssQuestionHintList.php.

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

Referenced by ilAssQuestionHintGUI\saveFormCmd().

322  {
323  global $ilDB;
324 
325  $query = "
326  SELECT 1 + COALESCE( MAX(qht_hint_index), 0 ) next_index
327 
328  FROM qpl_hints
329 
330  WHERE qht_question_fi = %s
331  ";
332 
333  $res = $ilDB->queryF(
334  $query,
335  array('integer'),
336  array((int) $questionId)
337  );
338 
339  $row = $ilDB->fetchAssoc($res);
340 
341  return $row['next_index'];
342  }
foreach($_POST as $key=> $value) $res
$query
Create styles array
The data for the language used.
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.

References array.

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  }
Create styles array
The data for the language used.
+ 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.

References $counter.

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

◆ 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: