19 declare(strict_types=1);
41 return new class ($deactivation_entries) extends
NullGateway {
43 public array $exposed_deactivation_entries
47 public function createDeactivationEntry(
SlotIdentifier $slot):
void 49 $this->exposed_deactivation_entries[] = $slot;
52 public function deleteDeactivationEntry(
SlotIdentifier $slot):
void 54 if (!in_array($slot, $this->exposed_deactivation_entries)) {
57 unset($this->exposed_deactivation_entries[array_search($slot, $this->exposed_deactivation_entries)]);
60 public function doesDeactivationEntryExistForSlot(
SlotIdentifier $slot):
bool 62 return in_array($slot, $this->exposed_deactivation_entries);
77 return new class ($slot, $values) extends
NullBuilder {
78 protected bool $active =
true;
82 protected array $values
89 $clone->active = !$deactivated;
95 return new class ($this->slot, $this->active, $this->values) extends
NullVocabulary {
98 protected bool $active,
99 protected array $values
108 public function isActive():
bool 110 return $this->active;
114 public function values(): \Generator
116 yield
from $this->values;
128 public function __construct(
protected array $assignments)
134 return array_key_exists($slot->value, $this->assignments);
139 yield
from $this->assignments[$slot->value] ?? [];
147 public function txt(
string $key):
string 149 return 'translated ' . $key;
157 bool $expected_active,
158 string ...$expected_values
160 $this->assertSame($expected_slot, $vocabulary->
slot());
164 'Vocab for slot ' . $expected_slot->value .
' activation should be ' . $expected_active
168 iterator_to_array($vocabulary->
values()),
169 'Vocab for slot ' . $expected_slot->value .
' values not correct.' 174 array $expected_content,
175 array $deactivated_slots,
178 $this->assertCount(count($expected_content), $vocabularies);
181 foreach ($expected_content as $expected_slot => $expected_values) {
186 !in_array($slot, $deactivated_slots),
195 $already_deactivated = [
196 SlotIdentifier::EDUCATIONAL_DIFFICULTY,
197 SlotIdentifier::CLASSIFICATION_PURPOSE
200 $gateway = $this->
getGateway(...$already_deactivated),
208 $already_deactivated,
209 $gateway->exposed_deactivation_entries
215 $already_deactivated = [
216 SlotIdentifier::EDUCATIONAL_DIFFICULTY,
217 SlotIdentifier::CLASSIFICATION_PURPOSE
220 $gateway = $this->
getGateway(...$already_deactivated),
225 $repo->deactivateVocabulary(SlotIdentifier::EDUCATIONAL_DIFFICULTY);
228 $already_deactivated,
229 $gateway->exposed_deactivation_entries
235 $already_deactivated = [
236 SlotIdentifier::EDUCATIONAL_DIFFICULTY,
237 SlotIdentifier::CLASSIFICATION_PURPOSE
240 $gateway = $this->
getGateway(...$already_deactivated),
245 $repo->deactivateVocabulary(SlotIdentifier::GENERAL_STRUCTURE);
248 array_merge($already_deactivated, [SlotIdentifier::GENERAL_STRUCTURE]),
249 $gateway->exposed_deactivation_entries
255 $already_deactivated = [
256 SlotIdentifier::EDUCATIONAL_DIFFICULTY,
257 SlotIdentifier::CLASSIFICATION_PURPOSE
260 $gateway = $this->
getGateway(...$already_deactivated),
268 $already_deactivated,
269 $gateway->exposed_deactivation_entries
275 $already_deactivated = [
276 SlotIdentifier::EDUCATIONAL_DIFFICULTY,
277 SlotIdentifier::CLASSIFICATION_PURPOSE
280 $gateway = $this->
getGateway(...$already_deactivated),
285 $repo->activateVocabulary(SlotIdentifier::CLASSIFICATION_PURPOSE);
288 [SlotIdentifier::EDUCATIONAL_DIFFICULTY],
289 $gateway->exposed_deactivation_entries
295 $already_deactivated = [
296 SlotIdentifier::EDUCATIONAL_DIFFICULTY,
297 SlotIdentifier::CLASSIFICATION_PURPOSE
300 $gateway = $this->
getGateway(...$already_deactivated),
305 $repo->activateVocabulary(SlotIdentifier::GENERAL_STRUCTURE);
308 $already_deactivated,
309 $gateway->exposed_deactivation_entries
315 $already_deactivated = [
316 SlotIdentifier::EDUCATIONAL_DIFFICULTY,
317 SlotIdentifier::CLASSIFICATION_PURPOSE
320 $gateway = $this->
getGateway(...$already_deactivated),
325 $this->assertTrue($repo->isVocabularyActive(SlotIdentifier::GENERAL_STRUCTURE));
330 $already_deactivated = [
331 SlotIdentifier::EDUCATIONAL_DIFFICULTY,
332 SlotIdentifier::CLASSIFICATION_PURPOSE
335 $gateway = $this->
getGateway(...$already_deactivated),
340 $this->assertFalse($repo->isVocabularyActive(SlotIdentifier::EDUCATIONAL_DIFFICULTY));
349 SlotIdentifier::EDUCATIONAL_DIFFICULTY->value => [
'value 1',
'value 2'],
350 SlotIdentifier::CLASSIFICATION_PURPOSE->value => [
'value 3',
'value 4']
354 $vocab = $repo->getVocabulary(SlotIdentifier::LIFECYCLE_STATUS);
356 $this->assertEmpty(iterator_to_array(
$vocab->values()));
365 SlotIdentifier::EDUCATIONAL_DIFFICULTY->value => [
'value 1',
'value 2'],
366 SlotIdentifier::CLASSIFICATION_PURPOSE->value => [
'value 3',
'value 4']
370 $vocab = $repo->getVocabulary(SlotIdentifier::EDUCATIONAL_DIFFICULTY);
371 $this->assertSame(SlotIdentifier::EDUCATIONAL_DIFFICULTY,
$vocab->slot());
372 $this->assertSame([
'value 1',
'value 2'], iterator_to_array(
$vocab->values()));
373 $this->assertTrue(
$vocab->isActive());
379 $gateway = $this->
getGateway(SlotIdentifier::EDUCATIONAL_DIFFICULTY),
382 SlotIdentifier::EDUCATIONAL_DIFFICULTY->value => [
'value 1',
'value 2'],
383 SlotIdentifier::CLASSIFICATION_PURPOSE->value => [
'value 3',
'value 4']
387 $vocab = $repo->getVocabulary(SlotIdentifier::EDUCATIONAL_DIFFICULTY);
388 $this->assertSame(SlotIdentifier::EDUCATIONAL_DIFFICULTY,
$vocab->slot());
389 $this->assertSame([
'value 1',
'value 2'], iterator_to_array(
$vocab->values()));
390 $this->assertFalse(
$vocab->isActive());
397 SlotIdentifier::EDUCATIONAL_DIFFICULTY,
398 SlotIdentifier::LIFECYCLE_STATUS
402 SlotIdentifier::EDUCATIONAL_DIFFICULTY->value => [
'value 1',
'value 2'],
403 SlotIdentifier::CLASSIFICATION_PURPOSE->value => [
'value 3',
'value 4'],
404 SlotIdentifier::LIFECYCLE_STATUS->value => [
'value 5',
'value 6']
408 $vocabs = $repo->getVocabularies(SlotIdentifier::GENERAL_STRUCTURE);
410 $this->assertNull($vocabs->current());
415 $expected_content = [
416 SlotIdentifier::EDUCATIONAL_DIFFICULTY->value => [
'value 1',
'value 2'],
417 SlotIdentifier::CLASSIFICATION_PURPOSE->value => [
'value 3',
'value 4'],
418 SlotIdentifier::LIFECYCLE_STATUS->value => [
'value 5',
'value 6']
420 $deactivated_slots = [
421 SlotIdentifier::EDUCATIONAL_DIFFICULTY,
422 SlotIdentifier::LIFECYCLE_STATUS
426 $gateway = $this->
getGateway(...$deactivated_slots),
431 $vocabs = $repo->getVocabularies(
432 SlotIdentifier::GENERAL_STRUCTURE,
433 SlotIdentifier::LIFECYCLE_STATUS,
434 SlotIdentifier::CLASSIFICATION_PURPOSE
439 SlotIdentifier::LIFECYCLE_STATUS->value => [
'value 5',
'value 6'],
440 SlotIdentifier::CLASSIFICATION_PURPOSE->value => [
'value 3',
'value 4']
451 SlotIdentifier::EDUCATIONAL_DIFFICULTY,
452 SlotIdentifier::LIFECYCLE_STATUS
456 SlotIdentifier::EDUCATIONAL_DIFFICULTY->value => [
'value 1',
'value 2'],
457 SlotIdentifier::CLASSIFICATION_PURPOSE->value => [
'value 3',
'value 4'],
458 SlotIdentifier::LIFECYCLE_STATUS->value => [
'value 5',
'value 6']
462 $vocabs = $repo->getActiveVocabularies(SlotIdentifier::GENERAL_STRUCTURE);
464 $this->assertNull($vocabs->current());
469 $expected_content = [
470 SlotIdentifier::EDUCATIONAL_DIFFICULTY->value => [
'value 1',
'value 2'],
471 SlotIdentifier::CLASSIFICATION_PURPOSE->value => [
'value 3',
'value 4'],
472 SlotIdentifier::LIFECYCLE_STATUS->value => [
'value 5',
'value 6'],
473 SlotIdentifier::TECHNICAL_REQUIREMENT_BROWSER->value => [
'value 7',
'value 8']
475 $deactivated_slots = [
476 SlotIdentifier::EDUCATIONAL_DIFFICULTY,
477 SlotIdentifier::LIFECYCLE_STATUS
481 $gateway = $this->
getGateway(...$deactivated_slots),
486 $vocabs = $repo->getActiveVocabularies(
487 SlotIdentifier::TECHNICAL_REQUIREMENT_BROWSER,
488 SlotIdentifier::GENERAL_STRUCTURE,
489 SlotIdentifier::LIFECYCLE_STATUS,
490 SlotIdentifier::CLASSIFICATION_PURPOSE
495 SlotIdentifier::TECHNICAL_REQUIREMENT_BROWSER->value => [
'value 7',
'value 8'],
496 SlotIdentifier::CLASSIFICATION_PURPOSE->value => [
'value 3',
'value 4']
506 SlotIdentifier::EDUCATIONAL_DIFFICULTY->value => [
'value 1',
'value 2',
'ProblemStatement',
'ispartof'],
515 $labelled_values = $repo->getLabelsForValues(
517 SlotIdentifier::EDUCATIONAL_DIFFICULTY,
525 $l1 = $labelled_values->current();
526 $this->assertSame(
'ispartof', $l1->value());
527 $this->assertSame(
'translated meta_is_part_of', $l1->label());
528 $labelled_values->next();
530 $l2 = $labelled_values->current();
531 $this->assertSame(
'value 2', $l2->value());
532 $this->assertSame(
'translated meta_value_2', $l2->label());
533 $labelled_values->next();
535 $l3 = $labelled_values->current();
536 $this->assertSame(
'ProblemStatement', $l3->value());
537 $this->assertSame(
'translated meta_problem_statement', $l3->label());
538 $labelled_values->next();
540 $this->assertNull($labelled_values->current());
546 SlotIdentifier::EDUCATIONAL_DIFFICULTY->value => [
'value 1',
'value 2',
'ProblemStatement',
'ispartof'],
555 $labelled_values = $repo->getLabelsForValues(
557 SlotIdentifier::EDUCATIONAL_DIFFICULTY,
565 $l1 = $labelled_values->current();
566 $this->assertSame(
'ispartof', $l1->value());
567 $this->assertSame(
'translated meta_is_part_of', $l1->label());
568 $labelled_values->next();
570 $l2 = $labelled_values->current();
571 $this->assertSame(
'value 2', $l2->value());
572 $this->assertSame(
'translated meta_value_2', $l2->label());
573 $labelled_values->next();
575 $l3 = $labelled_values->current();
576 $this->assertSame(
'ProblemStatement', $l3->value());
577 $this->assertSame(
'translated meta_problem_statement', $l3->label());
578 $labelled_values->next();
580 $this->assertNull($labelled_values->current());
586 SlotIdentifier::EDUCATIONAL_DIFFICULTY->value => [
'value 1',
'value 2',
'ProblemStatement',
'ispartof'],
590 $gateway = $this->
getGateway(SlotIdentifier::EDUCATIONAL_DIFFICULTY),
595 $labelled_values = $repo->getLabelsForValues(
597 SlotIdentifier::EDUCATIONAL_DIFFICULTY,
605 $this->assertNull($labelled_values->current());
standard()
description: > This is an example, of how the Notification Slate is generated by assigning Notificat...
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
__construct()
Constructor setup ILIAS global object public.