ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 ()
 
 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 350 of file class.ilTestRandomQuestionSetSourcePoolDefinitionList.php.

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

References hasLostPool(), and hasTrashedPool().

+ Here is the call graph for this function:

◆ current()

ilTestRandomQuestionSetSourcePoolDefinitionList::current ( )
Returns
ilTestRandomQuestionSetSourcePoolDefinition

Definition at line 376 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 261 of file class.ilTestRandomQuestionSetSourcePoolDefinitionList.php.

262 {
263 $query = "DELETE FROM tst_rnd_quest_set_qpls WHERE test_fi = %s";
264 $this->db->manipulateF($query, array('integer'), array($this->testOBJ->getTestId()));
265 }

References $query.

◆ getDefinition()

ilTestRandomQuestionSetSourcePoolDefinitionList::getDefinition (   $sourcePoolDefinitionId)

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

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

Referenced by hasDefinition().

+ Here is the caller graph for this function:

◆ getDefinitionBySourcePoolId()

ilTestRandomQuestionSetSourcePoolDefinitionList::getDefinitionBySourcePoolId (   $sourcePoolId)

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

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

◆ getDefinitionCount()

ilTestRandomQuestionSetSourcePoolDefinitionList::getDefinitionCount ( )

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

159 {
160 return count($this->sourcePoolDefinitions);
161 }

◆ getDefinitionIds()

ilTestRandomQuestionSetSourcePoolDefinitionList::getDefinitionIds ( )

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

154 {
155 return array_keys($this->sourcePoolDefinitions);
156 }

◆ getLostPool()

ilTestRandomQuestionSetSourcePoolDefinitionList::getLostPool (   $poolId)

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

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

References isLostPool().

+ Here is the call graph for this function:

◆ getLostPools()

ilTestRandomQuestionSetSourcePoolDefinitionList::getLostPools ( )

◆ getNextPosition()

ilTestRandomQuestionSetSourcePoolDefinitionList::getNextPosition ( )

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

293 {
294 return ( count($this->sourcePoolDefinitions) + 1 );
295 }

◆ getNonAvailablePools()

ilTestRandomQuestionSetSourcePoolDefinitionList::getNonAvailablePools ( )

◆ getTrashedPools()

ilTestRandomQuestionSetSourcePoolDefinitionList::getTrashedPools ( )
Returns
array

Definition at line 108 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 123 of file class.ilTestRandomQuestionSetSourcePoolDefinitionList.php.

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

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 100 of file class.ilTestRandomQuestionSetSourcePoolDefinitionList.php.

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

Referenced by areAllUsedPoolsAvailable().

+ Here is the caller graph for this function:

◆ 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 95 of file class.ilTestRandomQuestionSetSourcePoolDefinitionList.php.

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

◆ key()

ilTestRandomQuestionSetSourcePoolDefinitionList::key ( )
Returns
integer

Definition at line 384 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 164 of file class.ilTestRandomQuestionSetSourcePoolDefinitionList.php.

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

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 392 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 368 of file class.ilTestRandomQuestionSetSourcePoolDefinitionList.php.

369 {
370 return reset($this->sourcePoolDefinitions);
371 }

◆ savedDefinitionsExist()

ilTestRandomQuestionSetSourcePoolDefinitionList::savedDefinitionsExist ( )
Returns
bool

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

327 {
328 $query = "SELECT COUNT(*) cnt FROM tst_rnd_quest_set_qpls WHERE test_fi = %s";
329 $res = $this->db->queryF($query, array('integer'), array($this->testOBJ->getTestId()));
330
331 $row = $this->db->fetchAssoc($res);
332
333 return $row['cnt'] > 0;
334 }

References $query, $res, and $row.

◆ setTrashedPools()

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

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

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

References $trashedPools.

Referenced by loadDefinitions().

+ Here is the caller graph for this function:

◆ valid()

ilTestRandomQuestionSetSourcePoolDefinitionList::valid ( )
Returns
boolean

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

401 {
402 return key($this->sourcePoolDefinitions) !== null;
403 }

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: