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

Public Member Functions

 __construct (ilDBInterface $ilDB, ilPluginAdmin $pluginAdmin, ilObjTest $testOBJ)
 
 getTargetContainerRef ()
 
 setTargetContainerRef ($targetContainerRef)
 
 getOwnerId ()
 
 setOwnerId ($ownerId)
 
 getSourcePoolDefinitionList ()
 
 setSourcePoolDefinitionList ($sourcePoolDefinitionList)
 
 derive (ilTestRandomQuestionSetNonAvailablePool $nonAvailablePool)
 

Protected Member Functions

 getQuestionsForPool (ilTestRandomQuestionSetNonAvailablePool $nonAvailablePool)
 
 createNewPool (ilTestRandomQuestionSetNonAvailablePool $nonAvailablePool)
 
 copyQuestionsToPool (ilObjQuestionPool $pool, $questions)
 
 updateTestQuestionStage ($poolQidByTestQidMap)
 
 filterForQuestionRelatedTaxonomies ($taxonomyIds, $relatedQuestionIds)
 
 duplicateTaxonomies ($poolQidByTestQidMap, ilObjQuestionPool $pool)
 
 buildOriginalTaxonomyFilterForDerivedPool (ilQuestionPoolDuplicatedTaxonomiesKeysMap $taxKeysMap, $mappedTaxonomyFilter)
 
 updateRelatedSourcePoolDefinitions (ilQuestionPoolDuplicatedTaxonomiesKeysMap $taxKeysMap, $derivedPoolId, $nonAvailablePoolId)
 

Protected Attributes

 $db
 
 $pluginAdmin
 
 $testOBJ
 
 $targetContainerRef
 
 $ownerId
 
 $poolFactory
 
 $sourcePoolDefinitionList
 

Detailed Description

Definition at line 14 of file class.ilTestRandomQuestionSetPoolDeriver.php.

Constructor & Destructor Documentation

◆ __construct()

ilTestRandomQuestionSetPoolDeriver::__construct ( ilDBInterface  $ilDB,
ilPluginAdmin  $pluginAdmin,
ilObjTest  $testOBJ 
)

Member Function Documentation

◆ buildOriginalTaxonomyFilterForDerivedPool()

ilTestRandomQuestionSetPoolDeriver::buildOriginalTaxonomyFilterForDerivedPool ( ilQuestionPoolDuplicatedTaxonomiesKeysMap  $taxKeysMap,
  $mappedTaxonomyFilter 
)
protected

Definition at line 213 of file class.ilTestRandomQuestionSetPoolDeriver.php.

References array, ilQuestionPoolDuplicatedTaxonomiesKeysMap\getMappedTaxNodeId(), and ilQuestionPoolDuplicatedTaxonomiesKeysMap\getMappedTaxonomyId().

Referenced by updateRelatedSourcePoolDefinitions().

214  {
215  $originalTaxonomyFilter = array();
216 
217  foreach($mappedTaxonomyFilter as $testTaxonomyId => $testTaxNodes)
218  {
219  $poolTaxonomyId = $taxKeysMap->getMappedTaxonomyId($testTaxonomyId);
220  $originalTaxonomyFilter[$poolTaxonomyId] = array();
221 
222  foreach($testTaxNodes as $testTaxNode)
223  {
224  $poolTaxNode = $taxKeysMap->getMappedTaxNodeId($testTaxNode);
225  $originalTaxonomyFilter[$poolTaxonomyId][] = $poolTaxNode;
226  }
227  }
228 
229  return $originalTaxonomyFilter;
230  }
Create styles array
The data for the language used.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ copyQuestionsToPool()

ilTestRandomQuestionSetPoolDeriver::copyQuestionsToPool ( ilObjQuestionPool  $pool,
  $questions 
)
protected

Definition at line 142 of file class.ilTestRandomQuestionSetPoolDeriver.php.

References array, ilObject\getId(), and getOwnerId().

Referenced by derive().

143  {
144  $poolQidByTestQidMap = array();
145 
146  foreach($questions as $questionOBJ)
147  {
148  /* @var assQuestion $questionOBJ */
149 
150  $testQuestionId = $questionOBJ->getId();
151  $poolQuestionId = $questionOBJ->duplicate(false, '', '', $this->getOwnerId(), $pool->getId());
152 
153  $poolQidByTestQidMap[$testQuestionId] = $poolQuestionId;
154  }
155 
156  return $poolQidByTestQidMap;
157  }
getId()
get object id public
Create styles array
The data for the language used.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ createNewPool()

ilTestRandomQuestionSetPoolDeriver::createNewPool ( ilTestRandomQuestionSetNonAvailablePool  $nonAvailablePool)
protected

Definition at line 129 of file class.ilTestRandomQuestionSetPoolDeriver.php.

References getTargetContainerRef(), and ilTestRandomQuestionSetNonAvailablePool\getTitle().

Referenced by derive().

130  {
131  $pool = $this->poolFactory->createNewInstance($this->getTargetContainerRef());
132 
133  if( strlen($nonAvailablePool->getTitle()) )
134  {
135  $pool->setTitle($nonAvailablePool->getTitle());
136  $pool->update();
137  }
138 
139  return $pool;
140  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ derive()

ilTestRandomQuestionSetPoolDeriver::derive ( ilTestRandomQuestionSetNonAvailablePool  $nonAvailablePool)
Parameters
ilTestRandomQuestionSetNonAvailablePool$nonAvailablePool
Returns
ilObjQuestionPool

Definition at line 255 of file class.ilTestRandomQuestionSetPoolDeriver.php.

References copyQuestionsToPool(), createNewPool(), duplicateTaxonomies(), ilTestRandomQuestionSetNonAvailablePool\getId(), getQuestionsForPool(), updateRelatedSourcePoolDefinitions(), and updateTestQuestionStage().

256  {
257  $pool = $this->createNewPool($nonAvailablePool);
258  $questions = $this->getQuestionsForPool($nonAvailablePool);
259 
260  $poolQidByTestQidMap = $this->copyQuestionsToPool($pool, $questions);
261 
262  $this->updateTestQuestionStage($poolQidByTestQidMap);
263 
264  $duplicatedTaxKeysMap = $this->duplicateTaxonomies($poolQidByTestQidMap, $pool);
265 
266  $this->updateRelatedSourcePoolDefinitions($duplicatedTaxKeysMap, $pool->getId(), $nonAvailablePool->getId());
267 
268  return $pool;
269  }
copyQuestionsToPool(ilObjQuestionPool $pool, $questions)
duplicateTaxonomies($poolQidByTestQidMap, ilObjQuestionPool $pool)
getQuestionsForPool(ilTestRandomQuestionSetNonAvailablePool $nonAvailablePool)
updateRelatedSourcePoolDefinitions(ilQuestionPoolDuplicatedTaxonomiesKeysMap $taxKeysMap, $derivedPoolId, $nonAvailablePoolId)
createNewPool(ilTestRandomQuestionSetNonAvailablePool $nonAvailablePool)
+ Here is the call graph for this function:

◆ duplicateTaxonomies()

ilTestRandomQuestionSetPoolDeriver::duplicateTaxonomies (   $poolQidByTestQidMap,
ilObjQuestionPool  $pool 
)
protected

Definition at line 196 of file class.ilTestRandomQuestionSetPoolDeriver.php.

References filterForQuestionRelatedTaxonomies(), ilObject\getId(), and ilObject\getType().

Referenced by derive().

197  {
198  require_once 'Modules/TestQuestionPool/classes/class.ilQuestionPoolTaxonomiesDuplicator.php';
199  $taxDuplicator = new ilQuestionPoolTaxonomiesDuplicator();
200  $taxDuplicator->setSourceObjId($this->testOBJ->getId());
201  $taxDuplicator->setSourceObjType($this->testOBJ->getType());
202  $taxDuplicator->setTargetObjId($pool->getId());
203  $taxDuplicator->setTargetObjType($pool->getType());
204  $taxDuplicator->setQuestionIdMapping($poolQidByTestQidMap);
205 
206  $taxDuplicator->duplicate($this->filterForQuestionRelatedTaxonomies(
207  $taxDuplicator->getAllTaxonomiesForSourceObject(), array_keys($poolQidByTestQidMap)
208  ));
209 
210  return $taxDuplicator->getDuplicatedTaxonomiesKeysMap();
211  }
getId()
get object id public
getType()
get object type public
filterForQuestionRelatedTaxonomies($taxonomyIds, $relatedQuestionIds)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ filterForQuestionRelatedTaxonomies()

ilTestRandomQuestionSetPoolDeriver::filterForQuestionRelatedTaxonomies (   $taxonomyIds,
  $relatedQuestionIds 
)
protected

Definition at line 168 of file class.ilTestRandomQuestionSetPoolDeriver.php.

References array, and ilTaxNodeAssignment\getAssignmentsOfItem().

Referenced by duplicateTaxonomies().

169  {
170  require_once 'Services/Taxonomy/classes/class.ilTaxNodeAssignment.php';
171 
172  $filteredTaxIds = array();
173 
174  foreach($taxonomyIds as $taxonomyId)
175  {
176  $taxNodeAssignment = new ilTaxNodeAssignment(
177  $this->testOBJ->getType(), $this->testOBJ->getId(), 'quest', $taxonomyId
178  );
179 
180  foreach($relatedQuestionIds as $questionId)
181  {
182  $assignedTaxNodes = $taxNodeAssignment->getAssignmentsOfItem($questionId);
183 
184  if( count($assignedTaxNodes) )
185  {
186  $filteredTaxIds[] = $taxonomyId;
187  break;
188  }
189  }
190 
191  }
192 
193  return $filteredTaxIds;
194  }
getAssignmentsOfItem($a_item_id)
Get assignments for item.
Taxonomy node <-> item assignment.
Create styles array
The data for the language used.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getOwnerId()

ilTestRandomQuestionSetPoolDeriver::getOwnerId ( )
Returns
int

Definition at line 78 of file class.ilTestRandomQuestionSetPoolDeriver.php.

References $ownerId.

Referenced by copyQuestionsToPool().

+ Here is the caller graph for this function:

◆ getQuestionsForPool()

ilTestRandomQuestionSetPoolDeriver::getQuestionsForPool ( ilTestRandomQuestionSetNonAvailablePool  $nonAvailablePool)
protected

Definition at line 107 of file class.ilTestRandomQuestionSetPoolDeriver.php.

References assQuestion\_instantiateQuestion(), array, and ilTestRandomQuestionSetNonAvailablePool\getId().

Referenced by derive().

108  {
110  $this->db, $this->pluginAdmin
111  );
112 
113  $questionList->setTestObjId($this->testOBJ->getId());
114  $questionList->setTestId($this->testOBJ->getTestId());
115  $questionList->setPoolId($nonAvailablePool->getId());
116 
117  $questionList->loadQuestions();
118 
119  $questions = array();
120 
121  foreach($questionList as $questionId)
122  {
123  $questions[] = assQuestion::_instantiateQuestion($questionId);
124  }
125 
126  return $questions;
127  }
Create styles array
The data for the language used.
static _instantiateQuestion($question_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getSourcePoolDefinitionList()

ilTestRandomQuestionSetPoolDeriver::getSourcePoolDefinitionList ( )

◆ getTargetContainerRef()

ilTestRandomQuestionSetPoolDeriver::getTargetContainerRef ( )
Returns
int

Definition at line 62 of file class.ilTestRandomQuestionSetPoolDeriver.php.

References $targetContainerRef.

Referenced by createNewPool().

+ Here is the caller graph for this function:

◆ setOwnerId()

ilTestRandomQuestionSetPoolDeriver::setOwnerId (   $ownerId)
Parameters
int$ownerId

Definition at line 86 of file class.ilTestRandomQuestionSetPoolDeriver.php.

References $ownerId.

◆ setSourcePoolDefinitionList()

ilTestRandomQuestionSetPoolDeriver::setSourcePoolDefinitionList (   $sourcePoolDefinitionList)
Parameters
ilTestRandomQuestionSetSourcePoolDefinitionList$sourcePoolDefinitionList

Definition at line 102 of file class.ilTestRandomQuestionSetPoolDeriver.php.

References $sourcePoolDefinitionList.

103  {
104  $this->sourcePoolDefinitionList = $sourcePoolDefinitionList;
105  }

◆ setTargetContainerRef()

ilTestRandomQuestionSetPoolDeriver::setTargetContainerRef (   $targetContainerRef)
Parameters
int$targetContainerRef

Definition at line 70 of file class.ilTestRandomQuestionSetPoolDeriver.php.

References $targetContainerRef.

71  {
72  $this->targetContainerRef = $targetContainerRef;
73  }

◆ updateRelatedSourcePoolDefinitions()

ilTestRandomQuestionSetPoolDeriver::updateRelatedSourcePoolDefinitions ( ilQuestionPoolDuplicatedTaxonomiesKeysMap  $taxKeysMap,
  $derivedPoolId,
  $nonAvailablePoolId 
)
protected

Definition at line 232 of file class.ilTestRandomQuestionSetPoolDeriver.php.

References buildOriginalTaxonomyFilterForDerivedPool(), and getSourcePoolDefinitionList().

Referenced by derive().

233  {
234  foreach($this->getSourcePoolDefinitionList() as $definition)
235  {
236  if( $definition->getPoolId() != $nonAvailablePoolId )
237  {
238  continue;
239  }
240 
241  $definition->setPoolId($derivedPoolId);
242 
243  $definition->setOriginalTaxonomyFilter( $this->buildOriginalTaxonomyFilterForDerivedPool(
244  $taxKeysMap, $definition->getMappedTaxonomyFilter()
245  ));
246 
247  $definition->saveToDb();
248  }
249  }
buildOriginalTaxonomyFilterForDerivedPool(ilQuestionPoolDuplicatedTaxonomiesKeysMap $taxKeysMap, $mappedTaxonomyFilter)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ updateTestQuestionStage()

ilTestRandomQuestionSetPoolDeriver::updateTestQuestionStage (   $poolQidByTestQidMap)
protected

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

References assQuestion\resetOriginalId(), and assQuestion\saveOriginalId().

Referenced by derive().

160  {
161  foreach($poolQidByTestQidMap as $testQid => $poolQid)
162  {
164  assQuestion::saveOriginalId($testQid, $poolQid);
165  }
166  }
static resetOriginalId($questionId)
static saveOriginalId($questionId, $originalId)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $db

ilTestRandomQuestionSetPoolDeriver::$db
protected

Definition at line 19 of file class.ilTestRandomQuestionSetPoolDeriver.php.

◆ $ownerId

ilTestRandomQuestionSetPoolDeriver::$ownerId
protected

Definition at line 39 of file class.ilTestRandomQuestionSetPoolDeriver.php.

Referenced by getOwnerId(), and setOwnerId().

◆ $pluginAdmin

ilTestRandomQuestionSetPoolDeriver::$pluginAdmin
protected

Definition at line 24 of file class.ilTestRandomQuestionSetPoolDeriver.php.

Referenced by __construct().

◆ $poolFactory

ilTestRandomQuestionSetPoolDeriver::$poolFactory
protected

Definition at line 44 of file class.ilTestRandomQuestionSetPoolDeriver.php.

◆ $sourcePoolDefinitionList

ilTestRandomQuestionSetPoolDeriver::$sourcePoolDefinitionList
protected

◆ $targetContainerRef

ilTestRandomQuestionSetPoolDeriver::$targetContainerRef
protected

◆ $testOBJ

ilTestRandomQuestionSetPoolDeriver::$testOBJ
protected

Definition at line 29 of file class.ilTestRandomQuestionSetPoolDeriver.php.

Referenced by __construct().


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