ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilTestExportOptionXMLRES.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
24use ILIAS\ResourceStorage\Services as ResourceStorage;
25use ILIAS\Data\Factory as DataFactory;
29use ILIAS\Export\ExportHandler\I\Consumer\Context\HandlerInterface as ilExportHandlerConsumerContextInterface;
31use ILIAS\Export\ExportHandler\I\Info\File\CollectionInterface as ilExportHandlerFileInfoCollectionInterface;
32use ILIAS\Export\ExportHandler\I\Consumer\File\Identifier\CollectionInterface as ilExportHandlerConsumerFileIdentifierCollectionInterface;
33use ILIAS\Export\ExportHandler\I\Consumer\File\Identifier\HandlerInterface as ilExportHandlerConsumerFileIdentifierInterface;
34
35class ilTestExportOptionXMLRES extends ilBasicExportOption
36{
37 public const OPTIONS_ID = 'test_exp_option_xmlres';
39 private ResourceStorage $irss;
40 private DataFactory $data_factory;
42
43 public function init(
45 ): void {
46 $this->lng = $DIC['lng'];
47 $this->irss = $DIC['resource_storage'];
48 $this->data_factory = new DataFactory();
49 $this->repository = TestDIC::dic()['exportimport.repository'];
50 }
51
52 public function getExportType(): string
53 {
54 return 'ZIP Results';
55 }
56
57 public function getExportOptionId(): string
58 {
59 return self::OPTIONS_ID;
60 }
61
62 public function getSupportedRepositoryObjectTypes(): array
63 {
64 return ['tst'];
65 }
66
67 public function getLabel(): string
68 {
69 $this->lng->loadLanguageModule('exp');
70 $this->lng->loadLanguageModule('assessment');
71 return $this->lng->txt("exp_format_dropdown-xml") . " (" . $this->lng->txt('ass_create_export_file_with_results') . ")";
72 }
73
74 public function onDeleteFiles(
75 ilExportHandlerConsumerContextInterface $context,
76 ilExportHandlerConsumerFileIdentifierCollectionInterface $file_identifiers
77 ): void {
78 $object_id = new ObjectId($context->exportObject()->getId());
79 foreach ($file_identifiers as $file_identifier) {
80 $rid = $this->irss->manage()->find($file_identifier->getIdentifier());
81 $this->repository->delete($rid);
82 $this->irss->manage()->remove($rid, new ResultsExportStakeholder());
83 }
84 }
85
86 public function onDownloadFiles(
87 ilExportHandlerConsumerContextInterface $context,
88 ilExportHandlerConsumerFileIdentifierCollectionInterface $file_identifiers
89 ): void {
90 $object_id = new ObjectId($context->exportObject()->getId());
91 foreach ($file_identifiers as $file_identifier) {
92 $this->irss->consume()->download(
93 $this->irss->manage()->find($file_identifier->getIdentifier())
94 )->run();
95 }
96 }
97
98 public function onDownloadWithLink(
99 ReferenceId $reference_id,
100 ilExportHandlerConsumerFileIdentifierInterface $file_identifier
101 ): void {
102 $this->irss->consume()->download($reference_id)->run();
103 }
104
105 public function getFiles(
106 ilExportHandlerConsumerContextInterface $context
107 ): ilExportHandlerFileInfoCollectionInterface {
108 return $this->buildElements(
109 $context,
110 $this->data_factory->objId($context->exportObject()->getId())
111 );
112 }
113
114 public function getFileSelection(
115 ilExportHandlerConsumerContextInterface $context,
116 ilExportHandlerConsumerFileIdentifierCollectionInterface $file_identifiers
117 ): ilExportHandlerFileInfoCollectionInterface {
118 return $this->buildElements(
119 $context,
120 $this->data_factory->objId($context->exportObject()->getId()),
121 $file_identifiers->toStringArray()
122 );
123 }
124
125 public function onExportOptionSelected(
126 ilExportHandlerConsumerContextInterface $context
127 ): void {
128 $context->exportGUIObject()->createTestExportWithResults();
129 }
130
131 protected function buildElements(
132 ilExportHandlerConsumerContextInterface $context,
133 ObjectId $object_id,
134 ?array $file_identifiers = null
135 ): ilExportHandlerFileInfoCollectionInterface {
136 if ($file_identifiers === null) {
137 $file_identifiers = array_map(
138 static fn(array $v): string => $v['rid'],
139 $this->repository->getFor($object_id->toInt())
140 );
141 }
142 $collection_builder = $context->fileCollectionBuilder();
143 foreach ($file_identifiers as $file_identifier) {
144 $collection_builder = $collection_builder->withResourceIdentifier(
145 $this->irss->manage()->find($file_identifier),
146 $object_id,
147 $this
148 );
149 }
150 return $collection_builder->collection();
151 }
152}
Customizing of pimple-DIC for ILIAS.
Definition: Container.php:36
Builds data types.
Definition: Factory.php:36
language handling
onDownloadFiles(ilExportHandlerConsumerContextInterface $context, ilExportHandlerConsumerFileIdentifierCollectionInterface $file_identifiers)
buildElements(ilExportHandlerConsumerContextInterface $context, ObjectId $object_id, ?array $file_identifiers=null)
getFiles(ilExportHandlerConsumerContextInterface $context)
onDownloadWithLink(ReferenceId $reference_id, ilExportHandlerConsumerFileIdentifierInterface $file_identifier)
getFileSelection(ilExportHandlerConsumerContextInterface $context, ilExportHandlerConsumerFileIdentifierCollectionInterface $file_identifiers)
onExportOptionSelected(ilExportHandlerConsumerContextInterface $context)
onDeleteFiles(ilExportHandlerConsumerContextInterface $context, ilExportHandlerConsumerFileIdentifierCollectionInterface $file_identifiers)
return['delivery_method'=> 'php',]
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
if(!file_exists('../ilias.ini.php'))
global $DIC
Definition: shib_login.php:26
$context
Definition: webdav.php:31