ILIAS  trunk Revision v11.0_alpha-1769-g99a433fe2dc
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
Factory.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
21 namespace ILIAS\Test\ExportImport;
22 
26 
27 class Factory
28 {
29  public function __construct(
30  private readonly \ilLanguage $lng,
31  private readonly \ilDBInterface $db,
32  private readonly \ilBenchmark $bench,
33  private \ilGlobalTemplateInterface $tpl,
34  private readonly TestLogger $logger,
35  private readonly \ilTree $tree,
36  private readonly \ilComponentRepository $component_repository,
37  private readonly \ilComponentFactory $component_factory,
38  private readonly FileDeliveryServices $file_delivery,
39  private readonly \ilObjUser $current_user,
40  private readonly GeneralQuestionPropertiesRepository $questionrepository
41  ) {
42  }
43 
44  public function getExporter(
45  \ilObjTest $test_obj,
46  Types $export_type,
47  ?string $plugin_type = null
48  ): Exporter {
49  switch ($export_type) {
50  case Types::SCORED_ATTEMPT:
51  return (new ResultsExportExcel(
52  $this->lng,
53  $this->current_user,
54  $test_obj,
55  $this->questionrepository,
56  "{$test_obj->getTitle()}_{$this->lng->txt('scored_pass')}_{$this->lng->txt('results')}",
57  true
58  ))->withAggregatedResultsPage()
59  ->withResultsPage()
60  ->withUserPages();
61 
62  case Types::ALL_ATTEMPTS:
63  return (new ResultsExportExcel(
64  $this->lng,
65  $this->current_user,
66  $test_obj,
67  $this->questionrepository,
68  "{$test_obj->getTitle()}_{$this->lng->txt('all')}_{$this->lng->txt('results')}",
69  false
70  ))->withAggregatedResultsPage()
71  ->withResultsPage()
72  ->withUserPages();
73 
74  case Types::CERTIFICATE_ARCHIVE:
75  return new CertificateExport(
76  $this->lng,
77  $this->db,
78  $this->logger,
79  $this->tpl,
80  $this->file_delivery,
81  $test_obj
82  );
83 
84  case Types::XML:
85  case Types::XML_WITH_RESULTS:
86  $export_class = ExportFixedQuestionSet::class;
87  if (!$test_obj->isFixedTest()) {
88  $export_class = ExportRandomQuestionSet::class;
89  }
90 
91  $export = new $export_class(
92  $this->lng,
93  $this->db,
94  $this->bench,
95  $this->logger,
96  $this->tree,
97  $this->component_repository,
98  $this->questionrepository,
99  $this->file_delivery,
100  $test_obj
101  );
102 
103  if ($export_type === Types::XML_WITH_RESULTS) {
104  return $export->withResultExportingEnabled(true);
105  }
106  return $export;
107 
108  case Types::PLUGIN:
109  if ($plugin_type === null) {
110  throw new \Exception('No Plugin Type given!');
111  }
112  foreach ($this->component_factory->getActivePluginsInSlot('texp') as $plugin) {
113  if ($plugin->getFormat() === $plugin_type) {
114  $plugin->setTest($test_obj);
115  return $plugin;
116  }
117  }
118  }
119  }
120 }
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)
Definition: Factory.php:29
getExporter(\ilObjTest $test_obj, Types $export_type, ?string $plugin_type=null)
Definition: Factory.php:44
global $lng
Definition: privfeed.php:31
$file_delivery
Definition: deliver.php:29
Class ilBenchmark.