ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f87
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 69 of file class.ilAssQuestionHintList.php.

69 { }

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

Referenced by ilAssQuestionHintsGUI\pasteFromOrderingClipboardAfterCmd().

78  {
79  $this->questionHints[] = $questionHint;
80  }
+ 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.

References current().

Referenced by current().

30 { return current($this->questionHints); }
current()
iterator interface method
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deleteHintsByQuestionIds()

static ilAssQuestionHintList::deleteHintsByQuestionIds (   $questionIds)
static

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

ilDB $ilDB

Parameters
array[integer]$questionIds

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

References $ilDB, and $query.

Referenced by assQuestion\delete().

339  {
340  global $ilDB;
341 
342  $__qht_question_fi__IN__questionIds = $ilDB->in('qht_question_fi', $questionIds, false, 'integer');
343 
344  $query = "
345  DELETE FROM qpl_hints
346  WHERE $__qht_question_fi__IN__questionIds
347  ";
348 
349  return $ilDB->manipulate($query);
350  }
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 159 of file class.ilAssQuestionHintList.php.

Referenced by assQuestion\duplicateQuestionHints().

160  {
161  $hintIds = array();
162 
163  $questionHintList = self::getListByQuestionId($originalQuestionId);
164 
165  foreach($questionHintList as $questionHint)
166  {
167  /* @var $questionHint ilAssQuestionHint */
168 
169  $originalHintId = $questionHint->getId();
170 
171  $questionHint->setId(null);
172  $questionHint->setQuestionId($duplicateQuestionId);
173 
174  $questionHint->save();
175 
176  $duplicateHintId = $questionHint->getId();
177 
178  $hintIds[$originalHintId] = $duplicateHintId;
179  }
180 
181  return $hintIds;
182  }
+ 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 89 of file class.ilAssQuestionHintList.php.

90  {
91  foreach($this as $questionHint)
92  {
93  /* @var $questionHint ilAssQuestionHint */
94 
95  if( $questionHint->getId() == $hintId )
96  {
97  return $questionHint;
98  }
99  }
100 
101  require_once 'Modules/TestQuestionPool/exceptions/class.ilTestQuestionPoolException.php';
102  throw new ilTestQuestionPoolException("hint with id $hintId does not exist in this list");
103  }

◆ getListByHintIds()

static ilAssQuestionHintList::getListByHintIds (   $hintIds)
static

instantiates a question hint list for the passed hint ids

public ilDB $ilDB

Parameters
array$hintIds
Returns
self $questionHintList

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

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

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

265  {
266  global $ilDB;
267 
268  $qht_hint_id__IN__hintIds = $ilDB->in('qht_hint_id', $hintIds, false, 'integer');
269 
270  $query = "
271  SELECT qht_hint_id,
272  qht_question_fi,
273  qht_hint_index,
274  qht_hint_points,
275  qht_hint_text
276 
277  FROM qpl_hints
278 
279  WHERE $qht_hint_id__IN__hintIds
280 
281  ORDER BY qht_hint_index ASC
282  ";
283 
284  $res = $ilDB->query($query);
285 
286  $questionHintList = new self();
287 
288  while( $row = $ilDB->fetchAssoc($res) )
289  {
290  $questionHint = new ilAssQuestionHint();
291 
292  ilAssQuestionHint::assignDbRow($questionHint, $row);
293 
294  $questionHintList->addHint($questionHint);
295  }
296 
297  return $questionHintList;
298  }
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 ilDB $ilDB

Parameters
integer$questionId
Returns
self $questionHintList

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

References $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().

220  {
221  global $ilDB;
222 
223  $query = "
224  SELECT qht_hint_id,
225  qht_question_fi,
226  qht_hint_index,
227  qht_hint_points,
228  qht_hint_text
229 
230  FROM qpl_hints
231 
232  WHERE qht_question_fi = %s
233 
234  ORDER BY qht_hint_index ASC
235  ";
236 
237  $res = $ilDB->queryF(
238  $query, array('integer'), array((int)$questionId)
239  );
240 
241  $questionHintList = new self();
242 
243  while( $row = $ilDB->fetchAssoc($res) )
244  {
245  $questionHint = new ilAssQuestionHint();
246 
247  ilAssQuestionHint::assignDbRow($questionHint, $row);
248 
249  $questionHintList->addHint($questionHint);
250  }
251 
252  return $questionHintList;
253  }
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 ilDB $ilDB

Parameters
integer$questionId
Returns
integer $nextIndex

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

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

Referenced by ilAssQuestionHintGUI\saveFormCmd().

312  {
313  global $ilDB;
314 
315  $query = "
316  SELECT 1 + COALESCE( MAX(qht_hint_index), 0 ) next_index
317 
318  FROM qpl_hints
319 
320  WHERE qht_question_fi = %s
321  ";
322 
323  $res = $ilDB->queryF(
324  $query, array('integer'), array((int)$questionId)
325  );
326 
327  $row = $ilDB->fetchAssoc($res);
328 
329  return $row['next_index'];
330  }
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 191 of file class.ilAssQuestionHintList.php.

Referenced by ilAssQuestionHintsTableGUI\__construct().

192  {
193  $tableData = array();
194 
195  foreach($this as $questionHint)
196  {
197  /* @var $questionHint ilAssQuestionHint */
198 
199  $tableData[] = array(
200  'hint_id' => $questionHint->getId(),
201  'hint_index' => $questionHint->getIndex(),
202  'hint_points' => $questionHint->getPoints(),
203  'hint_text' => $questionHint->getText()
204  );
205  }
206 
207  return $tableData;
208  }
+ 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 113 of file class.ilAssQuestionHintList.php.

114  {
115  foreach($this as $questionHint)
116  {
117  /* @var $questionHint ilAssQuestionHint */
118 
119  if( $questionHint->getId() == $hintId )
120  {
121  return true;
122  }
123  }
124 
125  return false;
126  }

◆ key()

ilAssQuestionHintList::key ( )

iterator interface method

public

Returns
mixed

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

References key().

Referenced by key(), and valid().

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

◆ next()

ilAssQuestionHintList::next ( )

iterator interface method

public

Returns
mixed

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

References next().

Referenced by next().

46 { return next($this->questionHints); }
next()
iterator interface method
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

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

138  {
139  $counter = 0;
140 
141  foreach($this as $questionHint)
142  {
143  /* @var $questionHint ilAssQuestionHint */
144 
145  $questionHint->setIndex(++$counter);
146  $questionHint->save();
147  }
148  }

◆ rewind()

ilAssQuestionHintList::rewind ( )

iterator interface method

public

Returns
mixed

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

38 { return reset($this->questionHints); }

◆ valid()

ilAssQuestionHintList::valid ( )

iterator interface method

public

Returns
boolean

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

References key().

62 { return key($this->questionHints) !== null; }
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: