ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilTestRandomQuestionSetBuilder Class Reference
+ Inheritance diagram for ilTestRandomQuestionSetBuilder:
+ Collaboration diagram for ilTestRandomQuestionSetBuilder:

Public Member Functions

 checkBuildable ()
 
 performBuild (ilTestSession $testSession)
 
 getSrcPoolDefRelatedQuestCollection (ilTestRandomQuestionSetSourcePoolDefinition $definition)
 
 getSrcPoolDefListRelatedQuestUniqueCollection (ilTestRandomQuestionSetSourcePoolDefinitionList $sourcePoolDefinitionList)
 
 getCheckMessages ()
 
- Public Member Functions inherited from ilTestRandomSourcePoolDefinitionQuestionCollectionProvider
 getSrcPoolDefListRelatedQuestCombinationCollection (ilTestRandomQuestionSetSourcePoolDefinitionList $sourcePoolDefinitionList)
 

Static Public Member Functions

static getInstance (ilDBInterface $db, ilObjTest $testOBJ, ilTestRandomQuestionSetConfig $questionSetConfig, ilTestRandomQuestionSetSourcePoolDefinitionList $sourcePoolDefinitionList, ilTestRandomQuestionSetStagingPoolQuestionList $stagingPoolQuestionList)
 

Protected Member Functions

 __construct (ilDBInterface $db, ilObjTest $testOBJ, ilTestRandomQuestionSetConfig $questionSetConfig, ilTestRandomQuestionSetSourcePoolDefinitionList $sourcePoolDefinitionList, ilTestRandomQuestionSetStagingPoolQuestionList $stagingPoolQuestionList)
 
 storeQuestionSet (ilTestSession $testSession, $questionSet)
 
 fetchQuestionsFromStageRandomly (ilTestRandomQuestionSetQuestionCollection $questionStage, $requiredQuestionAmount)
 
 handleQuestionOrdering (ilTestRandomQuestionSetQuestionCollection $questionSet)
 

Protected Attributes

 $db = null
 
 $testOBJ = null
 
 $questionSetConfig = null
 
 $sourcePoolDefinitionList = null
 
 $stagingPoolQuestionList = null
 
 $checkMessages = array()
 

Private Member Functions

 getQuestionIdsForSourcePoolDefinitionIds (ilTestRandomQuestionSetSourcePoolDefinition $definition)
 
 buildSetQuestionCollection (ilTestRandomQuestionSetSourcePoolDefinition $definition, $questionIds)
 
 hasTaxonomyFilter (ilTestRandomQuestionSetSourcePoolDefinition $definition)
 
 hasTypeFilter (ilTestRandomQuestionSetSourcePoolDefinition $definition)
 
 storeQuestion (ilTestSession $testSession, ilTestRandomQuestionSetQuestion $setQuestion)
 

Detailed Description

Definition at line 12 of file class.ilTestRandomQuestionSetBuilder.php.

Constructor & Destructor Documentation

◆ __construct()

ilTestRandomQuestionSetBuilder::__construct ( ilDBInterface  $db,
ilObjTest  $testOBJ,
ilTestRandomQuestionSetConfig  $questionSetConfig,
ilTestRandomQuestionSetSourcePoolDefinitionList  $sourcePoolDefinitionList,
ilTestRandomQuestionSetStagingPoolQuestionList  $stagingPoolQuestionList 
)
protected

Member Function Documentation

◆ buildSetQuestionCollection()

ilTestRandomQuestionSetBuilder::buildSetQuestionCollection ( ilTestRandomQuestionSetSourcePoolDefinition  $definition,
  $questionIds 
)
private

Definition at line 143 of file class.ilTestRandomQuestionSetBuilder.php.

References ilTestRandomQuestionSetSourcePoolDefinition\getId().

Referenced by getSrcPoolDefRelatedQuestCollection().

144  {
145  $setQuestionCollection = new ilTestRandomQuestionSetQuestionCollection();
146 
147  foreach ($questionIds as $questionId) {
148  $setQuestion = new ilTestRandomQuestionSetQuestion();
149 
150  $setQuestion->setQuestionId($questionId);
151  $setQuestion->setSourcePoolDefinitionId($definition->getId());
152 
153  $setQuestionCollection->addQuestion($setQuestion);
154  }
155 
156  return $setQuestionCollection;
157  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ checkBuildable()

ilTestRandomQuestionSetBuilder::checkBuildable ( )
abstract

Referenced by __construct().

+ Here is the caller graph for this function:

◆ fetchQuestionsFromStageRandomly()

ilTestRandomQuestionSetBuilder::fetchQuestionsFromStageRandomly ( ilTestRandomQuestionSetQuestionCollection  $questionStage,
  $requiredQuestionAmount 
)
protected

Definition at line 217 of file class.ilTestRandomQuestionSetBuilder.php.

References ilTestRandomQuestionSetQuestionCollection\getRandomQuestionCollection().

Referenced by ilTestRandomQuestionSetBuilderWithAmountPerPool\checkBuildable(), and ilTestRandomQuestionSetBuilderWithAmountPerTest\performBuild().

218  {
219  $questionSet = $questionStage->getRandomQuestionCollection($requiredQuestionAmount);
220 
221  return $questionSet;
222  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getCheckMessages()

ilTestRandomQuestionSetBuilder::getCheckMessages ( )
Returns
array

Definition at line 267 of file class.ilTestRandomQuestionSetBuilder.php.

References $checkMessages.

◆ getInstance()

static ilTestRandomQuestionSetBuilder::getInstance ( ilDBInterface  $db,
ilObjTest  $testOBJ,
ilTestRandomQuestionSetConfig  $questionSetConfig,
ilTestRandomQuestionSetSourcePoolDefinitionList  $sourcePoolDefinitionList,
ilTestRandomQuestionSetStagingPoolQuestionList  $stagingPoolQuestionList 
)
staticfinal

Definition at line 233 of file class.ilTestRandomQuestionSetBuilder.php.

References ilTestRandomQuestionSetConfig\isQuestionAmountConfigurationModePerPool().

Referenced by ilTestOutputGUI\generateRandomTestPassForActiveUser(), and ilTestRandomQuestionSetConfig\isQuestionSetBuildable().

239  {
240  if ($questionSetConfig->isQuestionAmountConfigurationModePerPool()) {
241  require_once 'Modules/Test/classes/class.ilTestRandomQuestionSetBuilderWithAmountPerPool.php';
242 
244  $db,
245  $testOBJ,
246  $questionSetConfig,
247  $sourcePoolDefinitionList,
248  $stagingPoolQuestionList
249  );
250  }
251 
252  require_once 'Modules/Test/classes/class.ilTestRandomQuestionSetBuilderWithAmountPerTest.php';
253 
255  $db,
256  $testOBJ,
257  $questionSetConfig,
258  $sourcePoolDefinitionList,
259  $stagingPoolQuestionList
260  );
261  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getQuestionIdsForSourcePoolDefinitionIds()

ilTestRandomQuestionSetBuilder::getQuestionIdsForSourcePoolDefinitionIds ( ilTestRandomQuestionSetSourcePoolDefinition  $definition)
private

Definition at line 113 of file class.ilTestRandomQuestionSetBuilder.php.

References ilTestRandomQuestionSetSourcePoolDefinition\getMappedTaxonomyFilter(), ilTestRandomQuestionSetSourcePoolDefinition\getPoolId(), ilTestRandomQuestionSetSourcePoolDefinition\getTypeFilter(), hasTaxonomyFilter(), and hasTypeFilter().

Referenced by getSrcPoolDefRelatedQuestCollection().

114  {
115  $this->stagingPoolQuestionList->resetQuestionList();
116 
117  $this->stagingPoolQuestionList->setTestObjId($this->testOBJ->getId());
118  $this->stagingPoolQuestionList->setTestId($this->testOBJ->getTestId());
119  $this->stagingPoolQuestionList->setPoolId($definition->getPoolId());
120 
121  if ($this->hasTaxonomyFilter($definition)) {
122  // fau: taxFilter/typeFilter - use new taxonomy filter
123  foreach ($definition->getMappedTaxonomyFilter() as $taxId => $nodeIds) {
124  $this->stagingPoolQuestionList->addTaxonomyFilter($taxId, $nodeIds);
125  }
126  #$this->stagingPoolQuestionList->addTaxonomyFilter(
127  # $definition->getMappedFilterTaxId(), array($definition->getMappedFilterTaxNodeId())
128  #);
129  // fau.
130  }
131 
132  // fau: taxFilter/typeFilter - use type filter
133  if ($this->hasTypeFilter($definition)) {
134  $this->stagingPoolQuestionList->setTypeFilter($definition->getTypeFilter());
135  }
136  // fau.
137 
138  $this->stagingPoolQuestionList->loadQuestions();
139 
140  return $this->stagingPoolQuestionList->getQuestions();
141  }
hasTypeFilter(ilTestRandomQuestionSetSourcePoolDefinition $definition)
hasTaxonomyFilter(ilTestRandomQuestionSetSourcePoolDefinition $definition)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getSrcPoolDefListRelatedQuestUniqueCollection()

ilTestRandomQuestionSetBuilder::getSrcPoolDefListRelatedQuestUniqueCollection ( ilTestRandomQuestionSetSourcePoolDefinitionList  $sourcePoolDefinitionList)
Parameters
ilTestRandomQuestionSetSourcePoolDefinitionList$sourcePoolDefinitionList
Returns
ilTestRandomQuestionSetQuestionCollection

Implements ilTestRandomSourcePoolDefinitionQuestionCollectionProvider.

Definition at line 106 of file class.ilTestRandomQuestionSetBuilder.php.

References ilTestRandomSourcePoolDefinitionQuestionCollectionProvider\getSrcPoolDefListRelatedQuestCombinationCollection().

Referenced by ilTestRandomQuestionSetBuilderWithAmountPerTest\checkBuildable(), ilTestRandomQuestionSetBuilderWithAmountPerPool\checkBuildable(), and ilTestRandomQuestionSetBuilderWithAmountPerTest\performBuild().

107  {
108  $combinationCollection = $this->getSrcPoolDefListRelatedQuestCombinationCollection($sourcePoolDefinitionList);
109  return $combinationCollection->getUniqueQuestionCollection();
110  }
getSrcPoolDefListRelatedQuestCombinationCollection(ilTestRandomQuestionSetSourcePoolDefinitionList $sourcePoolDefinitionList)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getSrcPoolDefRelatedQuestCollection()

ilTestRandomQuestionSetBuilder::getSrcPoolDefRelatedQuestCollection ( ilTestRandomQuestionSetSourcePoolDefinition  $definition)
Parameters
ilTestRandomQuestionSetSourcePoolDefinition$definition
Returns
ilTestRandomQuestionSetQuestionCollection

Implements ilTestRandomSourcePoolDefinitionQuestionCollectionProvider.

Definition at line 92 of file class.ilTestRandomQuestionSetBuilder.php.

References buildSetQuestionCollection(), and getQuestionIdsForSourcePoolDefinitionIds().

Referenced by __construct(), and ilTestRandomQuestionSetBuilderWithAmountPerPool\checkBuildable().

94  {
95  $questionIds = $this->getQuestionIdsForSourcePoolDefinitionIds($definition);
96  $questionStage = $this->buildSetQuestionCollection($definition, $questionIds);
97 
98  return $questionStage;
99  }
buildSetQuestionCollection(ilTestRandomQuestionSetSourcePoolDefinition $definition, $questionIds)
getQuestionIdsForSourcePoolDefinitionIds(ilTestRandomQuestionSetSourcePoolDefinition $definition)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ handleQuestionOrdering()

ilTestRandomQuestionSetBuilder::handleQuestionOrdering ( ilTestRandomQuestionSetQuestionCollection  $questionSet)
protected

Definition at line 224 of file class.ilTestRandomQuestionSetBuilder.php.

References ilTestRandomQuestionSetQuestionCollection\shuffleQuestions().

Referenced by ilTestRandomQuestionSetBuilderWithAmountPerPool\checkBuildable(), and ilTestRandomQuestionSetBuilderWithAmountPerTest\performBuild().

225  {
226  if ($this->testOBJ->getShuffleQuestions()) {
227  $questionSet->shuffleQuestions();
228  }
229  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ hasTaxonomyFilter()

ilTestRandomQuestionSetBuilder::hasTaxonomyFilter ( ilTestRandomQuestionSetSourcePoolDefinition  $definition)
private

Definition at line 159 of file class.ilTestRandomQuestionSetBuilder.php.

References ilTestRandomQuestionSetSourcePoolDefinition\getMappedTaxonomyFilter().

Referenced by getQuestionIdsForSourcePoolDefinitionIds().

160  {
161  // fau: taxFilter - check for existing taxonomy filter
162  if (!count($definition->getMappedTaxonomyFilter())) {
163  return false;
164  }
165  #if( !(int)$definition->getMappedFilterTaxId() )
166  #{
167  # return false;
168  #}
169  #
170  #if( !(int)$definition->getMappedFilterTaxNodeId() )
171  #{
172  # return false;
173  #}
174  // fau.
175  return true;
176  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ hasTypeFilter()

ilTestRandomQuestionSetBuilder::hasTypeFilter ( ilTestRandomQuestionSetSourcePoolDefinition  $definition)
private

Definition at line 179 of file class.ilTestRandomQuestionSetBuilder.php.

References ilTestRandomQuestionSetSourcePoolDefinition\getTypeFilter().

Referenced by getQuestionIdsForSourcePoolDefinitionIds().

180  {
181  if (count($definition->getTypeFilter())) {
182  return true;
183  }
184 
185  return false;
186  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ performBuild()

ilTestRandomQuestionSetBuilder::performBuild ( ilTestSession  $testSession)
abstract

Referenced by __construct(), and ilTestRandomQuestionSetBuilderWithAmountPerPool\checkBuildable().

+ Here is the caller graph for this function:

◆ storeQuestion()

ilTestRandomQuestionSetBuilder::storeQuestion ( ilTestSession  $testSession,
ilTestRandomQuestionSetQuestion  $setQuestion 
)
private

Definition at line 202 of file class.ilTestRandomQuestionSetBuilder.php.

References ilTestSession\getActiveId(), ilTestSession\getPass(), ilTestRandomQuestionSetQuestion\getQuestionId(), ilTestRandomQuestionSetQuestion\getSequencePosition(), and ilTestRandomQuestionSetQuestion\getSourcePoolDefinitionId().

Referenced by storeQuestionSet().

203  {
204  $nextId = $this->db->nextId('tst_test_rnd_qst');
205 
206  $this->db->insert('tst_test_rnd_qst', array(
207  'test_random_question_id' => array('integer', $nextId),
208  'active_fi' => array('integer', $testSession->getActiveId()),
209  'question_fi' => array('integer', $setQuestion->getQuestionId()),
210  'sequence' => array('integer', $setQuestion->getSequencePosition()),
211  'pass' => array('integer', $testSession->getPass()),
212  'tstamp' => array('integer', time()),
213  'src_pool_def_fi' => array('integer', $setQuestion->getSourcePoolDefinitionId())
214  ));
215  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ storeQuestionSet()

ilTestRandomQuestionSetBuilder::storeQuestionSet ( ilTestSession  $testSession,
  $questionSet 
)
protected

Definition at line 189 of file class.ilTestRandomQuestionSetBuilder.php.

References storeQuestion().

Referenced by ilTestRandomQuestionSetBuilderWithAmountPerPool\checkBuildable(), and ilTestRandomQuestionSetBuilderWithAmountPerTest\performBuild().

190  {
191  $position = 0;
192 
193  foreach ($questionSet->getQuestions() as $setQuestion) {
194  /* @var ilTestRandomQuestionSetQuestion $setQuestion */
195 
196  $setQuestion->setSequencePosition($position++);
197 
198  $this->storeQuestion($testSession, $setQuestion);
199  }
200  }
storeQuestion(ilTestSession $testSession, ilTestRandomQuestionSetQuestion $setQuestion)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $checkMessages

ilTestRandomQuestionSetBuilder::$checkMessages = array()
protected

Definition at line 40 of file class.ilTestRandomQuestionSetBuilder.php.

Referenced by getCheckMessages().

◆ $db

ilTestRandomQuestionSetBuilder::$db = null
protected

Definition at line 17 of file class.ilTestRandomQuestionSetBuilder.php.

Referenced by __construct().

◆ $questionSetConfig

ilTestRandomQuestionSetBuilder::$questionSetConfig = null
protected

Definition at line 27 of file class.ilTestRandomQuestionSetBuilder.php.

Referenced by __construct().

◆ $sourcePoolDefinitionList

ilTestRandomQuestionSetBuilder::$sourcePoolDefinitionList = null
protected

Definition at line 32 of file class.ilTestRandomQuestionSetBuilder.php.

Referenced by __construct().

◆ $stagingPoolQuestionList

ilTestRandomQuestionSetBuilder::$stagingPoolQuestionList = null
protected

Definition at line 37 of file class.ilTestRandomQuestionSetBuilder.php.

Referenced by __construct().

◆ $testOBJ

ilTestRandomQuestionSetBuilder::$testOBJ = null
protected

Definition at line 22 of file class.ilTestRandomQuestionSetBuilder.php.

Referenced by __construct().


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