ILIAS  trunk Revision v12.0_alpha-16-g3e876e53c80
SubitemPropertiesReader.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
25use ILIAS\Data\Factory as DataFactory;
26use ilLanguage;
29use Generator;
31use ilAccess;
33
35{
36 protected ilLanguage $lng;
37 protected DataFactory $data_factory;
38 protected ilAccess $access;
40
41 public static function type(): string
42 {
43 return 'exc';
44 }
45
46 public function init(Container $dic): void
47 {
48 $this->lng = $dic->language();
49 $this->lng->loadLanguageModule('exc');
50 $this->data_factory = new DataFactory();
51 $this->access = $dic->access();
52 $this->permanent_link = $dic->exercise()->internal()->gui()->permanentLink();
53 }
54
55 public function getSubitemProperties(
56 PropertiesFactory $factory,
57 int $parent_ref_id,
58 ID ...$subitem_ids
59 ): Generator {
60 foreach ($subitem_ids as $subitem_id) {
61 if (!$this->isAssignmentVisible($parent_ref_id, (int) $subitem_id->id())) {
62 continue;
63 }
64 $link = $this->data_factory->uri(
65 $this->permanent_link->getPermanentLink($parent_ref_id, (int) $subitem_id->id())
66 );
67 yield $factory->get(
68 $subitem_id,
69 ilExAssignment::lookupTitle((int) $subitem_id->id()),
70 $link,
71 false,
72 $this->lng->txt('exc_assignment')
73 );
74 }
75 }
76
77 protected function isAssignmentVisible(
78 int $ref_id,
79 int $subitem_id
80 ): bool {
81 if ($this->access->checkAccess('write', '', $ref_id)) {
82 return true;
83 }
85 }
86}
Customizing of pimple-DIC for ILIAS.
Definition: Container.php:36
access()
Get interface for access checks.
Definition: Container.php:79
language()
Get interface to the i18n service.
Definition: Container.php:95
Builds data types.
Definition: Factory.php:36
getSubitemProperties(PropertiesFactory $factory, int $parent_ref_id, ID ... $subitem_ids)
Order of the output should respect the order of the subitem_ids.
Class ilAccessHandler Checks access for ILIAS objects.
Exercise assignment.
static lookupAssignmentOnline(int $a_ass_id)
static lookupTitle(int $a_id)
language handling
get(ID $id, string $title, ?URI $link_to_subitem, bool $open_link_in_new_viewport, string $presentable_subitem_type)
$ref_id
Definition: ltiauth.php:66
$dic
Definition: ltiresult.php:33
if(!file_exists('../ilias.ini.php'))