ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
Factory.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
21 namespace ILIAS\Test\ExportImport;
22 
27 
28 class Factory
29 {
30  public function __construct(
31  private readonly \ilLanguage $lng,
32  private readonly \ilDBInterface $db,
33  private readonly \ilBenchmark $bench,
34  private \ilGlobalTemplateInterface $tpl,
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 = ExportFixedQuestionSet::class;
89  if (!$test_obj->isFixedTest()) {
90  $export_class = ExportRandomQuestionSet::class;
91  }
92 
93  $export = new $export_class(
94  $this->lng,
95  $this->db,
96  $this->bench,
97  $this->logger,
98  $this->tree,
99  $this->component_repository,
100  $this->questionrepository,
101  $this->file_delivery,
102  $test_obj,
103  $this->irss
104  );
105 
106  if ($export_type === Types::XML_WITH_RESULTS) {
107  return $export->withResultExportingEnabled(true);
108  }
109  return $export;
110 
111  case Types::PLUGIN:
112  if ($plugin_type === null) {
113  throw new \Exception('No Plugin Type given!');
114  }
115  foreach ($this->component_factory->getActivePluginsInSlot('texp') as $plugin) {
116  if ($plugin->getFormat() === $plugin_type) {
117  $plugin->setTest($test_obj);
118  return $plugin;
119  }
120  }
121  }
122  }
123 }
Readable part of repository interface to ilComponentDataDB.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
isFixedTest()
Returns the fact wether this test is a fixed question set test or not.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
__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
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getExporter(\ilObjTest $test_obj, Types $export_type, ?string $plugin_type=null)
Definition: Factory.php:46
global $lng
Definition: privfeed.php:31
$file_delivery
Definition: deliver.php:29
Class ilBenchmark.