ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
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

ilTestRandomQuestionSetQuestionCollection::addQuestion ( ilTestRandomQuestionSetQuestion  $question)

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

{
$this->questions[] = $question;
}
ilTestRandomQuestionSetQuestionCollection::getInvolvedQuestionIds ( )

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

References getQuestions().

{
$questionIds = array();
foreach($this->getQuestions() as $question)
{
$questionIds[] = $question->getQuestionId();
}
return $questionIds;
}

+ Here is the call graph for this function:

ilTestRandomQuestionSetQuestionCollection::getMissingCount (   $amount)

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

{
return $amount - count($this->questions);
}
ilTestRandomQuestionSetQuestionCollection::getQuestions ( )

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

References $questions.

Referenced by getInvolvedQuestionIds(), getRelativeComplementCollection(), and getUniqueQuestionCollection().

{
}

+ Here is the caller graph for this function:

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

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

Referenced by getRandomQuestionCollection().

{
if( $numKeys < 1 )
{
return array();
}
if( $numKeys > 1 )
{
return array_rand($array, $numKeys);
}
return array( array_rand($array, $numKeys) );
}

+ Here is the caller graph for this function:

ilTestRandomQuestionSetQuestionCollection::getRandomQuestionCollection (   $requiredAmount)

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

References getRandomArrayKeys().

Referenced by ilTestRandomQuestionSetBuilder\fetchQuestionsFromStageRandomly().

{
$randomKeys = $this->getRandomArrayKeys($this->questions, $requiredAmount);
$randomQuestionCollection = new self();
foreach($randomKeys as $randomKey)
{
$randomQuestionCollection->addQuestion( $this->questions[$randomKey] );
}
return $randomQuestionCollection;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilTestRandomQuestionSetQuestionCollection::getRelativeComplementCollection ( self  $questionCollection)

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

References getQuestions().

{
$questionIds = array_flip( $questionCollection->getInvolvedQuestionIds() );
$relativeComplementCollection = new self();
foreach($this->getQuestions() as $question)
{
if( !isset($questionIds[$question->getQuestionId()]) )
{
$relativeComplementCollection->addQuestion($question);
}
}
return $relativeComplementCollection;
}

+ Here is the call graph for this function:

ilTestRandomQuestionSetQuestionCollection::getUniqueQuestionCollection ( )

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

References getQuestions().

{
$uniqueQuestions = array();
foreach($this->getQuestions() as $question)
{
/* @var ilTestRandomQuestionSetQuestion $question */
if( !isset($uniqueQuestions[$question->getQuestionId()]) )
{
$uniqueQuestions[$question->getQuestionId()] = $question;
}
}
$uniqueQuestionCollection = new self();
$uniqueQuestionCollection->setQuestions($uniqueQuestions);
return $uniqueQuestionCollection;
}

+ Here is the call graph for this function:

ilTestRandomQuestionSetQuestionCollection::isGreaterThan (   $amount)

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

{
return count($this->questions) > $amount;
}
ilTestRandomQuestionSetQuestionCollection::isSmallerThan (   $amount)

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

{
return count($this->questions) < $amount;
}
ilTestRandomQuestionSetQuestionCollection::mergeQuestionCollection ( self  $questionCollection)

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

{
$this->questions = array_merge( $this->questions, $questionCollection->getQuestions() );
}
ilTestRandomQuestionSetQuestionCollection::setQuestions (   $questions)

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

References $questions.

{
$this->questions = $questions;
}
ilTestRandomQuestionSetQuestionCollection::shuffleQuestions ( )

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

Referenced by ilTestRandomQuestionSetBuilder\handleQuestionOrdering().

{
shuffle($this->questions);
}

+ Here is the caller graph for this function:

Field Documentation

ilTestRandomQuestionSetQuestionCollection::$questions = array()
private

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