ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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 50 of file class.ilTestExportGUI.php.

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

Referenced by listExportFiles().

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

◆ createTestArchiveExport()

ilTestExportGUI::createTestArchiveExport ( )

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

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

113  {
114  global $ilAccess, $ilCtrl, $ilDB, $lng;
115 
116  if ($ilAccess->checkAccess("write", "", $this->obj->ref_id))
117  {
118  require_once 'Modules/Test/classes/class.ilTestEvaluation.php';
119  $evaluation = new ilTestEvaluation($ilDB, $this->obj->getTestId());
120  $allActivesPasses = $evaluation->getAllActivesPasses();
121 
122  require_once 'Modules/Test/classes/class.ilTestParticipantData.php';
123  $participantData = new ilTestParticipantData($ilDB, $lng);
124  $participantData->setActiveIds(array_keys($allActivesPasses));
125  $participantData->load($this->obj->getTestId());
126 
127  require_once 'Modules/Test/classes/class.ilTestArchiveService.php';
128  $archiveService = new ilTestArchiveService($this->obj);
129  $archiveService->setParticipantData($participantData);
130  $archiveService->archivePassesByActives($allActivesPasses);
131 
132  include_once("./Modules/Test/classes/class.ilTestArchiver.php");
133  $test_id = $this->obj->getId();
134  $archive_exp = new ilTestArchiver($test_id);
135 
136  require_once './Modules/Test/classes/class.ilTestScoring.php';
137  $scoring = new ilTestScoring($this->obj);
138  $best_solution = $scoring->calculateBestSolutionForTest();
139 
140  $tmpFileName = ilUtil::ilTempnam();
141  if(!is_dir($tmpFileName))
142  {
143  ilUtil::makeDirParents($tmpFileName);
144  }
145 
146  $directory_name = realpath($tmpFileName);
147  $file_name = $directory_name . DIRECTORY_SEPARATOR . 'Best_Solution.pdf';
148 
149  require_once './Modules/Test/classes/class.ilTestPDFGenerator.php';
150  $generator = new ilTestPDFGenerator();
151  $generator->generatePDF($best_solution, ilTestPDFGenerator::PDF_OUTPUT_FILE, $file_name);
152  $archive_exp->handInTestBestSolution($best_solution, $file_name);
153  ilUtil::delDir($directory_name);
154 
155  $archive_exp->updateTestArchive();
156  $archive_exp->compressTestArchive();
157  }
158  else
159  {
160  ilUtil::sendInfo("cannot_export_archive", TRUE);
161  }
162  $ilCtrl->redirectByClass('iltestexportgui');
163  }
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.
Class ilTestArchiver.
global $lng
Definition: privfeed.php:40
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 165 of file class.ilTestExportGUI.php.

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

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

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