ILIAS  trunk Revision v11.0_alpha-1689-g66c127b4ae8
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
class.ilTestSequenceFixedQuestionSet.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
28 {
32  public function removeQuestion(int $question_id, ilTestReindexedSequencePositionMap $reindexedSequencePositionMap): void
33  {
34  foreach ($this->sequencedata['sequence'] as $key => $oldSequenceElement) {
35  $newSequenceElement = $reindexedSequencePositionMap->getNewSequencePosition($oldSequenceElement);
36 
37  if ($newSequenceElement) {
38  $this->sequencedata['sequence'][$key] = $newSequenceElement;
39  } else {
40  unset($this->sequencedata['sequence'][$key]);
41  }
42  }
43 
44  $this->sequencedata['sequence'] = array_values($this->sequencedata['sequence']);
45 
46  $this->sequencedata['postponed'] = $this->removeArrayValue($this->sequencedata['postponed'], $question_id);
47  $this->sequencedata['hidden'] = $this->removeArrayValue($this->sequencedata['hidden'], $question_id);
48 
49  $this->optionalQuestions = $this->removeArrayValue($this->optionalQuestions, $question_id);
50 
51  $this->alreadyPresentedQuestions = $this->removeArrayValue($this->alreadyPresentedQuestions, $question_id);
52 
53  $this->alreadyCheckedQuestions = $this->removeArrayValue($this->alreadyCheckedQuestions, $question_id);
54  }
55 
56  private function removeArrayValue(array $array, int $value): array
57  {
58  foreach ($array as $key => $val) {
59  if ($val == $value) {
60  unset($array[$key]);
61  }
62  }
63 
64  return $array;
65  }
66 }
removeQuestion(int $question_id, ilTestReindexedSequencePositionMap $reindexedSequencePositionMap)
Test sequence handler.