ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
XMLWithResultsOption.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
24use ILIAS\Export\ExportHandler\Factory as ExportHandlerLocator;
31
32class XMLWithResultsOption extends BasicLegacyExportOption
33{
34 private readonly Language $lng;
36
37 public function init(
39 ): void {
40 parent::init($DIC);
41
42 $this->lng = $DIC->language();
43 $this->context_holder = TestDIC::dic()['exportimport.export_context_holder'];
44 }
45
46 public function getExportType(): string
47 {
48 return 'ZIP Results';
49 }
50
51 public function getExportOptionId(): string
52 {
53 return Types::XML_WITH_RESULTS->value;
54 }
55
56 public function getSupportedRepositoryObjectTypes(): array
57 {
58 return ['tst'];
59 }
60
61 public function getLabel(): string
62 {
63 $this->lng->loadLanguageModule('exp');
64 $this->lng->loadLanguageModule('assessment');
65
66 return "{$this->lng->txt('exp_format_dropdown-xml')} ({$this->lng->txt('ass_create_export_file_with_results')})";
67 }
68
69 public function onExportOptionSelected(ConsumerContext $context): void
70 {
71 $handler = new ExportHandlerLocator();
72 $manager = $handler->manager()->handler();
73
74 $export_info = $manager->getExportInfoWithObject(
75 $context->exportObject(),
76 time(),
77 $handler->consumer()->exportConfig()->allExportConfigs()
78 );
79
80 // Prepare export context to bridge between export option and the xml exporter
81 $this->context_holder->create(
82 $export_info->getTarget(),
83 $handler->consumer()->exportConfig()->allExportConfigs(),
84 Types::XML_WITH_RESULTS->value
85 );
86
87 // Delegate the export to the manager which will call ilTestExporter
88 $manager->createExport(1, $export_info, '');
89
90 $this->ctrl->redirectByClass(\ilExportGUI::class, \ilExportGUI::CMD_LIST_EXPORT_FILES);
91 }
92}
Customizing of pimple-DIC for ILIAS.
Definition: Container.php:38
language()
Get interface to the i18n service.
Definition: Container.php:95
static dic()
Definition: TestDIC.php:75
const CMD_LIST_EXPORT_FILES
$handler
Definition: oai.php:31
global $DIC
Definition: shib_login.php:26