ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilTestRandomQuestionCollectionSubsetApplicationList.php
Go to the documentation of this file.
1 <?php
2 
26 {
30  protected $collectionSubsetApplications = array();
31 
36 
40  public function __construct()
41  {
43  }
44 
50  {
51  if (!isset($this->collectionSubsetApplications[$applicantId])) {
52  return null;
53  }
54 
55  return $this->collectionSubsetApplications[$applicantId];
56  }
57 
61  public function getCollectionSubsetApplications(): array
62  {
64  }
65 
67  {
68  $this->collectionSubsetApplications[$collectionSubsetApplication->getApplicantId()] = $collectionSubsetApplication;
69  }
70 
75  {
76  $this->collectionSubsetApplications = $collectionSubsetApplications;
77  }
78 
83  {
84  $this->setCollectionSubsetApplications(array());
85  }
86 
91  {
93  }
94 
99  {
100  $this->reservedQuestionCollection = $reservedQuestionCollection;
101  }
102 
106  public function addReservedQuestion(ilTestRandomQuestionSetQuestion $reservedQuestion)
107  {
108  $this->getReservedQuestionCollection()->addQuestion($reservedQuestion);
109  }
110 
114  public function current()
115  {
116  return current($this->collectionSubsetApplications);
117  }
118 
122  public function next()
123  {
124  return next($this->collectionSubsetApplications);
125  }
126  /* @return string */
127  public function key(): string
128  {
129  return key($this->collectionSubsetApplications);
130  }
131  /* @return bool */
132  public function valid(): bool
133  {
134  return key($this->collectionSubsetApplications) !== null;
135  }
139  public function rewind()
140  {
141  return reset($this->collectionSubsetApplications);
142  }
143 
148  {
149  $questionReservationRequired = false;
150 
151  foreach ($this as $collectionSubsetApplication) {
152  if (!$collectionSubsetApplication->hasQuestion($question->getQuestionId())) {
153  continue;
154  }
155 
156  if ($collectionSubsetApplication->hasRequiredAmountLeft()) {
157  $questionReservationRequired = true;
158  $collectionSubsetApplication->decrementRequiredAmount();
159  }
160  }
161 
162  if ($questionReservationRequired) {
163  $this->addReservedQuestion($question);
164  }
165  }
166 
171  {
172  $availableQuestionCollection = new ilTestRandomQuestionSetQuestionCollection();
173 
174  foreach ($this as $collectionSubsetApplication) {
175  $applicationsNonReservedQstCollection = $collectionSubsetApplication->getRelativeComplementCollection(
177  );
178 
179  $availableQuestionCollection->mergeQuestionCollection($applicationsNonReservedQstCollection);
180  }
181 
182  $nonReservedQuestionCollection = $availableQuestionCollection->getUniqueQuestionCollection();
183 
184  return $nonReservedQuestionCollection->getQuestionAmount();
185  }
186 }
__construct()
ilTestRandomQuestionCollectionSubsetApplicantList constructor.
addCollectionSubsetApplication(ilTestRandomQuestionCollectionSubsetApplication $collectionSubsetApplication)