ILIAS  trunk Revision v13.0_alpha-52-g21c366bbdd4
Factory.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
25use ILIAS\FileDelivery\Services as FileDeliveryServices;
26use ILIAS\ResourceStorage\Services as ResourceStorage;
27
29{
30 public function __construct(
31 private readonly \ilLanguage $lng,
32 private readonly \ilDBInterface $db,
33 private readonly \ilBenchmark $bench,
35 private readonly TestLogger $logger,
36 private readonly \ilTree $tree,
37 private readonly \ilComponentRepository $component_repository,
38 private readonly \ilComponentFactory $component_factory,
39 private readonly FileDeliveryServices $file_delivery,
40 private readonly \ilObjUser $current_user,
41 private readonly GeneralQuestionPropertiesRepository $questionrepository,
42 private readonly ResourceStorage $irss
43 ) {
44 }
45
46 public function getExporter(
47 \ilObjTest $test_obj,
48 Types $export_type,
49 ?string $plugin_type = null
50 ): Exporter {
51 switch ($export_type) {
52 case Types::SCORED_ATTEMPT:
53 return (new ResultsExportExcel(
54 $this->lng,
55 $this->current_user,
56 $test_obj,
57 $this->questionrepository,
58 "{$test_obj->getTitle()}_{$this->lng->txt('scored_pass')}_{$this->lng->txt('results')}",
59 true
60 ))->withAggregatedResultsPage()
61 ->withResultsPage()
62 ->withUserPages();
63
64 case Types::ALL_ATTEMPTS:
65 return (new ResultsExportExcel(
66 $this->lng,
67 $this->current_user,
68 $test_obj,
69 $this->questionrepository,
70 "{$test_obj->getTitle()}_{$this->lng->txt('all')}_{$this->lng->txt('results')}",
71 false
72 ))->withAggregatedResultsPage()
73 ->withResultsPage()
74 ->withUserPages();
75
76 case Types::CERTIFICATE_ARCHIVE:
77 return new CertificateExport(
78 $this->lng,
79 $this->db,
80 $this->logger,
81 $this->tpl,
82 $this->file_delivery,
83 $test_obj
84 );
85
86 case Types::XML:
87 case Types::XML_WITH_RESULTS:
88 $export_class = $test_obj->isFixedTest() ? ExportFixedQuestionSet::class : ExportRandomQuestionSet::class;
89
90 $export = new $export_class(
91 $this->lng,
92 $this->db,
93 $this->bench,
94 $this->logger,
95 $this->tree,
96 $this->component_repository,
97 $this->questionrepository,
98 $this->file_delivery,
99 $test_obj,
100 $this->irss,
101 $this->current_user
102 );
103
104 return $export->withResultExportingEnabled($export_type === Types::XML_WITH_RESULTS);
105
106 case Types::PLUGIN:
107 if ($plugin_type === null) {
108 throw new \Exception('No Plugin Type given!');
109 }
110 foreach ($this->component_factory->getActivePluginsInSlot('texp') as $plugin) {
111 if ($plugin->getFormat() === $plugin_type) {
112 $plugin->setTest($test_obj);
113 return $plugin;
114 }
115 }
116 }
117 }
118}
getExporter(\ilObjTest $test_obj, Types $export_type, ?string $plugin_type=null)
Definition: Factory.php:46
__construct(private readonly \ilLanguage $lng, private readonly \ilDBInterface $db, private readonly \ilBenchmark $bench, private \ilGlobalTemplateInterface $tpl, private readonly TestLogger $logger, private readonly \ilTree $tree, private readonly \ilComponentRepository $component_repository, private readonly \ilComponentFactory $component_factory, private readonly FileDeliveryServices $file_delivery, private readonly \ilObjUser $current_user, private readonly GeneralQuestionPropertiesRepository $questionrepository, private readonly ResourceStorage $irss)
Definition: Factory.php:30
Class ilBenchmark.
language handling
isFixedTest()
Returns the fact wether this test is a fixed question set test or not.
User class.
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
Readable part of repository interface to ilComponentDataDB.
Interface ilDBInterface.
readonly ilGlobalTemplateInterface $tpl
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $lng
Definition: privfeed.php:26