ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilTestExportGUI Class Reference

Export User Interface Class. More...

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

Public Member Functions

 createTestArchiveExport ()
 
 listExportFiles ()
 
- Public Member Functions inherited from ilExportGUI
 __construct ($a_parent_gui, $a_main_obj=null)
 Constuctor. More...
 
 addFormat ($a_key, $a_txt="", $a_call_obj=null, $a_call_func="")
 Add formats. More...
 
 getFormats ()
 Get formats. More...
 
 addCustomColumn ($a_txt, $a_obj, $a_func)
 Add custom column. More...
 
 addCustomMultiCommand ($a_txt, $a_obj, $a_func)
 Add custom multi command. More...
 
 getCustomMultiCommands ()
 Get custom multi commands. More...
 
 getCustomColumns ()
 Get custom columns. More...
 
 executeCommand ()
 Execute command. More...
 
 listExportFiles ()
 List export files. More...
 
 createExportFile ()
 Create export file. More...
 
 confirmDeletion ()
 Confirm file deletion. More...
 
 delete ()
 Delete files. More...
 
 download ()
 Download file. More...
 
 handleCustomMultiCommand ()
 Handle custom multi command. More...
 

Protected Member Functions

 buildExportTableGUI ()
 
- Protected Member Functions inherited from ilExportGUI
 buildExportTableGUI ()
 
 getParentGUI ()
 get parent gui More...
 
 showItemSelection ()
 Show container item selection table. More...
 
 saveItemSelection ()
 Save selection of subitems. More...
 

Additional Inherited Members

- Protected Attributes inherited from ilExportGUI
 $formats = array()
 
 $custom_columns = array()
 
 $custom_multi_commands = array()
 

Detailed Description

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$

ilTestExportGUI:

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

Member Function Documentation

◆ buildExportTableGUI()

ilTestExportGUI::buildExportTableGUI ( )
protected
Returns
ilTestExportTableGUI

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

References $ilCtrl, $lng, and ilUtil\sendSuccess().

Referenced by listExportFiles().

52  {
53  require_once 'Modules/Test/classes/tables/class.ilTestExportTableGUI.php';
54  $table = new ilTestExportTableGUI($this, 'listExportFiles', $this->obj);
55  return $table;
56  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ createTestArchiveExport()

ilTestExportGUI::createTestArchiveExport ( )

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

References $ilCtrl, $ilDB, $lng, ilUtil\delDir(), ilTestEvaluation\getAllActivesPasses(), ilUtil\ilTempnam(), ilUtil\makeDirParents(), ilTestPDFGenerator\PDF_OUTPUT_FILE, ilPDFGeneration\prepareGeneration(), and ilUtil\sendInfo().

98  {
99  global $ilAccess, $ilCtrl, $ilDB, $lng;
100 
101  if ($ilAccess->checkAccess("write", "", $this->obj->ref_id))
102  {
103  // prepare generation before contents are processed (for mathjax)
104  require_once 'Services/PDFGeneration/classes/class.ilPDFGeneration.php';
106 
107  require_once 'Modules/Test/classes/class.ilTestEvaluation.php';
108  $evaluation = new ilTestEvaluation($ilDB, $this->obj->getTestId());
109  $allActivesPasses = $evaluation->getAllActivesPasses();
110 
111  require_once 'Modules/Test/classes/class.ilTestParticipantData.php';
112  $participantData = new ilTestParticipantData($ilDB, $lng);
113  $participantData->setActiveIds(array_keys($allActivesPasses));
114  $participantData->load($this->obj->getTestId());
115 
116  require_once 'Modules/Test/classes/class.ilTestArchiveService.php';
117  $archiveService = new ilTestArchiveService($this->obj);
118  $archiveService->setParticipantData($participantData);
119  $archiveService->archivePassesByActives($allActivesPasses);
120 
121  include_once("./Modules/Test/classes/class.ilTestArchiver.php");
122  $test_id = $this->obj->getId();
123  $archive_exp = new ilTestArchiver($test_id);
124 
125  require_once './Modules/Test/classes/class.ilTestScoring.php';
126  $scoring = new ilTestScoring($this->obj);
127  $best_solution = $scoring->calculateBestSolutionForTest();
128 
129  $tmpFileName = ilUtil::ilTempnam();
130  if(!is_dir($tmpFileName))
131  {
132  ilUtil::makeDirParents($tmpFileName);
133  }
134 
135  $directory_name = realpath($tmpFileName);
136  $file_name = $directory_name . DIRECTORY_SEPARATOR . 'Best_Solution.pdf';
137 
138  require_once './Modules/Test/classes/class.ilTestPDFGenerator.php';
139  $generator = new ilTestPDFGenerator();
140  $generator->generatePDF($best_solution, ilTestPDFGenerator::PDF_OUTPUT_FILE, $file_name);
141  $archive_exp->handInTestBestSolution($best_solution, $file_name);
142  ilUtil::delDir($directory_name);
143 
144  $archive_exp->updateTestArchive();
145  $archive_exp->compressTestArchive();
146  }
147  else
148  {
149  ilUtil::sendInfo("cannot_export_archive", TRUE);
150  }
151  $ilCtrl->redirectByClass('iltestexportgui');
152  }
static makeDirParents($a_dir)
Create a new directory and all parent directories.
Class ilTestPDFGenerator.
global $ilCtrl
Definition: ilias.php:18
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
Class ilTestScoring.
static ilTempnam($a_temp_path=null)
Create a temporary file in an ILIAS writable directory.
static prepareGeneration()
Prepare the PDF generation This initializes the purpose for MathJax rendering It has to be called bef...
Class ilTestArchiver.
global $lng
Definition: privfeed.php:17
global $ilDB
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
+ Here is the call graph for this function:

◆ listExportFiles()

ilTestExportGUI::listExportFiles ( )

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

References $_GET, $_POST, $data, $file, $filename, $ilCtrl, $lng, $options, $si, $tpl, array, buildExportTableGUI(), ilUtil\delDir(), ilUtil\deliverFile(), ilExportGUI\download(), ilExportGUI\getCustomColumns(), ilExportGUI\getCustomMultiCommands(), ilExportGUI\getFormats(), ilExportGUI\getParentGUI(), ilTestArchiver\getZipExportDirectory(), object, ilUtil\sendInfo(), and ilUtil\sendSuccess().

155  {
156  global $tpl, $ilToolbar, $ilCtrl, $lng;
157 
158  $ilToolbar->setFormAction($ilCtrl->getFormAction($this));
159 
160  if(count($this->getFormats()) > 1)
161  {
162  foreach($this->getFormats() as $f)
163  {
164  $options[$f["key"]] = $f["txt"];
165  }
166  include_once 'Services/Form/classes/class.ilSelectInputGUI.php';
167  $si = new ilSelectInputGUI($lng->txt("type"), "format");
168  $si->setOptions($options);
169  $ilToolbar->addInputItem($si, true);
170  $ilToolbar->addFormButton($lng->txt("exp_create_file"), "createExportFile");
171  }
172  else
173  {
174  $format = $this->getFormats();
175  $format = $format[0];
176  $ilToolbar->addFormButton($lng->txt("exp_create_file") . " (" . $format["txt"] . ")", "create_" . $format["key"]);
177  }
178 
179  require_once 'class.ilTestArchiver.php';
180  $archiver = new ilTestArchiver($this->getParentGUI()->object->getId());
181  $archive_dir = $archiver->getZipExportDirectory();
182  $archive_files = array();
183  if( file_exists($archive_dir) && is_dir($archive_dir) )
184  {
185  $archive_files = scandir($archive_dir);
186  }
187 
188  $export_dir = $this->obj->getExportDirectory();
189  $export_files = $this->obj->getExportFiles($export_dir);
190  $data = array();
191  if(count($export_files) > 0)
192  {
193  foreach($export_files as $exp_file)
194  {
195  $file_arr = explode("__", $exp_file);
196  array_push($data, array(
197  'file' => $exp_file,
198  'size' => filesize($export_dir . "/" . $exp_file),
199  'timestamp' => $file_arr[0]
200  ));
201  }
202  }
203 
204  if(count($archive_files) > 0)
205  {
206  foreach($archive_files as $exp_file)
207  {
208  if ($exp_file == '.' || $exp_file == '..')
209  {
210  continue;
211  }
212  $file_arr = explode("_", $exp_file);
213  array_push($data, array(
214  'file' => $exp_file,
215  'size' => filesize($archive_dir."/".$exp_file),
216  'timestamp' => $file_arr[4]
217  ));
218  }
219  }
220 
221  $table = $this->buildExportTableGUI();
222  $table->setSelectAllCheckbox("file");
223  foreach($this->getCustomColumns() as $c)
224  {
225  $table->addCustomColumn($c["txt"], $c["obj"], $c["func"]);
226  }
227 
228  foreach($this->getCustomMultiCommands() as $c)
229  {
230  $table->addCustomMultiCommand($c["txt"], "multi_".$c["func"]);
231  }
232 
233  $table->setData($data);
234  $tpl->setContent($table->getHTML());
235  }
This class represents a selection list property in a property form.
global $tpl
Definition: ilias.php:8
global $ilCtrl
Definition: ilias.php:18
getCustomColumns()
Get custom columns.
if(!is_array($argv)) $options
getZipExportDirectory()
Return the export directory, where zips are placed.
Create styles array
The data for the language used.
getFormats()
Get formats.
getCustomMultiCommands()
Get custom multi commands.
Class ilTestArchiver.
Create new PHPExcel object
obj_idprivate
global $lng
Definition: privfeed.php:17
getParentGUI()
get parent gui
+ Here is the call graph for this function:

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