ILIAS  release_7 Revision v7.30-3-g800a261c036
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 354 of file class.ilTestRandomQuestionSetSourcePoolDefinitionList.php.

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

References hasLostPool(), and hasTrashedPool().

+ Here is the call graph for this function:

◆ current()

ilTestRandomQuestionSetSourcePoolDefinitionList::current ( )
Returns
ilTestRandomQuestionSetSourcePoolDefinition

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

255 {
256 $query = "DELETE FROM tst_rnd_quest_set_qpls WHERE test_fi = %s";
257 $this->db->manipulateF($query, array('integer'), array($this->testOBJ->getTestId()));
258 }
$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 282 of file class.ilTestRandomQuestionSetSourcePoolDefinitionList.php.

283 {
284 return (count($this->sourcePoolDefinitions) + 1);
285 }

◆ getNonAvailablePools()

ilTestRandomQuestionSetSourcePoolDefinitionList::getNonAvailablePools ( )

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

344 {
345 foreach ($this as $definition) {
346 if (count($definition->getTypeFilter())) {
347 return true;
348 }
349 }
350 return false;
351 }

◆ 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 386 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, odat.title actual_pool_title, 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 && !$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 if (isset($row['actual_pool_title'])
216 && $sourcePoolDefinition->getPoolTitle() !== $row['actual_pool_title']) {
217 $sourcePoolDefinition->setPoolTitle($row['actual_pool_title']);
218 $sourcePoolDefinition->saveToDb();
219 }
220
221 if ($row['child']) {
222 unset($trashedPools[$row['pool_id']]);
223 }
224 }
225
227 }
addDefinition(ilTestRandomQuestionSetSourcePoolDefinition $sourcePoolDefinition)
foreach($_POST as $key=> $value) $res

References $query, $res, $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 394 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 370 of file class.ilTestRandomQuestionSetSourcePoolDefinitionList.php.

371 {
372 return reset($this->sourcePoolDefinitions);
373 }

◆ savedDefinitionsExist()

ilTestRandomQuestionSetSourcePoolDefinitionList::savedDefinitionsExist ( )
Returns
bool

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

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

References $query, and $res.

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

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

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: