ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilTestRandomQuestionSetQuestionCollection Class Reference
+ Collaboration diagram for ilTestRandomQuestionSetQuestionCollection:

Public Member Functions

 setQuestions ($questions)
 
 getQuestions ()
 
 addQuestion (ilTestRandomQuestionSetQuestion $question)
 
 isGreaterThan ($amount)
 
 isSmallerThan ($amount)
 
 getMissingCount ($amount)
 
 shuffleQuestions ()
 
 mergeQuestionCollection (self $questionCollection)
 
 getUniqueQuestionCollection ()
 
 getRelativeComplementCollection (self $questionCollection)
 
 getInvolvedQuestionIds ()
 
 getRandomQuestionCollection ($requiredAmount)
 

Private Member Functions

 getRandomArrayKeys ($array, $numKeys)
 

Private Attributes

 $questions = array()
 

Detailed Description

Member Function Documentation

◆ addQuestion()

ilTestRandomQuestionSetQuestionCollection::addQuestion ( ilTestRandomQuestionSetQuestion  $question)

Definition at line 26 of file class.ilTestRandomQuestionSetQuestionCollection.php.

27  {
28  $this->questions[] = $question;
29  }

◆ getInvolvedQuestionIds()

ilTestRandomQuestionSetQuestionCollection::getInvolvedQuestionIds ( )

Definition at line 93 of file class.ilTestRandomQuestionSetQuestionCollection.php.

References array, and getQuestions().

94  {
95  $questionIds = array();
96 
97  foreach($this->getQuestions() as $question)
98  {
99  $questionIds[] = $question->getQuestionId();
100  }
101 
102  return $questionIds;
103  }
Create styles array
The data for the language used.
+ Here is the call graph for this function:

◆ getMissingCount()

ilTestRandomQuestionSetQuestionCollection::getMissingCount (   $amount)

Definition at line 41 of file class.ilTestRandomQuestionSetQuestionCollection.php.

42  {
43  return $amount - count($this->questions);
44  }

◆ getQuestions()

ilTestRandomQuestionSetQuestionCollection::getQuestions ( )

◆ getRandomArrayKeys()

ilTestRandomQuestionSetQuestionCollection::getRandomArrayKeys (   $array,
  $numKeys 
)
private

Definition at line 119 of file class.ilTestRandomQuestionSetQuestionCollection.php.

References array.

Referenced by getRandomQuestionCollection().

120  {
121  if( $numKeys < 1 )
122  {
123  return array();
124  }
125 
126  if( $numKeys > 1 )
127  {
128  return array_rand($array, $numKeys);
129  }
130 
131  return array( array_rand($array, $numKeys) );
132  }
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ getRandomQuestionCollection()

ilTestRandomQuestionSetQuestionCollection::getRandomQuestionCollection (   $requiredAmount)

Definition at line 105 of file class.ilTestRandomQuestionSetQuestionCollection.php.

References getRandomArrayKeys().

Referenced by ilTestRandomQuestionSetBuilder\fetchQuestionsFromStageRandomly().

106  {
107  $randomKeys = $this->getRandomArrayKeys($this->questions, $requiredAmount);
108 
109  $randomQuestionCollection = new self();
110 
111  foreach($randomKeys as $randomKey)
112  {
113  $randomQuestionCollection->addQuestion( $this->questions[$randomKey] );
114  }
115 
116  return $randomQuestionCollection;
117  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getRelativeComplementCollection()

ilTestRandomQuestionSetQuestionCollection::getRelativeComplementCollection ( self  $questionCollection)

Definition at line 76 of file class.ilTestRandomQuestionSetQuestionCollection.php.

References getQuestions().

77  {
78  $questionIds = array_flip( $questionCollection->getInvolvedQuestionIds() );
79 
80  $relativeComplementCollection = new self();
81 
82  foreach($this->getQuestions() as $question)
83  {
84  if( !isset($questionIds[$question->getQuestionId()]) )
85  {
86  $relativeComplementCollection->addQuestion($question);
87  }
88  }
89 
90  return $relativeComplementCollection;
91  }
+ Here is the call graph for this function:

◆ getUniqueQuestionCollection()

ilTestRandomQuestionSetQuestionCollection::getUniqueQuestionCollection ( )

Definition at line 56 of file class.ilTestRandomQuestionSetQuestionCollection.php.

References array, and getQuestions().

57  {
58  $uniqueQuestions = array();
59 
60  foreach($this->getQuestions() as $question)
61  {
62  /* @var ilTestRandomQuestionSetQuestion $question */
63 
64  if( !isset($uniqueQuestions[$question->getQuestionId()]) )
65  {
66  $uniqueQuestions[$question->getQuestionId()] = $question;
67  }
68  }
69 
70  $uniqueQuestionCollection = new self();
71  $uniqueQuestionCollection->setQuestions($uniqueQuestions);
72 
73  return $uniqueQuestionCollection;
74  }
Create styles array
The data for the language used.
+ Here is the call graph for this function:

◆ isGreaterThan()

ilTestRandomQuestionSetQuestionCollection::isGreaterThan (   $amount)

Definition at line 31 of file class.ilTestRandomQuestionSetQuestionCollection.php.

32  {
33  return count($this->questions) > $amount;
34  }

◆ isSmallerThan()

ilTestRandomQuestionSetQuestionCollection::isSmallerThan (   $amount)

Definition at line 36 of file class.ilTestRandomQuestionSetQuestionCollection.php.

37  {
38  return count($this->questions) < $amount;
39  }

◆ mergeQuestionCollection()

ilTestRandomQuestionSetQuestionCollection::mergeQuestionCollection ( self  $questionCollection)

Definition at line 51 of file class.ilTestRandomQuestionSetQuestionCollection.php.

52  {
53  $this->questions = array_merge( $this->questions, $questionCollection->getQuestions() );
54  }

◆ setQuestions()

ilTestRandomQuestionSetQuestionCollection::setQuestions (   $questions)

◆ shuffleQuestions()

ilTestRandomQuestionSetQuestionCollection::shuffleQuestions ( )

Definition at line 46 of file class.ilTestRandomQuestionSetQuestionCollection.php.

Referenced by ilTestRandomQuestionSetBuilder\handleQuestionOrdering().

47  {
48  shuffle($this->questions);
49  }
+ Here is the caller graph for this function:

Field Documentation

◆ $questions

ilTestRandomQuestionSetQuestionCollection::$questions = array()
private

The documentation for this class was generated from the following file: