ILIAS  release_8 Revision v8.24
ilTestExportGUI Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Inheritance diagram for ilTestExportGUI:
+ Collaboration diagram for ilTestExportGUI:

Public Member Functions

 __construct ($a_parent_gui, $a_main_obj=null)
 
 createTestArchiveExport ()
 
 listExportFiles ()
 
- Public Member Functions inherited from ilExportGUI
 __construct (object $a_parent_gui, ?ilObject $a_main_obj=null)
 
 addFormat (string $a_key, string $a_txt="", object $a_call_obj=null, string $a_call_func="")
 
 getFormats ()
 
 addCustomColumn (string $a_txt, object $a_obj, string $a_func)
 
 addCustomMultiCommand (string $a_txt, object $a_obj, string $a_func)
 
 getCustomMultiCommands ()
 
 getCustomColumns ()
 
 executeCommand ()
 
 listExportFiles ()
 
 createExportFile ()
 
 confirmDeletion ()
 Confirm file deletion. More...
 
 delete ()
 
 download ()
 Download file. More...
 
 handleCustomMultiCommand ()
 

Protected Member Functions

 buildExportTableGUI ()
 
- Protected Member Functions inherited from ilExportGUI
 initFileIdentifierFromQuery ()
 
 initFileIdentifiersFromPost ()
 
 initFormatFromPost ()
 
 initExportOptionsFromPost ()
 
 buildExportTableGUI ()
 
 getParentGUI ()
 
 showItemSelection ()
 Show container item selection table. More...
 
 saveItemSelection ()
 

Private Member Functions

 getExportTypeFromFileName (string $export_file)
 

Private Attributes

ILIAS Test InternalRequestService $testrequest
 

Additional Inherited Members

- Protected Attributes inherited from ilExportGUI
Factory $refinery
 
Services $http
 
array $formats = array()
 
array $custom_columns = array()
 
array $custom_multi_commands = array()
 
ilObject $obj
 
ilLanguage $lng
 
ilGlobalTemplateInterface $tpl
 
ilCtrlInterface $ctrl
 
ilAccessHandler $access
 
ilErrorHandling $error
 
ilToolbarGUI $toolbar
 
ilObjectDefinition $objDefinition
 
ilTree $tree
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Export User Interface Class

Author
Michael Jansen mjans.nosp@m.en@d.nosp@m.ataba.nosp@m.y.de
Maximilian Becker mbeck.nosp@m.er@d.nosp@m.ataba.nosp@m.y.de
Version
$Id$

@ilCtrl_Calls ilTestExportGUI: ilParticipantsTestResultsGUI

Definition at line 31 of file class.ilTestExportGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilTestExportGUI::__construct (   $a_parent_gui,
  $a_main_obj = null 
)

Definition at line 35 of file class.ilTestExportGUI.php.

36 {
37 global $DIC;
38 $component_factory = $DIC["component.factory"];
39 $this->testrequest = $DIC->test()->internal()->request();
40 parent::__construct($a_parent_gui, $a_main_obj);
41
42 #$this->addFormat('xml', $a_parent_gui->lng->txt('ass_create_export_file'), $this, 'createTestExport');
43 $this->addFormat('xml', $DIC->language()->txt('ass_create_export_file'));
44 $this->addFormat('xmlres', $DIC->language()->txt('ass_create_export_file_with_results'), $this, 'createTestExportWithResults');
45 $this->addFormat('csv', $DIC->language()->txt('ass_create_export_test_results'), $this, 'createTestResultsExport');
46 $this->addFormat('arc', $DIC->language()->txt('ass_create_export_test_archive'), $this, 'createTestArchiveExport');
47 foreach ($component_factory->getActivePluginsInSlot("texp") as $plugin) {
48 $plugin->setTest($this->obj);
49 $this->addFormat(
50 $plugin->getFormat(),
51 $plugin->getFormatLabel(),
52 $plugin,
53 'export'
54 );
55 }
56 }
addFormat(string $a_key, string $a_txt="", object $a_call_obj=null, string $a_call_func="")
global $DIC
Definition: feed.php:28
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc

References $DIC, XapiProxy\$plugin, ILIAS\GlobalScreen\Provider\__construct(), and ilExportGUI\addFormat().

+ Here is the call graph for this function:

Member Function Documentation

◆ buildExportTableGUI()

ilTestExportGUI::buildExportTableGUI ( )
protected
Returns
ilTestExportTableGUI

Reimplemented from ilExportGUI.

Definition at line 61 of file class.ilTestExportGUI.php.

62 {
63 $table = new ilTestExportTableGUI($this, 'listExportFiles', $this->obj);
64 return $table;
65 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

Referenced by listExportFiles().

+ Here is the caller graph for this function:

◆ createTestArchiveExport()

ilTestExportGUI::createTestArchiveExport ( )

Definition at line 120 of file class.ilTestExportGUI.php.

121 {
122 global $DIC;
123 $ilAccess = $DIC['ilAccess'];
124 $ilCtrl = $DIC['ilCtrl'];
125 $ilDB = $DIC['ilDB'];
126 $lng = $DIC['lng'];
127
128 if ($ilAccess->checkAccess("write", "", $this->obj->getRefId())) {
129 // prepare generation before contents are processed (for mathjax)
131
132 $evaluation = new ilTestEvaluation($ilDB, $this->obj->getTestId());
133 $allActivesPasses = $evaluation->getAllActivesPasses();
134 $participantData = new ilTestParticipantData($ilDB, $lng);
135 $participantData->setActiveIdsFilter(array_keys($allActivesPasses));
136 $participantData->load($this->obj->getTestId());
137
138 $archiveService = new ilTestArchiveService($this->obj);
139 $archiveService->setParticipantData($participantData);
140 $archiveService->archivePassesByActives($allActivesPasses);
141
142 $test_id = $this->obj->getId();
143 $test_ref = $this->obj->getRefId();
144 $archive_exp = new ilTestArchiver($test_id, $test_ref);
145
146 $scoring = new ilTestScoring($this->obj);
147 $best_solution = $scoring->calculateBestSolutionForTest();
148
149 $tmpFileName = ilFileUtils::ilTempnam();
150 if (!is_dir($tmpFileName)) {
151 ilFileUtils::makeDirParents($tmpFileName);
152 }
153
154 $directory_name = realpath($tmpFileName);
155 $file_name = $directory_name . DIRECTORY_SEPARATOR . 'Best_Solution.pdf';
156
157 $generator = new ilTestPDFGenerator();
158 $generator->generatePDF($best_solution, ilTestPDFGenerator::PDF_OUTPUT_FILE, $file_name, PDF_USER_RESULT);
159 $archive_exp->handInTestBestSolution($best_solution, $file_name);
160 ilFileUtils::delDir($directory_name);
161
162 $archive_exp->updateTestArchive();
163 $archive_exp->compressTestArchive();
164 } else {
165 $this->tpl->setOnScreenMessage('info', "cannot_export_archive", true);
166 }
167 $ilCtrl->redirectByClass('iltestexportgui');
168 }
ilLanguage $lng
static makeDirParents(string $a_dir)
Create a new directory and all parent directories.
static ilTempnam(?string $a_temp_path=null)
Returns a unique and non existing Path for e temporary file or directory.
static delDir(string $a_dir, bool $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
static prepareGenerationRequest(string $service, string $purpose)
Prepare the content processing for a PDF generation request This function should be called as in a re...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const PDF_USER_RESULT
PDF Purposes.

References $DIC, $ilDB, ilExportGUI\$lng, ilFileUtils\delDir(), ilFileUtils\ilTempnam(), ilFileUtils\makeDirParents(), ilTestPDFGenerator\PDF_OUTPUT_FILE, PDF_USER_RESULT, and ilPDFGeneratorUtils\prepareGenerationRequest().

+ Here is the call graph for this function:

◆ getExportTypeFromFileName()

ilTestExportGUI::getExportTypeFromFileName ( string  $export_file)
private

Definition at line 263 of file class.ilTestExportGUI.php.

264 {
265 $extension = strtoupper(pathinfo($export_file, PATHINFO_EXTENSION));
266 if (in_array($extension, ['XLSX', 'CSV', 'XLS'])) {
267 return $this->lng->txt('results');
268 }
269 return $extension;
270 }

References ILIAS\Repository\lng().

Referenced by listExportFiles().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ listExportFiles()

ilTestExportGUI::listExportFiles ( )

Reimplemented from ilExportGUI.

Definition at line 170 of file class.ilTestExportGUI.php.

170 : void
171 {
172 global $DIC;
173 $ilAccess = $DIC['ilAccess'];
174 $tpl = $DIC['tpl'];
175 $ilToolbar = $DIC['ilToolbar'];
176 $ilCtrl = $DIC['ilCtrl'];
177 $lng = $DIC['lng'];
178
179 if (!$ilAccess->checkAccess('write', '', $this->obj->getRefId())) {
180 $this->tpl->setOnScreenMessage('info', "cannot_export_archive", true);
181 $ilCtrl->redirectByClass(ilObjTestGUI::class);
182 }
183
184 $ilToolbar->setFormAction($ilCtrl->getFormAction($this));
185
186 if (count($this->getFormats()) > 1) {
187 foreach ($this->getFormats() as $f) {
188 $options[$f["key"]] = $f["txt"];
189 }
190 $si = new ilSelectInputGUI($lng->txt("type"), "format");
191 $si->setOptions($options);
192 $ilToolbar->addInputItem($si, true);
193 $ilToolbar->addFormButton($lng->txt("exp_create_file"), "createExportFile");
194 } else {
195 $format = $this->getFormats();
196 $format = $format[0];
197 $ilToolbar->addFormButton($lng->txt("exp_create_file") . " (" . $format["txt"] . ")", "create_" . $format["key"]);
198 }
199
200 $archiver = new ilTestArchiver($this->getParentGUI()->getTestObject()->getId());
201 $archive_dir = $archiver->getZipExportDirectory();
202 $archive_files = array();
203
204 if (file_exists($archive_dir) && is_dir($archive_dir)) {
205 $archive_files = scandir($archive_dir);
206 }
207
208 $export_dir = $this->obj->getExportDirectory();
209 $export_files = $this->obj->getExportFiles($export_dir);
210 $data = array();
211 if (count($export_files) > 0) {
212 foreach ($export_files as $exp_file) {
213 $file_arr = explode("__", $exp_file);
214 if ($file_arr[0] == $exp_file) {
215 continue;
216 }
217
218 array_push($data, array(
219 'file' => $exp_file,
220 'size' => filesize($export_dir . "/" . $exp_file),
221 'timestamp' => $file_arr[0],
222 'type' => $this->getExportTypeFromFileName($exp_file)
223 ));
224 }
225 }
226
227 if (count($archive_files) > 0) {
228 foreach ($archive_files as $exp_file) {
229 if ($exp_file == '.' || $exp_file == '..') {
230 continue;
231 }
232 $file_arr = explode("_", $exp_file);
233
234 $data[] = [
235 'file' => $exp_file,
236 'size' => filesize($archive_dir . "/" . $exp_file),
237 'timestamp' => $file_arr[4],
238 'type' => $this->getExportTypeFromFileName($exp_file)
239 ];
240 }
241 }
242
243 $table = $this->buildExportTableGUI();
244 $table->setSelectAllCheckbox("file");
245 foreach ($this->getCustomColumns() as $c) {
246 $table->addCustomColumn($c["txt"], $c["obj"], $c["func"]);
247 }
248
249 foreach ($this->getCustomMultiCommands() as $c) {
250 $table->addCustomMultiCommand($c["txt"], "multi_" . $c["func"]);
251 }
252
253 $table->resetFormats();
254 foreach ($this->formats as $format) {
255 $table->addFormat($format['key']);
256 }
257
258 $table->setData($data);
259 $this->tpl->setOnScreenMessage('info', $lng->txt('no_manual_feedback_export_info'), true);
260 $tpl->setContent($table->getHTML());
261 }
ilGlobalTemplateInterface $tpl
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
This class represents a selection list property in a property form.
getExportTypeFromFileName(string $export_file)
$c
Definition: cli.php:38
setContent(string $a_html)
Sets content for standard template.
$format
Definition: metadata.php:235

References $c, $data, $DIC, Vendor\Package\$f, $format, ilExportGUI\$lng, ilExportGUI\$tpl, buildExportTableGUI(), ilExportGUI\getCustomColumns(), ilExportGUI\getCustomMultiCommands(), getExportTypeFromFileName(), ilExportGUI\getFormats(), ILIAS\Survey\Mode\getId(), ilExportGUI\getParentGUI(), ilGlobalTemplateInterface\setContent(), and ilLanguage\txt().

+ Here is the call graph for this function:

Field Documentation

◆ $testrequest

ILIAS Test InternalRequestService ilTestExportGUI::$testrequest
private

Definition at line 33 of file class.ilTestExportGUI.php.


The documentation for this class was generated from the following file: