ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 210 of file class.ilTestRandomQuestionSetPoolDeriver.php.

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

Referenced by updateRelatedSourcePoolDefinitions().

211  {
212  $originalTaxonomyFilter = array();
213 
214  foreach ($mappedTaxonomyFilter as $testTaxonomyId => $testTaxNodes) {
215  $poolTaxonomyId = $taxKeysMap->getMappedTaxonomyId($testTaxonomyId);
216  $originalTaxonomyFilter[$poolTaxonomyId] = array();
217 
218  foreach ($testTaxNodes as $testTaxNode) {
219  $poolTaxNode = $taxKeysMap->getMappedTaxNodeId($testTaxNode);
220  $originalTaxonomyFilter[$poolTaxonomyId][] = $poolTaxNode;
221  }
222  }
223 
224  return $originalTaxonomyFilter;
225  }
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 141 of file class.ilTestRandomQuestionSetPoolDeriver.php.

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

Referenced by derive().

142  {
143  $poolQidByTestQidMap = array();
144 
145  foreach ($questions as $questionOBJ) {
146  /* @var assQuestion $questionOBJ */
147 
148  $testQuestionId = $questionOBJ->getId();
149  $poolQuestionId = $questionOBJ->duplicate(false, '', '', $this->getOwnerId(), $pool->getId());
150 
151  $poolQidByTestQidMap[$testQuestionId] = $poolQuestionId;
152  }
153 
154  return $poolQidByTestQidMap;
155  }
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  $pool->setTitle($nonAvailablePool->getTitle());
135  $pool->update();
136  }
137 
138  return $pool;
139  }
+ 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 249 of file class.ilTestRandomQuestionSetPoolDeriver.php.

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

250  {
251  $pool = $this->createNewPool($nonAvailablePool);
252  $questions = $this->getQuestionsForPool($nonAvailablePool);
253 
254  $poolQidByTestQidMap = $this->copyQuestionsToPool($pool, $questions);
255 
256  $this->updateTestQuestionStage($poolQidByTestQidMap);
257 
258  $duplicatedTaxKeysMap = $this->duplicateTaxonomies($poolQidByTestQidMap, $pool);
259 
260  $this->updateRelatedSourcePoolDefinitions($duplicatedTaxKeysMap, $pool->getId(), $nonAvailablePool->getId());
261 
262  return $pool;
263  }
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 192 of file class.ilTestRandomQuestionSetPoolDeriver.php.

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

Referenced by derive().

193  {
194  require_once 'Modules/TestQuestionPool/classes/class.ilQuestionPoolTaxonomiesDuplicator.php';
195  $taxDuplicator = new ilQuestionPoolTaxonomiesDuplicator();
196  $taxDuplicator->setSourceObjId($this->testOBJ->getId());
197  $taxDuplicator->setSourceObjType($this->testOBJ->getType());
198  $taxDuplicator->setTargetObjId($pool->getId());
199  $taxDuplicator->setTargetObjType($pool->getType());
200  $taxDuplicator->setQuestionIdMapping($poolQidByTestQidMap);
201 
202  $taxDuplicator->duplicate($this->filterForQuestionRelatedTaxonomies(
203  $taxDuplicator->getAllTaxonomiesForSourceObject(),
204  array_keys($poolQidByTestQidMap)
205  ));
206 
207  return $taxDuplicator->getDuplicatedTaxonomiesKeysMap();
208  }
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 165 of file class.ilTestRandomQuestionSetPoolDeriver.php.

References array, and ilTaxNodeAssignment\getAssignmentsOfItem().

Referenced by duplicateTaxonomies().

166  {
167  require_once 'Services/Taxonomy/classes/class.ilTaxNodeAssignment.php';
168 
169  $filteredTaxIds = array();
170 
171  foreach ($taxonomyIds as $taxonomyId) {
172  $taxNodeAssignment = new ilTaxNodeAssignment(
173  $this->testOBJ->getType(),
174  $this->testOBJ->getId(),
175  'quest',
176  $taxonomyId
177  );
178 
179  foreach ($relatedQuestionIds as $questionId) {
180  $assignedTaxNodes = $taxNodeAssignment->getAssignmentsOfItem($questionId);
181 
182  if (count($assignedTaxNodes)) {
183  $filteredTaxIds[] = $taxonomyId;
184  break;
185  }
186  }
187  }
188 
189  return $filteredTaxIds;
190  }
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,
111  $this->pluginAdmin
112  );
113 
114  $questionList->setTestObjId($this->testOBJ->getId());
115  $questionList->setTestId($this->testOBJ->getTestId());
116  $questionList->setPoolId($nonAvailablePool->getId());
117 
118  $questionList->loadQuestions();
119 
120  $questions = array();
121 
122  foreach ($questionList as $questionId) {
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 227 of file class.ilTestRandomQuestionSetPoolDeriver.php.

References buildOriginalTaxonomyFilterForDerivedPool(), and getSourcePoolDefinitionList().

Referenced by derive().

228  {
229  foreach ($this->getSourcePoolDefinitionList() as $definition) {
230  if ($definition->getPoolId() != $nonAvailablePoolId) {
231  continue;
232  }
233 
234  $definition->setPoolId($derivedPoolId);
235 
236  $definition->setOriginalTaxonomyFilter($this->buildOriginalTaxonomyFilterForDerivedPool(
237  $taxKeysMap,
238  $definition->getMappedTaxonomyFilter()
239  ));
240 
241  $definition->saveToDb();
242  }
243  }
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 157 of file class.ilTestRandomQuestionSetPoolDeriver.php.

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

Referenced by derive().

158  {
159  foreach ($poolQidByTestQidMap as $testQid => $poolQid) {
161  assQuestion::saveOriginalId($testQid, $poolQid);
162  }
163  }
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: