44 $this->questions[] = $question;
52 return current($this->questions);
60 return next($this->questions);
63 public function key(): string
65 return key($this->questions);
70 return key($this->questions) !== null;
78 return reset($this->questions);
84 return count($this->questions) > $amount;
89 return count($this->questions) < $amount;
98 $difference = $requiredAmount - count($this->questions);
99 $missingCount = $difference < 0 ? 0 : $difference;
100 return $missingCount;
106 shuffle($this->questions);
111 $this->questions = array_merge($this->questions, $questionCollection->getQuestions());
116 $uniqueQuestions = array();
121 if (!isset($uniqueQuestions[$question->getQuestionId()])) {
122 $uniqueQuestions[$question->getQuestionId()] = $question;
126 $uniqueQuestionCollection =
new self();
127 $uniqueQuestionCollection->setQuestions($uniqueQuestions);
129 return $uniqueQuestionCollection;
146 $questionIds = array_flip($questionCollection->getInvolvedQuestionIds());
148 $relativeComplementCollection =
new self();
151 if (!isset($questionIds[$question->getQuestionId()])) {
152 $relativeComplementCollection->
addQuestion($question);
156 return $relativeComplementCollection;
161 $questionIds = array_flip($questionCollection->getInvolvedQuestionIds());
163 $intersectionCollection =
new self();
166 if (!isset($questionIds[$question->getQuestionId()])) {
173 return $intersectionCollection;
184 $questionIds = array();
187 $questionIds[] = $question->getQuestionId();
197 $randomQuestionCollection =
new self();
199 foreach ($randomKeys as $randomKey) {
200 $randomQuestionCollection->addQuestion($this->questions[$randomKey]);
203 return $randomQuestionCollection;
213 return array_rand($array, $numKeys);
216 return array( array_rand($array, $numKeys) );
getIntersectionCollection(self $questionCollection)
mergeQuestionCollection(self $questionCollection)
getRandomArrayKeys($array, $numKeys)
getMissingCount($requiredAmount)
getRelativeComplementCollection(self $questionCollection)
getRandomQuestionCollection($requiredAmount)
addQuestion(ilTestRandomQuestionSetQuestion $question)
getUniqueQuestionCollection()