ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilTestRandomQuestionSetSourcePoolDefinitionList Class Reference
+ Inheritance diagram for ilTestRandomQuestionSetSourcePoolDefinitionList:
+ Collaboration diagram for ilTestRandomQuestionSetSourcePoolDefinitionList:

Public Member Functions

 __construct (ilDBInterface $db, ilObjTest $test_obj, ilTestRandomQuestionSetSourcePoolDefinitionFactory $source_pool_definition_factory)
 
 addDefinition (ilTestRandomQuestionSetSourcePoolDefinition $source_pool_definition)
 
 isLostPool (?int $pool_id)
 
 hasLostPool ()
 
 getLostPools ()
 
 getLostPool (int $pool_id)
 
 isTrashedPool (int $pool_id)
 
 hasTrashedPool ()
 
 getTrashedPools ()
 
 setTrashedPools (array $trashed_pools)
 
 hasDefinition (int $source_pool_definition_id)
 
 getDefinition (int $source_pool_definition_id)
 
 getDefinitionBySourcePoolId (int $source_pool_id)
 
 getDefinitionIds ()
 
 getDefinitionCount ()
 
 loadDefinitions ()
 
 saveDefinitions ()
 
 deleteDefinitions ()
 
 getNextPosition ()
 
 getInvolvedSourcePoolIds ()
 
 getQuestionAmount ()
 
 savedDefinitionsExist ()
 
 hasTaxonomyFilters ()
 
 hasTypeFilters ()
 
 areAllUsedPoolsAvailable ()
 
 rewind ()
 
 current ()
 
 key ()
 
 next ()
 
 valid ()
 
 getNonAvailablePools ()
 

Protected Member Functions

 addLostPool (ilTestRandomQuestionSetNonAvailablePool $lost_pool)
 

Protected Attributes

ilDBInterface $db
 
ilObjTest $test_obj
 
array $lost_pools = []
 
array $trashed_pools = []
 

Private Attributes

array $source_pool_definitions = []
 
ilTestRandomQuestionSetSourcePoolDefinitionFactory $source_pool_definition_factory
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilTestRandomQuestionSetSourcePoolDefinitionList::__construct ( ilDBInterface  $db,
ilObjTest  $test_obj,
ilTestRandomQuestionSetSourcePoolDefinitionFactory  $source_pool_definition_factory 
)

Member Function Documentation

◆ addDefinition()

ilTestRandomQuestionSetSourcePoolDefinitionList::addDefinition ( ilTestRandomQuestionSetSourcePoolDefinition  $source_pool_definition)

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

44 {
45 $this->source_pool_definitions[ $source_pool_definition->getId() ] = $source_pool_definition;
46 }

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  $lost_pool)
protected

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

49 {
50 $this->lost_pools[$lost_pool->getId()] = $lost_pool;
51 }

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

319 : bool
320 {
321 if ($this->hasLostPool()) {
322 return false;
323 }
324
325 if ($this->hasTrashedPool()) {
326 return false;
327 }
328
329 return true;
330 }

References hasLostPool(), and hasTrashedPool().

+ Here is the call graph for this function:

◆ current()

ilTestRandomQuestionSetSourcePoolDefinitionList::current ( )

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

230 : void
231 {
232 $query = "DELETE FROM tst_rnd_quest_set_qpls WHERE test_fi = %s";
233 $this->db->manipulateF($query, ['integer'], [$this->test_obj->getTestId()]);
234 }

◆ getDefinition()

ilTestRandomQuestionSetSourcePoolDefinitionList::getDefinition ( int  $source_pool_definition_id)

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

105 {
106 if (isset($this->source_pool_definitions[$source_pool_definition_id])) {
107 return $this->source_pool_definitions[$source_pool_definition_id];
108 }
109
110 return null;
111 }

Referenced by hasDefinition().

+ Here is the caller graph for this function:

◆ getDefinitionBySourcePoolId()

ilTestRandomQuestionSetSourcePoolDefinitionList::getDefinitionBySourcePoolId ( int  $source_pool_id)

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

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

◆ getDefinitionCount()

ilTestRandomQuestionSetSourcePoolDefinitionList::getDefinitionCount ( )

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

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

◆ getDefinitionIds()

ilTestRandomQuestionSetSourcePoolDefinitionList::getDefinitionIds ( )

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

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

◆ getInvolvedSourcePoolIds()

ilTestRandomQuestionSetSourcePoolDefinitionList::getInvolvedSourcePoolIds ( )

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

263 : array
264 {
265 $involved_source_pool_ids = [];
266
267 foreach ($this as $definition) {
268 $involved_source_pool_ids[ $definition->getPoolId() ] = $definition->getPoolId();
269 }
270
271 return array_values($involved_source_pool_ids);
272 }

Referenced by ilTestRandomQuestionSetStagingPoolBuilder\build().

+ Here is the caller graph for this function:

◆ getLostPool()

ilTestRandomQuestionSetSourcePoolDefinitionList::getLostPool ( int  $pool_id)

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

69 {
70 if ($this->isLostPool($pool_id)) {
71 return $this->lost_pools[$pool_id];
72 }
73
74 return null;
75 }

References isLostPool().

+ Here is the call graph for this function:

◆ getLostPools()

ilTestRandomQuestionSetSourcePoolDefinitionList::getLostPools ( )

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

References $lost_pools.

Referenced by getNonAvailablePools().

+ Here is the caller graph for this function:

◆ getNextPosition()

ilTestRandomQuestionSetSourcePoolDefinitionList::getNextPosition ( )

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

258 : int
259 {
260 return (count($this->source_pool_definitions) + 1);
261 }

◆ getNonAvailablePools()

ilTestRandomQuestionSetSourcePoolDefinitionList::getNonAvailablePools ( )

◆ getQuestionAmount()

ilTestRandomQuestionSetSourcePoolDefinitionList::getQuestionAmount ( )

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

274 : ?int
275 {
276 $question_amount = 0;
277
278 foreach ($this as $definition) {
279 $question_amount += $definition->getQuestionAmount();
280 }
281
282 return $question_amount;
283 }

◆ getTrashedPools()

ilTestRandomQuestionSetSourcePoolDefinitionList::getTrashedPools ( )

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

References $trashed_pools.

Referenced by getNonAvailablePools().

+ Here is the caller graph for this function:

◆ hasDefinition()

ilTestRandomQuestionSetSourcePoolDefinitionList::hasDefinition ( int  $source_pool_definition_id)

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

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

References getDefinition().

+ Here is the call graph for this function:

◆ hasLostPool()

ilTestRandomQuestionSetSourcePoolDefinitionList::hasLostPool ( )

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

58 : bool
59 {
60 return (bool) count($this->lost_pools);
61 }

Referenced by areAllUsedPoolsAvailable().

+ Here is the caller graph for this function:

◆ hasTaxonomyFilters()

ilTestRandomQuestionSetSourcePoolDefinitionList::hasTaxonomyFilters ( )

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

298 : bool
299 {
300 foreach ($this as $definition) {
301 if (count($definition->getMappedTaxonomyFilter())) {
302 return true;
303 }
304 }
305
306 return false;
307 }

◆ hasTrashedPool()

ilTestRandomQuestionSetSourcePoolDefinitionList::hasTrashedPool ( )

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

82 : bool
83 {
84 return (bool) count($this->trashed_pools);
85 }

Referenced by areAllUsedPoolsAvailable().

+ Here is the caller graph for this function:

◆ hasTypeFilters()

ilTestRandomQuestionSetSourcePoolDefinitionList::hasTypeFilters ( )

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

309 : bool
310 {
311 foreach ($this as $definition) {
312 if (count($definition->getTypeFilter())) {
313 return true;
314 }
315 }
316 return false;
317 }

◆ isLostPool()

ilTestRandomQuestionSetSourcePoolDefinitionList::isLostPool ( ?int  $pool_id)

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

53 : bool
54 {
55 return isset($this->lost_pools[$pool_id]);
56 }

Referenced by getLostPool(), and loadDefinitions().

+ Here is the caller graph for this function:

◆ isTrashedPool()

ilTestRandomQuestionSetSourcePoolDefinitionList::isTrashedPool ( int  $pool_id)

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

77 : bool
78 {
79 return isset($this->trashed_pools[$pool_id]);
80 }

◆ key()

ilTestRandomQuestionSetSourcePoolDefinitionList::key ( )

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

343 : ?int
344 {
345 return key($this->source_pool_definitions);
346 }

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

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

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

+ Here is the call graph for this function:

◆ next()

ilTestRandomQuestionSetSourcePoolDefinitionList::next ( )

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

348 : void
349 {
350 next($this->source_pool_definitions);
351 }

References next().

Referenced by next().

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

◆ rewind()

ilTestRandomQuestionSetSourcePoolDefinitionList::rewind ( )

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

332 : void
333 {
334 reset($this->source_pool_definitions);
335 }

◆ savedDefinitionsExist()

ilTestRandomQuestionSetSourcePoolDefinitionList::savedDefinitionsExist ( )
Returns
bool

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

288 : bool
289 {
290 $query = "SELECT COUNT(*) cnt FROM tst_rnd_quest_set_qpls WHERE test_fi = %s";
291 $res = $this->db->queryF($query, ['integer'], [$this->test_obj->getTestId()]);
292
293 $row = $this->db->fetchAssoc($res);
294
295 return $row['cnt'] > 0;
296 }

References $res.

◆ saveDefinitions()

ilTestRandomQuestionSetSourcePoolDefinitionList::saveDefinitions ( )

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

206 : void
207 {
208 foreach ($this as $source_pool_definition) {
209 $source_pool_definition->saveToDb();
210 }
211 }

◆ setTrashedPools()

ilTestRandomQuestionSetSourcePoolDefinitionList::setTrashedPools ( array  $trashed_pools)

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

92 : void
93 {
94 $this->trashed_pools = $trashed_pools;
95 }

References $trashed_pools.

Referenced by loadDefinitions().

+ Here is the caller graph for this function:

◆ valid()

ilTestRandomQuestionSetSourcePoolDefinitionList::valid ( )

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

353 : bool
354 {
355 return key($this->source_pool_definitions) !== null;
356 }

References key().

+ Here is the call graph for this function:

Field Documentation

◆ $db

ilDBInterface ilTestRandomQuestionSetSourcePoolDefinitionList::$db
protected

◆ $lost_pools

array ilTestRandomQuestionSetSourcePoolDefinitionList::$lost_pools = []
protected

◆ $source_pool_definition_factory

ilTestRandomQuestionSetSourcePoolDefinitionFactory ilTestRandomQuestionSetSourcePoolDefinitionList::$source_pool_definition_factory
private

◆ $source_pool_definitions

array ilTestRandomQuestionSetSourcePoolDefinitionList::$source_pool_definitions = []
private

◆ $test_obj

ilObjTest ilTestRandomQuestionSetSourcePoolDefinitionList::$test_obj
protected

◆ $trashed_pools

array ilTestRandomQuestionSetSourcePoolDefinitionList::$trashed_pools = []
protected

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