ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
ilTestRandomQuestionSetSourcePoolDefinition Class Reference
+ Inheritance diagram for ilTestRandomQuestionSetSourcePoolDefinition:
+ Collaboration diagram for ilTestRandomQuestionSetSourcePoolDefinition:

Public Member Functions

 __construct (protected ilDBInterface $db, protected ilObjTest $test_obj)
 
 setId (int $id)
 
 getId ()
 
 setPoolId (int $pool_id)
 
 getPoolId ()
 
 getPoolRefId ()
 
 setPoolRefId (?int $pool_ref_id)
 
 setPoolTitle (string $pool_title)
 
 getPoolTitle ()
 
 setPoolPath (string $pool_path)
 
 getPoolPath ()
 
 setPoolQuestionCount (?int $pool_question_count)
 
 getPoolQuestionCount ()
 
 getOriginalTaxonomyFilter ()
 
 setOriginalTaxonomyFilter (array $filter=[])
 
 getMappedTaxonomyFilter ()
 get the mapped taxonomy filter conditions More...
 
 setMappedTaxonomyFilter (array $filter=[])
 set the original taxonomy filter condition More...
 
 mapTaxonomyFilter (ilQuestionPoolDuplicatedTaxonomiesKeysMap $taxonomies_keys_map)
 
 setTypeFilter (array $type_filter=[])
 
 getTypeFilter ()
 
 getLifecycleFilter ()
 
 setLifecycleFilter (array $lifecycle_filter)
 
 getLifecycleFilterForDbValue ()
 
 setLifecycleFilterFromDbValue (?string $db_value)
 
 getTypeFilterAsTypeTags ()
 Get the type filter as a list of type tags. More...
 
 setTypeFilterFromTypeTags (array $tags)
 Set the type filter from a list of type tags. More...
 
 setQuestionAmount (?int $question_amount)
 
 getQuestionAmount ()
 
 setSequencePosition (int $sequence_position)
 
 getSequencePosition ()
 
 initFromArray (array $data_array)
 
 loadFromDb (int $id)
 
 saveToDb ()
 
 cloneToDbForTestId (int $test_id)
 
 deleteFromDb ()
 
 getPoolInfoLabel (ilLanguage $lng)
 
 toNormalized (Transformations $transformations, array $context=[])
 Convert the internal state of the implementing object into a language-neutral array structure. More...
 
 fromNormalized (array $normalized, Transformations $transformations)
 Restore the object from its normalized representation. More...
 
 toNormalized (Transformations $transformations, array $context=[])
 Convert the internal state of the implementing object into a language-neutral array structure. More...
 
 fromNormalized (array $normalized, Transformations $transformations)
 Restore the object from its normalized representation. More...
 

Private Member Functions

 getOriginalTaxonomyFilterForDbValue ()
 
 setOriginalTaxonomyFilterFromDbValue (?string $value)
 
 getMappedTaxonomyFilterForDbValue ()
 
 setMappedTaxonomyFilterFromDbValue (?string $value)
 
 getTypeFilterForDbValue ()
 get the question type filter for insert into the database More...
 
 setTypeFilterFromDbValue (?string $value)
 get the question type filter from database value More...
 
 updateDbRecord (int $test_id)
 
 insertDbRecord (int $test_id)
 

Private Attributes

int $id = null
 
int $pool_id = null
 
int $pool_ref_id = null
 
string $pool_title = ''
 
string $pool_path = ''
 
int $pool_question_count = null
 
array $original_taxonomy_filter = []
 
array $mapped_taxonomy_filter = []
 
array $type_filter = []
 
array $lifecycle_filter = []
 
int $question_amount = null
 
int $sequence_position = null
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilTestRandomQuestionSetSourcePoolDefinition::__construct ( protected ilDBInterface  $db,
protected ilObjTest  $test_obj 
)

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

61 {
62 }

Member Function Documentation

◆ cloneToDbForTestId()

ilTestRandomQuestionSetSourcePoolDefinition::cloneToDbForTestId ( int  $test_id)

Definition at line 394 of file class.ilTestRandomQuestionSetSourcePoolDefinition.php.

394 : void
395 {
396 $this->insertDbRecord($test_id);
397 }

References insertDbRecord().

+ Here is the call graph for this function:

◆ deleteFromDb()

ilTestRandomQuestionSetSourcePoolDefinition::deleteFromDb ( )

Definition at line 399 of file class.ilTestRandomQuestionSetSourcePoolDefinition.php.

399 : void
400 {
401 $this->db->manipulateF(
402 "DELETE FROM tst_rnd_quest_set_qpls WHERE def_id = %s",
403 ['integer'],
404 [$this->getId()]
405 );
406 }

References getId().

+ Here is the call graph for this function:

◆ fromNormalized()

ilTestRandomQuestionSetSourcePoolDefinition::fromNormalized ( array  $normalized,
Transformations  $transformations 
)

Restore the object from its normalized representation.

Parameters
array<array-key,mixed>$normalized

Implements ILIAS\TestQuestionPool\ExportImport\Foundation\Normalize\FromNormalized.

Definition at line 521 of file class.ilTestRandomQuestionSetSourcePoolDefinition.php.

524 : static {
525 $clone = clone $this;
526 $clone->setId($transformations->denormalize($normalized['id'], Id::class)->getId());
527 $clone->setPoolId($transformations->denormalize($normalized['pool_id'], Id::class)->getId());
528 $clone->setPoolTitle($transformations->string($normalized['pool_title']));
529 $clone->setPoolPath($transformations->string($normalized['pool_path']));
530 $clone->setQuestionAmount($transformations->nullableInt($normalized['quest_amount']));
531 $clone->setPoolQuestionCount($transformations->nullableInt($normalized['pool_quest_count']));
532 $clone->setSequencePosition($transformations->int($normalized['position']));
533 $clone->setTypeFilterFromTypeTags($normalized['type_filter']);
534 $clone->setLifecycleFilter($normalized['lifecycle_filter']);
535
536 $taxonomy_filter = [];
537 foreach ($normalized['taxonomy_filter'] as $item) {
538 $tax_id = $transformations->denormalize($item['tax_id'], Id::class)->getId();
539 $taxonomy_filter[$tax_id] = array_map(
540 static fn($node_id): mixed => $transformations->denormalize($node_id, Id::class)->getId(),
541 $item['node_ids']
542 );
543 }
544 $clone->setOriginalTaxonomyFilter($taxonomy_filter);
545
547 foreach (($normalized['mapped_taxonomy_filter'] ?? []) as $item) {
548 $tax_id = $transformations->denormalize($item['tax_id'], Id::class)->getId();
549 $mapped_taxonomy_filter[$tax_id] = array_map(
550 static fn($node_id): mixed => $transformations->denormalize($node_id, Id::class)->getId(),
551 $item['node_ids']
552 );
553 }
554 $clone->setMappedTaxonomyFilter($mapped_taxonomy_filter);
555
556 return $clone;
557 }
denormalize(array|float|bool|int|string|null $normalized, string|object $expected)

References ILIAS\TestQuestionPool\ExportImport\Foundation\Normalize\Transformations\denormalize().

+ Here is the call graph for this function:

◆ getId()

◆ getLifecycleFilter()

ilTestRandomQuestionSetSourcePoolDefinition::getLifecycleFilter ( )

◆ getLifecycleFilterForDbValue()

ilTestRandomQuestionSetSourcePoolDefinition::getLifecycleFilterForDbValue ( )

Definition at line 250 of file class.ilTestRandomQuestionSetSourcePoolDefinition.php.

250 : ?string
251 {
252 return empty($this->lifecycle_filter) ? null : serialize($this->lifecycle_filter);
253 }

Referenced by insertDbRecord(), and updateDbRecord().

+ Here is the caller graph for this function:

◆ getMappedTaxonomyFilter()

ilTestRandomQuestionSetSourcePoolDefinition::getMappedTaxonomyFilter ( )

get the mapped taxonomy filter conditions

Returns
array taxId => [nodeId, ...]

Definition at line 150 of file class.ilTestRandomQuestionSetSourcePoolDefinition.php.

150 : array
151 {
153 }

References $mapped_taxonomy_filter.

Referenced by ilTestRandomQuestionSetBuilder\getQuestionIdsForSourcePoolDefinitionIds(), and ilTestRandomQuestionSetBuilder\hasTaxonomyFilter().

+ Here is the caller graph for this function:

◆ getMappedTaxonomyFilterForDbValue()

ilTestRandomQuestionSetSourcePoolDefinition::getMappedTaxonomyFilterForDbValue ( )
private

Definition at line 168 of file class.ilTestRandomQuestionSetSourcePoolDefinition.php.

168 : ?string
169 {
170 return empty($this->mapped_taxonomy_filter) ? null : serialize($this->mapped_taxonomy_filter);
171 }

Referenced by insertDbRecord(), and updateDbRecord().

+ Here is the caller graph for this function:

◆ getOriginalTaxonomyFilter()

ilTestRandomQuestionSetSourcePoolDefinition::getOriginalTaxonomyFilter ( )

◆ getOriginalTaxonomyFilterForDbValue()

ilTestRandomQuestionSetSourcePoolDefinition::getOriginalTaxonomyFilterForDbValue ( )
private

Definition at line 134 of file class.ilTestRandomQuestionSetSourcePoolDefinition.php.

134 : ?string
135 {
136 // TODO-RND2017: migrate to separate table for common selections by e.g. statistics
137 return empty($this->original_taxonomy_filter) ? null : serialize($this->original_taxonomy_filter);
138 }

Referenced by insertDbRecord(), and updateDbRecord().

+ Here is the caller graph for this function:

◆ getPoolId()

ilTestRandomQuestionSetSourcePoolDefinition::getPoolId ( )

◆ getPoolInfoLabel()

ilTestRandomQuestionSetSourcePoolDefinition::getPoolInfoLabel ( ilLanguage  $lng)

Definition at line 457 of file class.ilTestRandomQuestionSetSourcePoolDefinition.php.

457 : string
458 {
459 $pool_path = $this->getPoolPath();
460 if (is_int($this->getPoolRefId()) && ilObject::_lookupObjId($this->getPoolRefId())) {
461 $path = new ilPathGUI();
462 $path->enableTextOnly(true);
463 $pool_path = $path->getPath(ROOT_FOLDER_ID, (int) $this->getPoolRefId());
464 }
465
466 $poolInfoLabel = sprintf(
467 $lng->txt('tst_random_question_set_source_questionpool_summary_string'),
468 $this->getPoolTitle(),
470 $this->getPoolQuestionCount()
471 );
472
473 return $poolInfoLabel;
474 }
static _lookupObjId(int $ref_id)
const ROOT_FOLDER_ID
Definition: constants.php:32
global $lng
Definition: privfeed.php:26

References $lng, $pool_path, ilObject\_lookupObjId(), getPoolPath(), getPoolRefId(), and ROOT_FOLDER_ID.

Referenced by ilTestRandomQuestionSetPoolDefinitionFormGUI\build().

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

◆ getPoolPath()

ilTestRandomQuestionSetSourcePoolDefinition::getPoolPath ( )

Definition at line 109 of file class.ilTestRandomQuestionSetSourcePoolDefinition.php.

109 : string
110 {
111 return $this->pool_path;
112 }

References $pool_path.

Referenced by getPoolInfoLabel(), insertDbRecord(), and updateDbRecord().

+ Here is the caller graph for this function:

◆ getPoolQuestionCount()

ilTestRandomQuestionSetSourcePoolDefinition::getPoolQuestionCount ( )

Definition at line 119 of file class.ilTestRandomQuestionSetSourcePoolDefinition.php.

References $pool_question_count.

Referenced by insertDbRecord(), and updateDbRecord().

+ Here is the caller graph for this function:

◆ getPoolRefId()

ilTestRandomQuestionSetSourcePoolDefinition::getPoolRefId ( )

Definition at line 84 of file class.ilTestRandomQuestionSetSourcePoolDefinition.php.

References $pool_ref_id.

Referenced by getPoolInfoLabel(), insertDbRecord(), and updateDbRecord().

+ Here is the caller graph for this function:

◆ getPoolTitle()

ilTestRandomQuestionSetSourcePoolDefinition::getPoolTitle ( )

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

References $pool_title.

Referenced by insertDbRecord(), and updateDbRecord().

+ Here is the caller graph for this function:

◆ getQuestionAmount()

ilTestRandomQuestionSetSourcePoolDefinition::getQuestionAmount ( )

◆ getSequencePosition()

ilTestRandomQuestionSetSourcePoolDefinition::getSequencePosition ( )

Definition at line 315 of file class.ilTestRandomQuestionSetSourcePoolDefinition.php.

References $sequence_position.

Referenced by insertDbRecord(), and updateDbRecord().

+ Here is the caller graph for this function:

◆ getTypeFilter()

◆ getTypeFilterAsTypeTags()

ilTestRandomQuestionSetSourcePoolDefinition::getTypeFilterAsTypeTags ( )

Get the type filter as a list of type tags.

Returns
string[]

Definition at line 264 of file class.ilTestRandomQuestionSetSourcePoolDefinition.php.

264 : array
265 {
266 $map = [];
267 foreach (ilObjQuestionPool::_getQuestionTypes(true) as $row) {
268 $map[$row['question_type_id']] = $row['type_tag'];
269 }
270
271 $tags = [];
272 foreach ($this->type_filter as $type_id) {
273 if (isset($map[$type_id])) {
274 $tags[] = $map[$type_id];
275 }
276 }
277
278 return $tags;
279 }
static _getQuestionTypes($all_tags=false, $fixOrder=false, $withDeprecatedTypes=true)

References ilObjQuestionPool\_getQuestionTypes().

+ Here is the call graph for this function:

◆ getTypeFilterForDbValue()

ilTestRandomQuestionSetSourcePoolDefinition::getTypeFilterForDbValue ( )
private

get the question type filter for insert into the database

Definition at line 227 of file class.ilTestRandomQuestionSetSourcePoolDefinition.php.

227 : ?string
228 {
229 return empty($this->type_filter) ? null : serialize($this->type_filter);
230 }

Referenced by insertDbRecord(), and updateDbRecord().

+ Here is the caller graph for this function:

◆ initFromArray()

ilTestRandomQuestionSetSourcePoolDefinition::initFromArray ( array  $data_array)

Definition at line 322 of file class.ilTestRandomQuestionSetSourcePoolDefinition.php.

322 : void
323 {
324 foreach ($data_array as $field => $value) {
325 switch ($field) {
326 case 'def_id':
327 $this->setId($value);
328 break;
329 case 'pool_fi':
330 $this->setPoolId($value);
331 break;
332 case 'pool_ref_id':
333 $this->setPoolRefId($value ? (int) $value : null);
334 break;
335 case 'pool_title':
336 $this->setPoolTitle($value ?? '');
337 break;
338 case 'pool_path':
339 $this->setPoolPath($value);
340 break;
341 case 'pool_quest_count':
342 $this->setPoolQuestionCount($value);
343 break;
344 case 'origin_tax_filter':
346 break;
347 case 'mapped_tax_filter':
349 break;
350 case 'type_filter':
351 $this->setTypeFilterFromDbValue($value);
352 break;
353 case 'lifecycle_filter':
354 $this->setLifecycleFilterFromDbValue($value);
355 break;
356 // fau.
357 case 'quest_amount':
358 $this->setQuestionAmount($value);
359 break;
360 case 'sequence_pos':
361 $this->setSequencePosition($value);
362 break;
363 }
364 }
365 }
setTypeFilterFromDbValue(?string $value)
get the question type filter from database value

References setId(), setLifecycleFilterFromDbValue(), setMappedTaxonomyFilterFromDbValue(), setOriginalTaxonomyFilterFromDbValue(), setPoolId(), setPoolPath(), setPoolQuestionCount(), setPoolRefId(), setPoolTitle(), setQuestionAmount(), setSequencePosition(), and setTypeFilterFromDbValue().

Referenced by loadFromDb().

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

◆ insertDbRecord()

ilTestRandomQuestionSetSourcePoolDefinition::insertDbRecord ( int  $test_id)
private

Definition at line 432 of file class.ilTestRandomQuestionSetSourcePoolDefinition.php.

432 : void
433 {
434 $next_id = $this->db->nextId('tst_rnd_quest_set_qpls');
435
436 $this->db->insert('tst_rnd_quest_set_qpls', [
437 'def_id' => ['integer', $next_id],
438 'test_fi' => ['integer', $test_id],
439 'pool_fi' => ['integer', $this->getPoolId()],
440 'pool_ref_id' => ['integer', $this->getPoolRefId()],
441 'pool_title' => ['text', $this->getPoolTitle()],
442 'pool_path' => ['text', $this->getPoolPath()],
443 'pool_quest_count' => ['integer', $this->getPoolQuestionCount()],
444 'origin_tax_filter' => ['text', $this->getOriginalTaxonomyFilterForDbValue()],
445 'mapped_tax_filter' => ['text', $this->getMappedTaxonomyFilterForDbValue()],
446 'type_filter' => ['text', $this->getTypeFilterForDbValue()],
447 'lifecycle_filter' => ['text', $this->getLifecycleFilterForDbValue()],
448 'quest_amount' => ['integer', $this->getQuestionAmount()],
449 'sequence_pos' => ['integer', $this->getSequencePosition()]
450 ]);
451
452 $this->setId($next_id);
453 }
getTypeFilterForDbValue()
get the question type filter for insert into the database

References getLifecycleFilterForDbValue(), getMappedTaxonomyFilterForDbValue(), getOriginalTaxonomyFilterForDbValue(), getPoolId(), getPoolPath(), getPoolQuestionCount(), getPoolRefId(), getPoolTitle(), getQuestionAmount(), getSequencePosition(), getTypeFilterForDbValue(), and setId().

Referenced by cloneToDbForTestId(), and saveToDb().

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

◆ loadFromDb()

ilTestRandomQuestionSetSourcePoolDefinition::loadFromDb ( int  $id)

Definition at line 367 of file class.ilTestRandomQuestionSetSourcePoolDefinition.php.

367 : bool
368 {
369 $res = $this->db->queryF(
370 "SELECT * FROM tst_rnd_quest_set_qpls WHERE def_id = %s",
371 ['integer'],
372 [$id]
373 );
374
375 while ($row = $this->db->fetchAssoc($res)) {
376 $this->initFromArray($row);
377
378 return true;
379 }
380
381 return false;
382 }
foreach($_POST as $key=> $value) $res

References $id, $res, and initFromArray().

+ Here is the call graph for this function:

◆ mapTaxonomyFilter()

ilTestRandomQuestionSetSourcePoolDefinition::mapTaxonomyFilter ( ilQuestionPoolDuplicatedTaxonomiesKeysMap  $taxonomies_keys_map)

Definition at line 193 of file class.ilTestRandomQuestionSetSourcePoolDefinition.php.

193 : void
194 {
195 $this->mapped_taxonomy_filter = [];
196 foreach ($this->original_taxonomy_filter as $tax_id => $node_ids) {
197 $mapped_node_ids = [];
198
199 $mapped_taxonomy_id = $taxonomies_keys_map->getMappedTaxonomyId($tax_id);
200 if ($mapped_taxonomy_id === null || $mapped_taxonomy_id < 1) {
201 continue;
202 }
203
204 foreach ($node_ids as $node_id) {
205 $mapped_node_id = $taxonomies_keys_map->getMappedTaxNodeId($node_id);
206 if ($mapped_node_id !== null) {
207 $mapped_node_ids[] = $mapped_node_id;
208 }
209 }
210 $this->mapped_taxonomy_filter[$mapped_taxonomy_id] = $mapped_node_ids;
211 }
212 }

References ilQuestionPoolDuplicatedTaxonomiesKeysMap\getMappedTaxNodeId(), and ilQuestionPoolDuplicatedTaxonomiesKeysMap\getMappedTaxonomyId().

+ Here is the call graph for this function:

◆ saveToDb()

ilTestRandomQuestionSetSourcePoolDefinition::saveToDb ( )

Definition at line 384 of file class.ilTestRandomQuestionSetSourcePoolDefinition.php.

384 : void
385 {
386 if ($this->getId()) {
387 $this->updateDbRecord($this->test_obj->getTestId());
388 return;
389 }
390
391 $this->insertDbRecord($this->test_obj->getTestId());
392 }

References getId(), insertDbRecord(), and updateDbRecord().

+ Here is the call graph for this function:

◆ setId()

ilTestRandomQuestionSetSourcePoolDefinition::setId ( int  $id)

Definition at line 64 of file class.ilTestRandomQuestionSetSourcePoolDefinition.php.

64 : void
65 {
66 $this->id = $id;
67 }

References $id.

Referenced by initFromArray(), and insertDbRecord().

+ Here is the caller graph for this function:

◆ setLifecycleFilter()

ilTestRandomQuestionSetSourcePoolDefinition::setLifecycleFilter ( array  $lifecycle_filter)

Definition at line 245 of file class.ilTestRandomQuestionSetSourcePoolDefinition.php.

245 : void
246 {
247 $this->lifecycle_filter = $lifecycle_filter;
248 }

References $lifecycle_filter.

◆ setLifecycleFilterFromDbValue()

ilTestRandomQuestionSetSourcePoolDefinition::setLifecycleFilterFromDbValue ( ?string  $db_value)

Definition at line 255 of file class.ilTestRandomQuestionSetSourcePoolDefinition.php.

256 {
257 $this->lifecycle_filter = empty($db_value) ? [] : unserialize($db_value);
258 }

Referenced by initFromArray().

+ Here is the caller graph for this function:

◆ setMappedTaxonomyFilter()

ilTestRandomQuestionSetSourcePoolDefinition::setMappedTaxonomyFilter ( array  $filter = [])

set the original taxonomy filter condition

Parameters
arraytaxId => [nodeId, ...]

Definition at line 159 of file class.ilTestRandomQuestionSetSourcePoolDefinition.php.

159 : void
160 {
161 $this->mapped_taxonomy_filter = array_filter(
162 $filter,
163 static fn(mixed $value, int|string $key): bool => (int) $key > 0 || !is_array($value),
164 ARRAY_FILTER_USE_BOTH
165 );
166 }

Referenced by ilObjTestXMLParser\importRandomQuestionSourcePoolDefinition(), and setMappedTaxonomyFilterFromDbValue().

+ Here is the caller graph for this function:

◆ setMappedTaxonomyFilterFromDbValue()

ilTestRandomQuestionSetSourcePoolDefinition::setMappedTaxonomyFilterFromDbValue ( ?string  $value)
private

Definition at line 173 of file class.ilTestRandomQuestionSetSourcePoolDefinition.php.

173 : void
174 {
175 $this->mapped_taxonomy_filter = [];
176 if ($value === null || $value === '') {
177 return;
178 }
179
180 $filter = unserialize($value, ['allowed_classes' => false]);
181 if (!is_array($filter)) {
182 return;
183 }
184
186 foreach ($filter as $tax_id => $node_ids) {
187 $mapped_taxonomy_filter[$tax_id] = $node_ids;
188 }
189
191 }
setMappedTaxonomyFilter(array $filter=[])
set the original taxonomy filter condition

References $mapped_taxonomy_filter, and setMappedTaxonomyFilter().

Referenced by initFromArray().

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

◆ setOriginalTaxonomyFilter()

ilTestRandomQuestionSetSourcePoolDefinition::setOriginalTaxonomyFilter ( array  $filter = [])

Definition at line 129 of file class.ilTestRandomQuestionSetSourcePoolDefinition.php.

129 : void
130 {
131 $this->original_taxonomy_filter = $filter;
132 }

◆ setOriginalTaxonomyFilterFromDbValue()

ilTestRandomQuestionSetSourcePoolDefinition::setOriginalTaxonomyFilterFromDbValue ( ?string  $value)
private

Definition at line 140 of file class.ilTestRandomQuestionSetSourcePoolDefinition.php.

140 : void
141 {
142 // TODO-RND2017: migrate to separate table for common selections by e.g. statistics
143 $this->original_taxonomy_filter = empty($value) ? [] : unserialize($value);
144 }

Referenced by initFromArray().

+ Here is the caller graph for this function:

◆ setPoolId()

ilTestRandomQuestionSetSourcePoolDefinition::setPoolId ( int  $pool_id)

Definition at line 74 of file class.ilTestRandomQuestionSetSourcePoolDefinition.php.

74 : void
75 {
76 $this->pool_id = $pool_id;
77 }

References $pool_id.

Referenced by ilObjTestXMLParser\importRandomQuestionSourcePoolDefinition(), and initFromArray().

+ Here is the caller graph for this function:

◆ setPoolPath()

ilTestRandomQuestionSetSourcePoolDefinition::setPoolPath ( string  $pool_path)

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

104 : void
105 {
106 $this->pool_path = $pool_path;
107 }

References $pool_path.

Referenced by initFromArray().

+ Here is the caller graph for this function:

◆ setPoolQuestionCount()

ilTestRandomQuestionSetSourcePoolDefinition::setPoolQuestionCount ( ?int  $pool_question_count)

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

114 : void
115 {
116 $this->pool_question_count = $pool_question_count;
117 }

References $pool_question_count.

Referenced by ilObjTestXMLParser\importRandomQuestionSourcePoolDefinition(), and initFromArray().

+ Here is the caller graph for this function:

◆ setPoolRefId()

ilTestRandomQuestionSetSourcePoolDefinition::setPoolRefId ( ?int  $pool_ref_id)

◆ setPoolTitle()

ilTestRandomQuestionSetSourcePoolDefinition::setPoolTitle ( string  $pool_title)

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

94 : void
95 {
96 $this->pool_title = $pool_title;
97 }

References $pool_title.

Referenced by initFromArray().

+ Here is the caller graph for this function:

◆ setQuestionAmount()

ilTestRandomQuestionSetSourcePoolDefinition::setQuestionAmount ( ?int  $question_amount)

Definition at line 300 of file class.ilTestRandomQuestionSetSourcePoolDefinition.php.

300 : void
301 {
302 $this->question_amount = $question_amount;
303 }

References $question_amount.

Referenced by ilObjTestXMLParser\importRandomQuestionSourcePoolDefinition(), and initFromArray().

+ Here is the caller graph for this function:

◆ setSequencePosition()

ilTestRandomQuestionSetSourcePoolDefinition::setSequencePosition ( int  $sequence_position)

Definition at line 310 of file class.ilTestRandomQuestionSetSourcePoolDefinition.php.

310 : void
311 {
312 $this->sequence_position = $sequence_position;
313 }

References $sequence_position.

Referenced by ilObjTestXMLParser\importRandomQuestionSourcePoolDefinition(), and initFromArray().

+ Here is the caller graph for this function:

◆ setTypeFilter()

ilTestRandomQuestionSetSourcePoolDefinition::setTypeFilter ( array  $type_filter = [])

Definition at line 214 of file class.ilTestRandomQuestionSetSourcePoolDefinition.php.

214 : void
215 {
216 $this->type_filter = $type_filter;
217 }

References $type_filter.

◆ setTypeFilterFromDbValue()

ilTestRandomQuestionSetSourcePoolDefinition::setTypeFilterFromDbValue ( ?string  $value)
private

get the question type filter from database value

Definition at line 235 of file class.ilTestRandomQuestionSetSourcePoolDefinition.php.

235 : void
236 {
237 $this->type_filter = empty($value) ? [] : unserialize($value);
238 }

Referenced by initFromArray().

+ Here is the caller graph for this function:

◆ setTypeFilterFromTypeTags()

ilTestRandomQuestionSetSourcePoolDefinition::setTypeFilterFromTypeTags ( array  $tags)

Set the type filter from a list of type tags.

Parameters
string[]$tags

Definition at line 285 of file class.ilTestRandomQuestionSetSourcePoolDefinition.php.

285 : void
286 {
287 $map = [];
288 foreach (ilObjQuestionPool::_getQuestionTypes(true) as $row) {
289 $map[$row['type_tag']] = $row['question_type_id'];
290 }
291
292 $this->type_filter = [];
293 foreach ($tags as $type_tag) {
294 if (isset($map[$type_tag])) {
295 $this->type_filter[] = $map[$type_tag];
296 }
297 }
298 }

References ilObjQuestionPool\_getQuestionTypes().

Referenced by ilObjTestXMLParser\importRandomQuestionSourcePoolDefinition().

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

◆ toNormalized()

ilTestRandomQuestionSetSourcePoolDefinition::toNormalized ( Transformations  $transformations,
array  $context = [] 
)

Convert the internal state of the implementing object into a language-neutral array structure.

The resulting array must contain only null, scalar values (string, int, float, bool) and nested arrays following the same rules.

Parameters
array<string,mixed>$context
Returns
array<array-key, mixed>|float|bool|int|string|null

Implements ILIAS\TestQuestionPool\ExportImport\Foundation\Normalize\ToNormalized.

Definition at line 479 of file class.ilTestRandomQuestionSetSourcePoolDefinition.php.

482 : array|float|bool|int|string|null {
483 $normalized = [
484 'id' => $transformations->normalize(new Id($this->getId(), 'rnd_src_pool_def')),
485 'pool_id' => $transformations->normalize(new Id($this->getPoolId(), 'qpl')),
486 'pool_title' => $this->getPoolTitle(),
487 'pool_path' => $this->getPoolPath(),
488 'quest_amount' => $this->getQuestionAmount(),
489 'pool_quest_count' => $this->getPoolQuestionCount(),
490 'position' => $this->getSequencePosition(),
491 'type_filter' => $this->getTypeFilterAsTypeTags(),
492 'lifecycle_filter' => $this->getLifecycleFilter(),
493 'taxonomy_filter' => [],
494 'mapped_taxonomy_filter' => [],
495 ];
496
497 foreach ($this->getOriginalTaxonomyFilter() as $tax_id => $node_ids) {
498 $normalized['taxonomy_filter'][] = [
499 'tax_id' => $transformations->normalize(new Id($tax_id, 'tax')),
500 'node_ids' => array_map(
501 static fn($node_id): mixed => $transformations->normalize(new Id($node_id, 'tax_node')),
502 $node_ids
503 ),
504 ];
505 }
506
507 foreach ($this->getMappedTaxonomyFilter() as $tax_id => $node_ids) {
508 $normalized['mapped_taxonomy_filter'][] = [
509 'tax_id' => $transformations->normalize(new Id($tax_id, 'mapped_tax')),
510 'node_ids' => array_map(
511 static fn($node_id): mixed => $transformations->normalize(new Id($node_id, 'mapped_tax_node')),
512 $node_ids
513 ),
514 ];
515 }
516
517 return $normalized;
518 }
Wrapper object for an object identifier and an optional object type the identifier belongs to.
Definition: Id.php:33

References ILIAS\TestQuestionPool\ExportImport\Foundation\Normalize\Transformations\normalize().

+ Here is the call graph for this function:

◆ updateDbRecord()

ilTestRandomQuestionSetSourcePoolDefinition::updateDbRecord ( int  $test_id)
private

Definition at line 408 of file class.ilTestRandomQuestionSetSourcePoolDefinition.php.

408 : void
409 {
410 $this->db->update(
411 'tst_rnd_quest_set_qpls',
412 [
413 'test_fi' => ['integer', $test_id],
414 'pool_fi' => ['integer', $this->getPoolId()],
415 'pool_ref_id' => ['integer', $this->getPoolRefId()],
416 'pool_title' => ['text', $this->getPoolTitle()],
417 'pool_path' => ['text', $this->getPoolPath()],
418 'pool_quest_count' => ['integer', $this->getPoolQuestionCount()],
419 'origin_tax_filter' => ['text', $this->getOriginalTaxonomyFilterForDbValue()],
420 'mapped_tax_filter' => ['text', $this->getMappedTaxonomyFilterForDbValue()],
421 'type_filter' => ['text', $this->getTypeFilterForDbValue()],
422 'lifecycle_filter' => ['text', $this->getLifecycleFilterForDbValue()],
423 'quest_amount' => ['integer', $this->getQuestionAmount()],
424 'sequence_pos' => ['integer', $this->getSequencePosition()]
425 ],
426 [
427 'def_id' => ['integer', $this->getId()]
428 ]
429 );
430 }

References getId(), getLifecycleFilterForDbValue(), getMappedTaxonomyFilterForDbValue(), getOriginalTaxonomyFilterForDbValue(), getPoolId(), getPoolPath(), getPoolQuestionCount(), getPoolRefId(), getPoolTitle(), getQuestionAmount(), getSequencePosition(), and getTypeFilterForDbValue().

Referenced by saveToDb().

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

Field Documentation

◆ $id

int ilTestRandomQuestionSetSourcePoolDefinition::$id = null
private

Definition at line 34 of file class.ilTestRandomQuestionSetSourcePoolDefinition.php.

Referenced by getId(), loadFromDb(), and setId().

◆ $lifecycle_filter

array ilTestRandomQuestionSetSourcePoolDefinition::$lifecycle_filter = []
private

◆ $mapped_taxonomy_filter

array ilTestRandomQuestionSetSourcePoolDefinition::$mapped_taxonomy_filter = []
private

◆ $original_taxonomy_filter

array ilTestRandomQuestionSetSourcePoolDefinition::$original_taxonomy_filter = []
private

◆ $pool_id

int ilTestRandomQuestionSetSourcePoolDefinition::$pool_id = null
private

Definition at line 35 of file class.ilTestRandomQuestionSetSourcePoolDefinition.php.

Referenced by getPoolId(), and setPoolId().

◆ $pool_path

string ilTestRandomQuestionSetSourcePoolDefinition::$pool_path = ''
private

◆ $pool_question_count

int ilTestRandomQuestionSetSourcePoolDefinition::$pool_question_count = null
private

◆ $pool_ref_id

int ilTestRandomQuestionSetSourcePoolDefinition::$pool_ref_id = null
private

◆ $pool_title

string ilTestRandomQuestionSetSourcePoolDefinition::$pool_title = ''
private

◆ $question_amount

int ilTestRandomQuestionSetSourcePoolDefinition::$question_amount = null
private

◆ $sequence_position

int ilTestRandomQuestionSetSourcePoolDefinition::$sequence_position = null
private

◆ $type_filter

array ilTestRandomQuestionSetSourcePoolDefinition::$type_filter = []
private

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