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

Public Member Functions

 __construct (ilDBInterface $db, ilObjTest $testOBJ, ilTestRandomQuestionSetSourcePoolDefinitionFactory $sourcePoolDefinitionFactory)
 Constructor. More...
 
 addDefinition (ilTestRandomQuestionSetSourcePoolDefinition $sourcePoolDefinition)
 
 isLostPool ($poolId)
 
 hasLostPool ()
 
 getLostPools ()
 
 getLostPool ($poolId)
 
 isTrashedPool ($poolId)
 
 hasTrashedPool ()
 
 getTrashedPools ()
 
 setTrashedPools ($trashedPools)
 
 hasDefinition ($sourcePoolDefinitionId)
 
 getDefinition ($sourcePoolDefinitionId)
 
 getDefinitionBySourcePoolId ($sourcePoolId)
 
 getDefinitionIds ()
 
 getDefinitionCount ()
 
 loadDefinitions ()
 
 deleteDefinitions ()
 
 getNextPosition ()
 
 savedDefinitionsExist ()
 
 hasTypeFilters ()
 
 areAllUsedPoolsAvailable ()
 
 rewind ()
 
 current ()
 
 key ()
 
 next ()
 
 valid ()
 
 getNonAvailablePools ()
 

Protected Member Functions

 addLostPool (ilTestRandomQuestionSetNonAvailablePool $lostPool)
 

Protected Attributes

 $db = null
 
 $testOBJ = null
 
 $lostPools = array()
 
 $trashedPools = array()
 

Private Attributes

 $sourcePoolDefinitions = array()
 
 $sourcePoolDefinitionFactory = null
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

Member Function Documentation

◆ addDefinition()

ilTestRandomQuestionSetSourcePoolDefinitionList::addDefinition ( ilTestRandomQuestionSetSourcePoolDefinition  $sourcePoolDefinition)

Definition at line 60 of file class.ilTestRandomQuestionSetSourcePoolDefinitionList.php.

61 {
62 $this->sourcePoolDefinitions[ $sourcePoolDefinition->getId() ] = $sourcePoolDefinition;
63 }

References ilTestRandomQuestionSetSourcePoolDefinition\getId().

Referenced by loadDefinitions().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addLostPool()

ilTestRandomQuestionSetSourcePoolDefinitionList::addLostPool ( ilTestRandomQuestionSetNonAvailablePool  $lostPool)
protected

Definition at line 65 of file class.ilTestRandomQuestionSetSourcePoolDefinitionList.php.

66 {
67 $this->lostPools[$lostPool->getId()] = $lostPool;
68 }

References ilTestRandomQuestionSetNonAvailablePool\getId().

Referenced by loadDefinitions().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ areAllUsedPoolsAvailable()

ilTestRandomQuestionSetSourcePoolDefinitionList::areAllUsedPoolsAvailable ( )

Definition at line 349 of file class.ilTestRandomQuestionSetSourcePoolDefinitionList.php.

350 {
351 if ($this->hasLostPool()) {
352 return false;
353 }
354
355 if ($this->hasTrashedPool()) {
356 return false;
357 }
358
359 return true;
360 }

References hasLostPool(), and hasTrashedPool().

+ Here is the call graph for this function:

◆ current()

ilTestRandomQuestionSetSourcePoolDefinitionList::current ( )
Returns
ilTestRandomQuestionSetSourcePoolDefinition

Definition at line 373 of file class.ilTestRandomQuestionSetSourcePoolDefinitionList.php.

References current().

Referenced by current().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deleteDefinitions()

ilTestRandomQuestionSetSourcePoolDefinitionList::deleteDefinitions ( )

Definition at line 249 of file class.ilTestRandomQuestionSetSourcePoolDefinitionList.php.

250 {
251 $query = "DELETE FROM tst_rnd_quest_set_qpls WHERE test_fi = %s";
252 $this->db->manipulateF($query, array('integer'), array($this->testOBJ->getTestId()));
253 }
$query

References $query.

◆ getDefinition()

ilTestRandomQuestionSetSourcePoolDefinitionList::getDefinition (   $sourcePoolDefinitionId)

Definition at line 127 of file class.ilTestRandomQuestionSetSourcePoolDefinitionList.php.

128 {
129 if (isset($this->sourcePoolDefinitions[$sourcePoolDefinitionId])) {
130 return $this->sourcePoolDefinitions[$sourcePoolDefinitionId];
131 }
132
133 return null;
134 }

Referenced by hasDefinition().

+ Here is the caller graph for this function:

◆ getDefinitionBySourcePoolId()

ilTestRandomQuestionSetSourcePoolDefinitionList::getDefinitionBySourcePoolId (   $sourcePoolId)

Definition at line 136 of file class.ilTestRandomQuestionSetSourcePoolDefinitionList.php.

137 {
138 foreach ($this as $definition) {
139 if ($definition->getPoolId() != $sourcePoolId) {
140 continue;
141 }
142
143 return $definition;
144 }
145
146 throw new InvalidArgumentException('invalid source pool id given');
147 }

◆ getDefinitionCount()

ilTestRandomQuestionSetSourcePoolDefinitionList::getDefinitionCount ( )

Definition at line 154 of file class.ilTestRandomQuestionSetSourcePoolDefinitionList.php.

155 {
156 return count($this->sourcePoolDefinitions);
157 }

◆ getDefinitionIds()

ilTestRandomQuestionSetSourcePoolDefinitionList::getDefinitionIds ( )

Definition at line 149 of file class.ilTestRandomQuestionSetSourcePoolDefinitionList.php.

150 {
151 return array_keys($this->sourcePoolDefinitions);
152 }

◆ getLostPool()

ilTestRandomQuestionSetSourcePoolDefinitionList::getLostPool (   $poolId)

Definition at line 85 of file class.ilTestRandomQuestionSetSourcePoolDefinitionList.php.

86 {
87 if ($this->isLostPool($poolId)) {
88 return $this->lostPools[$poolId];
89 }
90
91 return null;
92 }

References isLostPool().

+ Here is the call graph for this function:

◆ getLostPools()

ilTestRandomQuestionSetSourcePoolDefinitionList::getLostPools ( )

◆ getNextPosition()

ilTestRandomQuestionSetSourcePoolDefinitionList::getNextPosition ( )

Definition at line 277 of file class.ilTestRandomQuestionSetSourcePoolDefinitionList.php.

278 {
279 return (count($this->sourcePoolDefinitions) + 1);
280 }

◆ getNonAvailablePools()

ilTestRandomQuestionSetSourcePoolDefinitionList::getNonAvailablePools ( )

Definition at line 402 of file class.ilTestRandomQuestionSetSourcePoolDefinitionList.php.

References getLostPools(), and getTrashedPools().

+ Here is the call graph for this function:

◆ getTrashedPools()

ilTestRandomQuestionSetSourcePoolDefinitionList::getTrashedPools ( )
Returns
array

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

References $trashedPools.

Referenced by getNonAvailablePools().

+ Here is the caller graph for this function:

◆ hasDefinition()

ilTestRandomQuestionSetSourcePoolDefinitionList::hasDefinition (   $sourcePoolDefinitionId)

Definition at line 122 of file class.ilTestRandomQuestionSetSourcePoolDefinitionList.php.

123 {
124 return $this->getDefinition($sourcePoolDefinitionId) !== null;
125 }

References getDefinition().

+ Here is the call graph for this function:

◆ hasLostPool()

ilTestRandomQuestionSetSourcePoolDefinitionList::hasLostPool ( )

Definition at line 75 of file class.ilTestRandomQuestionSetSourcePoolDefinitionList.php.

76 {
77 return (bool) count($this->lostPools);
78 }

Referenced by areAllUsedPoolsAvailable().

+ Here is the caller graph for this function:

◆ hasTrashedPool()

ilTestRandomQuestionSetSourcePoolDefinitionList::hasTrashedPool ( )

Definition at line 99 of file class.ilTestRandomQuestionSetSourcePoolDefinitionList.php.

100 {
101 return (bool) count($this->trashedPools);
102 }

Referenced by areAllUsedPoolsAvailable().

+ Here is the caller graph for this function:

◆ hasTypeFilters()

ilTestRandomQuestionSetSourcePoolDefinitionList::hasTypeFilters ( )

Definition at line 338 of file class.ilTestRandomQuestionSetSourcePoolDefinitionList.php.

339 {
340 foreach ($this as $definition) {
341 if (count($definition->getTypeFilter())) {
342 return true;
343 }
344 }
345 return false;
346 }

◆ isLostPool()

ilTestRandomQuestionSetSourcePoolDefinitionList::isLostPool (   $poolId)

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

71 {
72 return isset($this->lostPools[$poolId]);
73 }

Referenced by getLostPool(), and loadDefinitions().

+ Here is the caller graph for this function:

◆ isTrashedPool()

ilTestRandomQuestionSetSourcePoolDefinitionList::isTrashedPool (   $poolId)

Definition at line 94 of file class.ilTestRandomQuestionSetSourcePoolDefinitionList.php.

95 {
96 return isset($this->trashedPools[$poolId]);
97 }

◆ key()

ilTestRandomQuestionSetSourcePoolDefinitionList::key ( )
Returns
integer

Definition at line 381 of file class.ilTestRandomQuestionSetSourcePoolDefinitionList.php.

References key().

Referenced by key(), and valid().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ loadDefinitions()

ilTestRandomQuestionSetSourcePoolDefinitionList::loadDefinitions ( )

Definition at line 160 of file class.ilTestRandomQuestionSetSourcePoolDefinitionList.php.

161 {
162 $query = "
163 SELECT tst_rnd_quest_set_qpls.*, odat.obj_id pool_id, tree.child
164 FROM tst_rnd_quest_set_qpls
165 LEFT JOIN object_data odat
166 ON odat.obj_id = pool_fi
167 LEFT JOIN object_reference oref
168 ON oref.obj_id = pool_fi
169 LEFT JOIN tree
170 ON tree = %s
171 AND child = oref.ref_id
172 WHERE test_fi = %s
173 ORDER BY sequence_pos ASC
174 ";
175
176 $res = $this->db->queryF($query, array('integer', 'integer'), array(1, $this->testOBJ->getTestId()));
177
178 $handledDefinitions = array();
179 $trashedPools = array();
180
181 while ($row = $this->db->fetchAssoc($res)) {
182 $sourcePoolDefinition = $this->sourcePoolDefinitionFactory->getEmptySourcePoolDefinition();
183 $sourcePoolDefinition->initFromArray($row);
184
185 if (!isset($handledDefinitions[$sourcePoolDefinition->getId()])) {
186 $this->addDefinition($sourcePoolDefinition);
187 $handledDefinitions[$sourcePoolDefinition->getId()] = $sourcePoolDefinition->getId();
188
189 $trashedPool = new ilTestRandomQuestionSetNonAvailablePool();
190 $trashedPool->assignDbRow($row);
191
192 $trashedPool->setUnavailabilityStatus(
194 );
195
196 $trashedPools[$trashedPool->getId()] = $trashedPool;
197 }
198
199 if (!$this->isLostPool($row['pool_id'])) {
200 if (!$row['pool_id']) {
202 $lostPool->assignDbRow($row);
203
204 $lostPool->setUnavailabilityStatus(
206 );
207
208 $this->addLostPool($lostPool);
209
210 if (isset($trashedPools[$lostPool->getId()])) {
211 unset($trashedPools[$lostPool->getId()]);
212 }
213 }
214 }
215
216 if ($row['child']) {
217 unset($trashedPools[$row['pool_id']]);
218 }
219 }
220
222 }
addDefinition(ilTestRandomQuestionSetSourcePoolDefinition $sourcePoolDefinition)
$row
foreach($_POST as $key=> $value) $res

References $query, $res, $row, $trashedPools, addDefinition(), addLostPool(), isLostPool(), setTrashedPools(), ilTestRandomQuestionSetNonAvailablePool\UNAVAILABILITY_STATUS_LOST, and ilTestRandomQuestionSetNonAvailablePool\UNAVAILABILITY_STATUS_TRASHED.

+ Here is the call graph for this function:

◆ next()

ilTestRandomQuestionSetSourcePoolDefinitionList::next ( )
Returns
ilTestRandomQuestionSetSourcePoolDefinition

Definition at line 389 of file class.ilTestRandomQuestionSetSourcePoolDefinitionList.php.

References next().

Referenced by next().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ rewind()

ilTestRandomQuestionSetSourcePoolDefinitionList::rewind ( )
Returns
ilTestRandomQuestionSetSourcePoolDefinition

Definition at line 365 of file class.ilTestRandomQuestionSetSourcePoolDefinitionList.php.

366 {
367 return reset($this->sourcePoolDefinitions);
368 }

◆ savedDefinitionsExist()

ilTestRandomQuestionSetSourcePoolDefinitionList::savedDefinitionsExist ( )
Returns
bool

Definition at line 309 of file class.ilTestRandomQuestionSetSourcePoolDefinitionList.php.

310 {
311 $query = "SELECT COUNT(*) cnt FROM tst_rnd_quest_set_qpls WHERE test_fi = %s";
312 $res = $this->db->queryF($query, array('integer'), array($this->testOBJ->getTestId()));
313
314 $row = $this->db->fetchAssoc($res);
315
316 return $row['cnt'] > 0;
317 }

References $query, $res, and $row.

◆ setTrashedPools()

ilTestRandomQuestionSetSourcePoolDefinitionList::setTrashedPools (   $trashedPools)
Parameters
array$trashedPools

Definition at line 115 of file class.ilTestRandomQuestionSetSourcePoolDefinitionList.php.

116 {
117 $this->trashedPools = $trashedPools;
118 }

References $trashedPools.

Referenced by loadDefinitions().

+ Here is the caller graph for this function:

◆ valid()

ilTestRandomQuestionSetSourcePoolDefinitionList::valid ( )
Returns
boolean

Definition at line 397 of file class.ilTestRandomQuestionSetSourcePoolDefinitionList.php.

398 {
399 return key($this->sourcePoolDefinitions) !== null;
400 }

References key().

+ Here is the call graph for this function:

Field Documentation

◆ $db

ilTestRandomQuestionSetSourcePoolDefinitionList::$db = null
protected

◆ $lostPools

ilTestRandomQuestionSetSourcePoolDefinitionList::$lostPools = array()
protected

◆ $sourcePoolDefinitionFactory

ilTestRandomQuestionSetSourcePoolDefinitionList::$sourcePoolDefinitionFactory = null
private

◆ $sourcePoolDefinitions

ilTestRandomQuestionSetSourcePoolDefinitionList::$sourcePoolDefinitions = array()
private

◆ $testOBJ

ilTestRandomQuestionSetSourcePoolDefinitionList::$testOBJ = null
protected

◆ $trashedPools

ilTestRandomQuestionSetSourcePoolDefinitionList::$trashedPools = array()
protected

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