ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilTestRandomQuestionSetBuilder Class Reference
+ Inheritance diagram for ilTestRandomQuestionSetBuilder:
+ Collaboration diagram for ilTestRandomQuestionSetBuilder:

Public Member Functions

 checkBuildable ()
 
 performBuild (ilTestSession $testSession)
 
 getSrcPoolDefListRelatedQuestCombinationCollection (ilTestRandomQuestionSetSourcePoolDefinitionList $sourcePoolDefinitionList)
 
 getSrcPoolDefRelatedQuestCollection (ilTestRandomQuestionSetSourcePoolDefinition $definition)
 
 getSrcPoolDefListRelatedQuestUniqueCollection (ilTestRandomQuestionSetSourcePoolDefinitionList $sourcePoolDefinitionList)
 
 getCheckMessages ()
 

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 25 of file class.ilTestRandomQuestionSetBuilder.php.

Constructor & Destructor Documentation

◆ __construct()

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

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

References $db, $questionSetConfig, $sourcePoolDefinitionList, $stagingPoolQuestionList, $testOBJ, checkBuildable(), and performBuild().

69  {
70  $this->db = $db;
71  $this->testOBJ = $testOBJ;
72  $this->questionSetConfig = $questionSetConfig;
73  $this->sourcePoolDefinitionList = $sourcePoolDefinitionList;
74  $this->stagingPoolQuestionList = $stagingPoolQuestionList;
75  $this->stagingPoolQuestionList->setTestObjId($this->testOBJ->getId());
76  $this->stagingPoolQuestionList->setTestId($this->testOBJ->getTestId());
77  }
+ Here is the call graph for this function:

Member Function Documentation

◆ buildSetQuestionCollection()

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

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

References ilTestRandomQuestionSetSourcePoolDefinition\getId().

Referenced by getSrcPoolDefRelatedQuestCollection().

147  {
148  $setQuestionCollection = new ilTestRandomQuestionSetQuestionCollection();
149 
150  foreach ($questionIds as $questionId) {
151  $setQuestion = new ilTestRandomQuestionSetQuestion();
152 
153  $setQuestion->setQuestionId($questionId);
154  $setQuestion->setSourcePoolDefinitionId($definition->getId());
155 
156  $setQuestionCollection->addQuestion($setQuestion);
157  }
158 
159  return $setQuestionCollection;
160  }
+ 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

◆ getCheckMessages()

ilTestRandomQuestionSetBuilder::getCheckMessages ( )
Returns
array

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

References $checkMessages.

259  : array
260  {
261  return $this->checkMessages;
262  }

◆ getInstance()

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

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

References ilTestRandomQuestionSetConfig\isQuestionAmountConfigurationModePerPool().

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

231  {
232  if ($questionSetConfig->isQuestionAmountConfigurationModePerPool()) {
233  require_once 'Modules/Test/classes/class.ilTestRandomQuestionSetBuilderWithAmountPerPool.php';
234 
236  $db,
237  $testOBJ,
238  $questionSetConfig,
239  $sourcePoolDefinitionList,
240  $stagingPoolQuestionList
241  );
242  }
243 
244  require_once 'Modules/Test/classes/class.ilTestRandomQuestionSetBuilderWithAmountPerTest.php';
245 
247  $db,
248  $testOBJ,
249  $questionSetConfig,
250  $sourcePoolDefinitionList,
251  $stagingPoolQuestionList
252  );
253  }
+ 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 119 of file class.ilTestRandomQuestionSetBuilder.php.

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

Referenced by getSrcPoolDefRelatedQuestCollection().

119  : array
120  {
121  $this->stagingPoolQuestionList->resetQuestionList();
122 
123  $this->stagingPoolQuestionList->setPoolId($definition->getPoolId());
124 
125  if ($this->hasTaxonomyFilter($definition)) {
126  foreach ($definition->getMappedTaxonomyFilter() as $taxId => $nodeIds) {
127  $this->stagingPoolQuestionList->addTaxonomyFilter($taxId, $nodeIds);
128  }
129  }
130 
131  if (count($definition->getLifecycleFilter())) {
132  $this->stagingPoolQuestionList->setLifecycleFilter($definition->getLifecycleFilter());
133  }
134 
135  // fau: taxFilter/typeFilter - use type filter
136  if ($this->hasTypeFilter($definition)) {
137  $this->stagingPoolQuestionList->setTypeFilter($definition->getTypeFilter());
138  }
139  // fau.
140 
141  $this->stagingPoolQuestionList->loadQuestions();
142 
143  return $this->stagingPoolQuestionList->getQuestions();
144  }
hasTypeFilter(ilTestRandomQuestionSetSourcePoolDefinition $definition)
hasTaxonomyFilter(ilTestRandomQuestionSetSourcePoolDefinition $definition)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getSrcPoolDefListRelatedQuestCombinationCollection()

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

Implements ilTestRandomSourcePoolDefinitionQuestionCollectionProvider.

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

References getSrcPoolDefRelatedQuestCollection().

Referenced by getSrcPoolDefListRelatedQuestUniqueCollection().

84  {
85  $questionStage = new ilTestRandomQuestionSetQuestionCollection();
86 
87  foreach ($sourcePoolDefinitionList as $definition) {
88  $questions = $this->getSrcPoolDefRelatedQuestCollection($definition);
89  $questionStage->mergeQuestionCollection($questions);
90  }
91 
92  return $questionStage;
93  }
getSrcPoolDefRelatedQuestCollection(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 112 of file class.ilTestRandomQuestionSetBuilder.php.

References getSrcPoolDefListRelatedQuestCombinationCollection().

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

113  {
114  $combinationCollection = $this->getSrcPoolDefListRelatedQuestCombinationCollection($sourcePoolDefinitionList);
115  return $combinationCollection->getUniqueQuestionCollection();
116  }
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 99 of file class.ilTestRandomQuestionSetBuilder.php.

References buildSetQuestionCollection(), and getQuestionIdsForSourcePoolDefinitionIds().

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

100  {
101  $questionIds = $this->getQuestionIdsForSourcePoolDefinitionIds($definition);
102  $questionStage = $this->buildSetQuestionCollection($definition, $questionIds);
103 
104  return $questionStage;
105  }
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 216 of file class.ilTestRandomQuestionSetBuilder.php.

References ilTestRandomQuestionSetQuestionCollection\shuffleQuestions().

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

217  {
218  if ($this->testOBJ->getShuffleQuestions()) {
219  $questionSet->shuffleQuestions();
220  }
221  }
+ 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 162 of file class.ilTestRandomQuestionSetBuilder.php.

References ilTestRandomQuestionSetSourcePoolDefinition\getMappedTaxonomyFilter().

Referenced by getQuestionIdsForSourcePoolDefinitionIds().

162  : bool
163  {
164  if (!count($definition->getMappedTaxonomyFilter())) {
165  return false;
166  }
167  return true;
168  }
+ 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 171 of file class.ilTestRandomQuestionSetBuilder.php.

References ilTestRandomQuestionSetSourcePoolDefinition\getTypeFilter().

Referenced by getQuestionIdsForSourcePoolDefinitionIds().

171  : bool
172  {
173  if (count($definition->getTypeFilter())) {
174  return true;
175  }
176 
177  return false;
178  }
+ 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 194 of file class.ilTestRandomQuestionSetBuilder.php.

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

Referenced by storeQuestionSet().

195  {
196  $nextId = $this->db->nextId('tst_test_rnd_qst');
197 
198  $this->db->insert('tst_test_rnd_qst', array(
199  'test_random_question_id' => array('integer', $nextId),
200  'active_fi' => array('integer', $testSession->getActiveId()),
201  'question_fi' => array('integer', $setQuestion->getQuestionId()),
202  'sequence' => array('integer', $setQuestion->getSequencePosition()),
203  'pass' => array('integer', $testSession->getPass()),
204  'tstamp' => array('integer', time()),
205  'src_pool_def_fi' => array('integer', $setQuestion->getSourcePoolDefinitionId())
206  ));
207  }
+ 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 181 of file class.ilTestRandomQuestionSetBuilder.php.

References storeQuestion().

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

182  {
183  $position = 0;
184 
185  foreach ($questionSet->getQuestions() as $setQuestion) {
186  /* @var ilTestRandomQuestionSetQuestion $setQuestion */
187 
188  $setQuestion->setSequencePosition($position++);
189 
190  $this->storeQuestion($testSession, $setQuestion);
191  }
192  }
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 53 of file class.ilTestRandomQuestionSetBuilder.php.

Referenced by getCheckMessages().

◆ $db

ilTestRandomQuestionSetBuilder::$db = null
protected

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

Referenced by __construct().

◆ $questionSetConfig

ilTestRandomQuestionSetBuilder::$questionSetConfig = null
protected

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

Referenced by __construct().

◆ $sourcePoolDefinitionList

ilTestRandomQuestionSetBuilder::$sourcePoolDefinitionList = null
protected

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

Referenced by __construct().

◆ $stagingPoolQuestionList

ilTestRandomQuestionSetBuilder::$stagingPoolQuestionList = null
protected

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

Referenced by __construct().

◆ $testOBJ

ilTestRandomQuestionSetBuilder::$testOBJ = null
protected

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

Referenced by __construct().


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