Skip to content

Commit

Permalink
Test: Removed test export options (csv results, xml results, plugins)…
Browse files Browse the repository at this point in the history
… from export tab. Removed test question pool export option (excel) from export tab. Fixed file paths of test archive export option. Removed corresponding code from gui classes.
  • Loading branch information
chlulei committed Oct 25, 2024
1 parent 4e3194d commit 24fd2bd
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 838 deletions.
62 changes: 0 additions & 62 deletions components/ILIAS/Test/classes/class.ilTestExportGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
*/
class ilTestExportGUI extends ilExportGUI
{
protected array $active_export_plugins;
protected UIServices $ui;

public function __construct(
Expand All @@ -54,70 +53,9 @@ public function __construct(
private readonly ilTestHTMLGenerator $html_generator,
private readonly array $selected_files,
) {
$this->active_export_plugins = iterator_to_array($active_export_plugins);
parent::__construct($parent_gui, null);
}

public function executeCommand(): void
{
$cmd = $this->ctrl->getCmd();
if (
$cmd === "exportPlugin" ||
$cmd === "showExportPluginMenu"
) {
$this->$cmd();
return;
}
parent::executeCommand();
}

protected function buildExportPluginMenuForm(): StandardForm
{
$this->lng->loadLanguageModule('exp');
$items = [];
foreach ($this->active_export_plugins as $plugin) {
/** @var ilPlugin $plugin */
$items[$plugin->getId()] = $plugin->getFormatLabel();
}
$select = $this->ui_factory->input()->field()->select($this->lng->txt("export_type"), $items)
->withRequired(true);
$section = $this->ui_factory->input()->field()->section(
[$select],
$this->lng->txt("export_options")
);
return $this->ui_factory->input()->container()->form()->standard(
$this->ctrl->getLinkTarget($this, "exportPlugin"),
[$section]
)->withSubmitLabel($this->lng->txt("export"));
}

protected function exportPlugin(): void
{
$form = $this->buildExportPluginMenuForm()->withRequest($this->http->request());
$plugin = null;
if (!is_null($form->getData())) {
$plugin_id = $form->getData()[0][0];
foreach ($this->active_export_plugins as $current_plugin) {
if ($current_plugin->getId() === $plugin_id) {
$plugin = $current_plugin;
break;
}
}
}
if (is_null($form->getData())) {
$this->tpl->setContent($this->ui_renderer->render($form));
return;
}
$plugin->export();
$this->ctrl->redirectByClass(ilExportGUI::class, ilExportGUI::CMD_LIST_EXPORT_FILES);
}

public function showExportPluginMenu(): void
{
$form = $this->buildExportPluginMenuForm();
$this->tpl->setContent($this->ui_renderer->render($form));
}

/**
* @return ilTestExportTableGUI
*/
Expand Down
21 changes: 7 additions & 14 deletions components/ILIAS/Test/classes/class.ilTestExportOptionARC.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,28 +140,21 @@ public function onExportOptionSelected(
protected function getExportFiles(
string $directory
): array {
$file = [];
$files = [];
try {
$h_dir = dir($directory);
while ($entry = $h_dir->read()) {
foreach (scandir($directory) as $file) {
if (
$entry !== "." &&
$entry !== ".." &&
substr($entry, -4) === ".zip"
in_array($file, ['.', '..']) ||
!str_ends_with($file, ".zip")
) {
$ts = substr($entry, 0, strpos($entry, "__"));
$file[$entry . $this->getExportType()] = [
"type" => $this->getExportType(),
"file" => $entry,
"size" => (int) filesize($directory . "/" . $entry),
"timestamp" => (int) $ts
];
continue;
}
$files[$file] = ["file" => $file];
}
} catch (Exception $e) {

}
return $file;
return $files;
}

protected function getDirectory(
Expand Down
180 changes: 0 additions & 180 deletions components/ILIAS/Test/classes/class.ilTestExportOptionCSV.php

This file was deleted.

Loading

0 comments on commit 24fd2bd

Please sign in to comment.