ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilTestRandomQuestionCollectionSubsetApplicationList.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 require_once 'Modules/Test/classes/class.ilTestRandomQuestionCollectionSubsetApplication.php';
5 
13 {
18 
23 
27  public function __construct()
28  {
30  }
31 
36  public function getCollectionSubsetApplication($applicantId)
37  {
38  if (!isset($this->collectionSubsetApplications[$applicantId])) {
39  return null;
40  }
41 
42  return $this->collectionSubsetApplications[$applicantId];
43  }
44 
49  {
51  }
52 
57  {
58  $this->collectionSubsetApplications[$collectionSubsetApplication->getApplicantId()] = $collectionSubsetApplication;
59  }
60 
65  {
66  $this->collectionSubsetApplications = $collectionSubsetApplications;
67  }
68 
73  {
75  }
76 
81  {
83  }
84 
89  {
90  $this->reservedQuestionCollection = $reservedQuestionCollection;
91  }
92 
96  public function addReservedQuestion(ilTestRandomQuestionSetQuestion $reservedQuestion)
97  {
98  $this->getReservedQuestionCollection()->addQuestion($reservedQuestion);
99  }
100 
101  /* @return ilTestRandomQuestionCollectionSubsetApplication */
102  public function current()
103  {
104  return current($this->collectionSubsetApplications);
105  }
106  /* @return ilTestRandomQuestionCollectionSubsetApplication */
107  public function next()
108  {
109  return next($this->collectionSubsetApplications);
110  }
111  /* @return string */
112  public function key()
113  {
114  return key($this->collectionSubsetApplications);
115  }
116  /* @return bool */
117  public function valid()
118  {
119  return key($this->collectionSubsetApplications) !== null;
120  }
121  /* @return ilTestRandomQuestionCollectionSubsetApplication */
122  public function rewind()
123  {
124  return reset($this->collectionSubsetApplications);
125  }
126 
131  {
132  $questionReservationRequired = false;
133 
134  foreach ($this as $collectionSubsetApplication) {
135  if (!$collectionSubsetApplication->hasQuestion($question->getQuestionId())) {
136  continue;
137  }
138 
139  if ($collectionSubsetApplication->hasRequiredAmountLeft()) {
140  $questionReservationRequired = true;
141  $collectionSubsetApplication->decrementRequiredAmount();
142  }
143  }
144 
145  if ($questionReservationRequired) {
146  $this->addReservedQuestion($question);
147  }
148  }
149 
154  {
155  $availableQuestionCollection = new ilTestRandomQuestionSetQuestionCollection();
156 
157  foreach ($this as $collectionSubsetApplication) {
158  $applicationsNonReservedQstCollection = $collectionSubsetApplication->getRelativeComplementCollection(
160  );
161 
162  $availableQuestionCollection->mergeQuestionCollection($applicationsNonReservedQstCollection);
163  }
164 
165  $nonReservedQuestionCollection = $availableQuestionCollection->getUniqueQuestionCollection();
166 
167  return $nonReservedQuestionCollection->getQuestionAmount();
168  }
169 }
__construct()
ilTestRandomQuestionCollectionSubsetApplicantList constructor.
addCollectionSubsetApplication(ilTestRandomQuestionCollectionSubsetApplication $collectionSubsetApplication)
Create styles array
The data for the language used.