ILIAS  release_8 Revision v8.24
ilTestRandomQuestionSetSourcePoolDefinitionList Class Reference
+ Inheritance diagram for ilTestRandomQuestionSetSourcePoolDefinitionList:
+ Collaboration diagram for ilTestRandomQuestionSetSourcePoolDefinitionList:

Public Member Functions

 __construct (ilDBInterface $db, ilObjTest $testOBJ, ilTestRandomQuestionSetSourcePoolDefinitionFactory $sourcePoolDefinitionFactory)
 
 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

ilDBInterface $db
 
ilObjTest $testOBJ
 
array $lostPools = array()
 
array $trashedPools = array()
 

Private Attributes

array $sourcePoolDefinitions = array()
 
ilTestRandomQuestionSetSourcePoolDefinitionFactory $sourcePoolDefinitionFactory
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilTestRandomQuestionSetSourcePoolDefinitionList::__construct ( ilDBInterface  $db,
ilObjTest  $testOBJ,
ilTestRandomQuestionSetSourcePoolDefinitionFactory  $sourcePoolDefinitionFactory 
)

Member Function Documentation

◆ addDefinition()

ilTestRandomQuestionSetSourcePoolDefinitionList::addDefinition ( ilTestRandomQuestionSetSourcePoolDefinition  $sourcePoolDefinition)

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

42 {
43 $this->sourcePoolDefinitions[ $sourcePoolDefinition->getId() ] = $sourcePoolDefinition;
44 }

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

47 {
48 $this->lostPools[$lostPool->getId()] = $lostPool;
49 }

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

332 : bool
333 {
334 if ($this->hasLostPool()) {
335 return false;
336 }
337
338 if ($this->hasTrashedPool()) {
339 return false;
340 }
341
342 return true;
343 }

References hasLostPool(), and hasTrashedPool().

+ Here is the call graph for this function:

◆ current()

ilTestRandomQuestionSetSourcePoolDefinitionList::current ( )
Returns
false|ilTestRandomQuestionSetSourcePoolDefinition

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

233 {
234 $query = "DELETE FROM tst_rnd_quest_set_qpls WHERE test_fi = %s";
235 $this->db->manipulateF($query, array('integer'), array($this->testOBJ->getTestId()));
236 }
$query

References $query.

◆ getDefinition()

ilTestRandomQuestionSetSourcePoolDefinitionList::getDefinition (   $sourcePoolDefinitionId)

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

106 {
107 if (isset($this->sourcePoolDefinitions[$sourcePoolDefinitionId])) {
108 return $this->sourcePoolDefinitions[$sourcePoolDefinitionId];
109 }
110
111 return null;
112 }

Referenced by hasDefinition().

+ Here is the caller graph for this function:

◆ getDefinitionBySourcePoolId()

ilTestRandomQuestionSetSourcePoolDefinitionList::getDefinitionBySourcePoolId (   $sourcePoolId)

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

115 {
116 foreach ($this as $definition) {
117 if ($definition->getPoolId() != $sourcePoolId) {
118 continue;
119 }
120
121 return $definition;
122 }
123
124 throw new InvalidArgumentException('invalid source pool id given');
125 }

◆ getDefinitionCount()

ilTestRandomQuestionSetSourcePoolDefinitionList::getDefinitionCount ( )

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

132 : int
133 {
134 return count($this->sourcePoolDefinitions);
135 }

◆ getDefinitionIds()

ilTestRandomQuestionSetSourcePoolDefinitionList::getDefinitionIds ( )

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

127 : array
128 {
129 return array_keys($this->sourcePoolDefinitions);
130 }

◆ getLostPool()

ilTestRandomQuestionSetSourcePoolDefinitionList::getLostPool (   $poolId)

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

67 {
68 if ($this->isLostPool($poolId)) {
69 return $this->lostPools[$poolId];
70 }
71
72 return null;
73 }

References isLostPool().

+ Here is the call graph for this function:

◆ getLostPools()

ilTestRandomQuestionSetSourcePoolDefinitionList::getLostPools ( )

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

References $lostPools.

Referenced by getNonAvailablePools().

+ Here is the caller graph for this function:

◆ getNextPosition()

ilTestRandomQuestionSetSourcePoolDefinitionList::getNextPosition ( )

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

260 : int
261 {
262 return (count($this->sourcePoolDefinitions) + 1);
263 }

◆ getNonAvailablePools()

ilTestRandomQuestionSetSourcePoolDefinitionList::getNonAvailablePools ( )

◆ getTrashedPools()

ilTestRandomQuestionSetSourcePoolDefinitionList::getTrashedPools ( )

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

100 : bool
101 {
102 return $this->getDefinition($sourcePoolDefinitionId) !== null;
103 }

References getDefinition().

+ Here is the call graph for this function:

◆ hasLostPool()

ilTestRandomQuestionSetSourcePoolDefinitionList::hasLostPool ( )

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

56 : bool
57 {
58 return (bool) count($this->lostPools);
59 }

Referenced by areAllUsedPoolsAvailable().

+ Here is the caller graph for this function:

◆ hasTrashedPool()

ilTestRandomQuestionSetSourcePoolDefinitionList::hasTrashedPool ( )

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

80 : bool
81 {
82 return (bool) count($this->trashedPools);
83 }

Referenced by areAllUsedPoolsAvailable().

+ Here is the caller graph for this function:

◆ hasTypeFilters()

ilTestRandomQuestionSetSourcePoolDefinitionList::hasTypeFilters ( )

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

321 : bool
322 {
323 foreach ($this as $definition) {
324 if (count($definition->getTypeFilter())) {
325 return true;
326 }
327 }
328 return false;
329 }

◆ isLostPool()

ilTestRandomQuestionSetSourcePoolDefinitionList::isLostPool (   $poolId)

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

51 : bool
52 {
53 return isset($this->lostPools[$poolId]);
54 }

Referenced by getLostPool(), and loadDefinitions().

+ Here is the caller graph for this function:

◆ isTrashedPool()

ilTestRandomQuestionSetSourcePoolDefinitionList::isTrashedPool (   $poolId)

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

75 : bool
76 {
77 return isset($this->trashedPools[$poolId]);
78 }

◆ key()

ilTestRandomQuestionSetSourcePoolDefinitionList::key ( )
Returns
int|null|string

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

139 {
140 $query = "
141 SELECT tst_rnd_quest_set_qpls.*, odat.obj_id pool_id, odat.title actual_pool_title, tree.child
142 FROM tst_rnd_quest_set_qpls
143 LEFT JOIN object_data odat
144 ON odat.obj_id = pool_fi
145 LEFT JOIN object_reference oref
146 ON oref.obj_id = pool_fi
147 LEFT JOIN tree
148 ON tree = %s
149 AND child = oref.ref_id
150 WHERE test_fi = %s
151 ORDER BY sequence_pos ASC
152 ";
153
154 $res = $this->db->queryF($query, array('integer', 'integer'), array(1, $this->testOBJ->getTestId()));
155
156 $handledDefinitions = array();
157 $trashedPools = array();
158
159 while ($row = $this->db->fetchAssoc($res)) {
160 $sourcePoolDefinition = $this->sourcePoolDefinitionFactory->getEmptySourcePoolDefinition();
161 $sourcePoolDefinition->initFromArray($row);
162
163 if (!isset($handledDefinitions[$sourcePoolDefinition->getId()])) {
164 $this->addDefinition($sourcePoolDefinition);
165 $handledDefinitions[$sourcePoolDefinition->getId()] = $sourcePoolDefinition->getId();
166
167 $trashedPool = new ilTestRandomQuestionSetNonAvailablePool();
168 $trashedPool->assignDbRow($row);
169
170 $trashedPool->setUnavailabilityStatus(
172 );
173
174 $trashedPools[$trashedPool->getId()] = $trashedPool;
175 }
176
177 if (!$this->isLostPool($row['pool_id'])
178 && !$row['pool_id']) {
180 $lostPool->assignDbRow($row);
181
182 $lostPool->setUnavailabilityStatus(
184 );
185
186 $this->addLostPool($lostPool);
187
188 if (isset($trashedPools[$lostPool->getId()])) {
189 unset($trashedPools[$lostPool->getId()]);
190 }
191 }
192
193 if (isset($row['actual_pool_title'])
194 && $sourcePoolDefinition->getPoolTitle() !== $row['actual_pool_title']) {
195 $sourcePoolDefinition->setPoolTitle($row['actual_pool_title']);
196 $sourcePoolDefinition->saveToDb();
197 }
198
199 if ($row['child']) {
200 unset($trashedPools[$row['pool_id']]);
201 }
202 }
203
205 }
addDefinition(ilTestRandomQuestionSetSourcePoolDefinition $sourcePoolDefinition)
$res
Definition: ltiservices.php:69

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
false|ilTestRandomQuestionSetSourcePoolDefinition

Definition at line 372 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
false|ilTestRandomQuestionSetSourcePoolDefinition

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

349 {
350 return reset($this->sourcePoolDefinitions);
351 }

◆ savedDefinitionsExist()

ilTestRandomQuestionSetSourcePoolDefinitionList::savedDefinitionsExist ( )
Returns
bool

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

292 : bool
293 {
294 $query = "SELECT COUNT(*) cnt FROM tst_rnd_quest_set_qpls WHERE test_fi = %s";
295 $res = $this->db->queryF($query, array('integer'), array($this->testOBJ->getTestId()));
296
297 $row = $this->db->fetchAssoc($res);
298
299 return $row['cnt'] > 0;
300 }

References $query, and $res.

◆ setTrashedPools()

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

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

94 {
95 $this->trashedPools = $trashedPools;
96 }

References $trashedPools.

Referenced by loadDefinitions().

+ Here is the caller graph for this function:

◆ valid()

ilTestRandomQuestionSetSourcePoolDefinitionList::valid ( )
Returns
boolean

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

380 : bool
381 {
382 return key($this->sourcePoolDefinitions) !== null;
383 }

References key().

+ Here is the call graph for this function:

Field Documentation

◆ $db

ilDBInterface ilTestRandomQuestionSetSourcePoolDefinitionList::$db
protected

◆ $lostPools

array ilTestRandomQuestionSetSourcePoolDefinitionList::$lostPools = array()
protected

◆ $sourcePoolDefinitionFactory

ilTestRandomQuestionSetSourcePoolDefinitionFactory ilTestRandomQuestionSetSourcePoolDefinitionList::$sourcePoolDefinitionFactory
private

◆ $sourcePoolDefinitions

array ilTestRandomQuestionSetSourcePoolDefinitionList::$sourcePoolDefinitions = array()
private

◆ $testOBJ

ilObjTest ilTestRandomQuestionSetSourcePoolDefinitionList::$testOBJ
protected

◆ $trashedPools

array ilTestRandomQuestionSetSourcePoolDefinitionList::$trashedPools = array()
protected

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