35 return current($this->questionHints);
40 reset($this->questionHints);
43 public function next(): void
45 next($this->questionHints);
50 return key($this->questionHints);
55 return key($this->questionHints) !==
null;
64 $this->questionHints[] = $questionHint;
72 foreach ($this as $questionHint) {
75 if ($questionHint->getId() == $hintId) {
88 foreach ($this as $questionHint) {
90 if ($questionHint->getId() == $hintId) {
108 foreach ($this as $questionHint) {
111 $questionHint->setIndex(++$counter);
112 $questionHint->save();
128 $questionHintList = self::getListByQuestionId($originalQuestionId);
130 foreach ($questionHintList as $questionHint) {
133 $originalHintId = $questionHint->getId();
135 $questionHint->setId(0);
136 $questionHint->setQuestionId($duplicateQuestionId);
138 $questionHint->save();
140 $duplicateHintId = $questionHint->getId();
142 $hintIds[$originalHintId] = $duplicateHintId;
157 foreach ($this as $questionHint) {
161 'hint_id' => $questionHint->getId(),
162 'hint_index' => $questionHint->getIndex(),
163 'hint_points' => $questionHint->getPoints(),
164 'hint_text' => $questionHint->getText()
178 $ilDB = $DIC->database();
189 WHERE qht_question_fi = %s 191 ORDER BY qht_hint_index ASC 200 $questionHintList =
new self();
207 $questionHintList->addHint($questionHint);
210 return $questionHintList;
220 $ilDB = $DIC->database();
222 $qht_hint_id__IN__hintIds =
$ilDB->in(
'qht_hint_id', (array) $hintIds,
false,
'integer');
233 WHERE $qht_hint_id__IN__hintIds 235 ORDER BY qht_hint_index ASC 240 $questionHintList =
new self();
247 $questionHintList->addHint($questionHint);
250 return $questionHintList;
262 $ilDB = $DIC->database();
265 SELECT 1 + COALESCE( MAX(qht_hint_index), 0 ) next_index 269 WHERE qht_question_fi = %s 279 return is_array($row) ? (
int) $row[
'next_index'] : 1;
289 $ilDB = $DIC->database();
291 $__qht_question_fi__IN__questionIds =
$ilDB->in(
'qht_question_fi', $questionIds,
false,
'integer');
294 DELETE FROM qpl_hints 295 WHERE $__qht_question_fi__IN__questionIds 298 return $ilDB->manipulate($query);
static getListByQuestionId($questionId)
instantiates a question hint list for the passed question id
static deleteHintsByQuestionIds(array $questionIds)
Deletes all question hints relating to questions included in given question ids.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static getListByHintIds($hintIds)
instantiates a question hint list for the passed hint ids
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...
static duplicateListForQuestion($originalQuestionId, $duplicateQuestionId)
duplicates a hint list from given original question id to given duplicate question id and returns an ...
reIndex()
re-indexes the list's hints sequentially by current order (starting with index "1") ATTENTION: it als...
static assignDbRow(self $questionHint, $hintDbRow)
assigns the field elements of passed hint db row array to the corresponding hint object properties of...
addHint(ilAssQuestionHint $questionHint)
getTableData()
returns an array with data of the hints in this list that is adopted to be used as table gui data ...