ILIAS  trunk Revision v11.0_alpha-1689-g66c127b4ae8
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
class.ilTestRandomQuestionCollectionSubsetApplicationList.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
29 {
31  protected array $collectionSubsetApplications = [];
33 
34  public function __construct()
35  {
37  }
38 
43  {
44  return $this->collectionSubsetApplications[$applicantId] ?? null;
45  }
46 
50  public function getCollectionSubsetApplications(): array
51  {
53  }
54 
56  ilTestRandomQuestionCollectionSubsetApplication $collectionSubsetApplication
57  ): void {
58  $this->collectionSubsetApplications[$collectionSubsetApplication->getApplicantId()] = $collectionSubsetApplication;
59  }
60 
64  public function setCollectionSubsetApplications(array $collectionSubsetApplications): void
65  {
66  $this->collectionSubsetApplications = $collectionSubsetApplications;
67  }
68 
69  public function resetCollectionSubsetApplicants(): void
70  {
72  }
73 
75  {
77  }
78 
80  ilTestRandomQuestionSetQuestionCollection $reservedQuestionCollection
81  ): void {
82  $this->reservedQuestionCollection = $reservedQuestionCollection;
83  }
84 
85  public function addReservedQuestion(ilTestRandomQuestionSetQuestion $reservedQuestion): void
86  {
87  $this->getReservedQuestionCollection()->addQuestion($reservedQuestion);
88  }
89 
91  {
92  return current($this->collectionSubsetApplications);
93  }
94 
95  public function next(): void
96  {
97  next($this->collectionSubsetApplications);
98  }
99 
100  public function key(): int
101  {
102  return key($this->collectionSubsetApplications);
103  }
104 
105  public function valid(): bool
106  {
107  return key($this->collectionSubsetApplications) !== null;
108  }
109 
110  public function rewind(): void
111  {
112  reset($this->collectionSubsetApplications);
113  }
114 
116  {
117  $questionReservationRequired = false;
118 
119  foreach ($this as $collectionSubsetApplication) {
120  if (!$collectionSubsetApplication->hasQuestion($question->getQuestionId())) {
121  continue;
122  }
123 
124  if ($collectionSubsetApplication->hasRequiredAmountLeft()) {
125  $questionReservationRequired = true;
126  $collectionSubsetApplication->decrementRequiredAmount();
127  }
128  }
129 
130  if ($questionReservationRequired) {
131  $this->addReservedQuestion($question);
132  }
133  }
134 
136  {
137  $availableQuestionCollection = new ilTestRandomQuestionSetQuestionCollection();
138 
139  foreach ($this as $collectionSubsetApplication) {
140  $applicationsNonReservedQstCollection = $collectionSubsetApplication->getRelativeComplementCollection(
142  );
143 
144  $availableQuestionCollection->mergeQuestionCollection($applicationsNonReservedQstCollection);
145  }
146 
147  $nonReservedQuestionCollection = $availableQuestionCollection->getUniqueQuestionCollection();
148 
149  return $nonReservedQuestionCollection->getQuestionAmount();
150  }
151 }
setReservedQuestionCollection(ilTestRandomQuestionSetQuestionCollection $reservedQuestionCollection)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
addCollectionSubsetApplication(ilTestRandomQuestionCollectionSubsetApplication $collectionSubsetApplication)