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

Export class for SCORM 2004 object. More...

+ Collaboration diagram for ilScorm2004Export:

Public Member Functions

 __construct (&$a_cont_obj, $a_mode="SCORM 2004 3rd")
 Constructor @access public. More...
 
 getExportDirectory ()
 
 getExportDirectoryForType ($type)
 
 getExportSubDirectory ()
 
 getExportFileName ()
 
 getSupportedExportTypes ()
 
 getInstId ()
 
 buildExportFile ()
 build export file (complete zip file) More...
 
 buildExportFileSCORM ($ver)
 build xml export file More...
 
 buildExportFileHTML ()
 build xml export file More...
 
 buildExportFileHTMLOne ()
 build xml export file More...
 
 buildExportFileISO ()
 
 buildExportFilePDF ()
 
 createExportDirectory ()
 

Private Attributes

 $err
 
 $db
 
 $ilias
 
 $cont_obj
 
 $cont_obj_id
 
 $inst_id
 
 $mode
 
 $export_types
 
 $module_id
 
 $date
 
 $settings
 
 $export_dir
 
 $subdir
 
 $filename
 

Detailed Description

Export class for SCORM 2004 object.

Definition at line 10 of file class.ilSCORM2004Export.php.

Constructor & Destructor Documentation

◆ __construct()

ilScorm2004Export::__construct ( $a_cont_obj,
  $a_mode = "SCORM 2004 3rd" 
)

Constructor @access public.

Definition at line 32 of file class.ilSCORM2004Export.php.

33 {
34 global $ilErr, $ilDB, $ilias;
35
36 $this->export_types = array("SCORM 2004 3rd","SCORM 2004 4th","SCORM 1.2","HTML","ISO","PDF",
37 "HTMLOne");
38
39 if(!in_array($a_mode,$this->export_types))
40 die("Unsupported format");
41
42 $this->cont_obj = $a_cont_obj;
43
44 $this->err = $ilErr;
45 $this->ilias = $ilias;
46 $this->db = $ilDB;
47 $this->mode = $a_mode;
48
49 $settings = $this->ilias->getAllSettings();
50
51 $this->inst_id = IL_INST_ID;
52
53 switch ($this->cont_obj->getType())
54 {
55 case 'sahs':
56 $this->module_id = $this->cont_obj->getId();
57 $this->cont_obj_id = $this->cont_obj->getId();
58 break;
59 case 'sco':
60 $this->module_id = $this->cont_obj->slm_id;
61 $this->cont_obj_id = $this->cont_obj->getId();
62 break;
63 }
64
65 $this->date = time();
66
67 $this->export_dir = $this->getExportDirectory();
68 $this->subdir = $this->getExportSubDirectory();
69 $this->filename = $this->getExportFileName();
70 }
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
redirection script todo: (a better solution should control the processing via a xml file)
global $ilErr
Definition: raiseError.php:16
global $ilDB

References $ilDB, $ilErr, $ilias, $settings, date, getExportDirectory(), getExportFileName(), and getExportSubDirectory().

+ Here is the call graph for this function:

Member Function Documentation

◆ buildExportFile()

ilScorm2004Export::buildExportFile ( )

build export file (complete zip file)

@access public

Returns

Definition at line 134 of file class.ilSCORM2004Export.php.

135 {
136 switch ($this->mode)
137 {
138 case "SCORM 2004 3rd":
139 return $this->buildExportFileSCORM("2004 3rd");
140 case "SCORM 2004 4th":
141 return $this->buildExportFileSCORM("2004 4th");
142 case "SCORM 1.2":
143 return $this->buildExportFileSCORM("12");
144 case "HTML":
145 return $this->buildExportFileHTML();
146 case "HTMLOne":
147 return $this->buildExportFileHTMLOne();
148 case "ISO":
149 return $this->buildExportFileISO();
150 case "PDF":
151 return $this->buildExportFilePDF();
152 }
153 }
buildExportFileHTMLOne()
build xml export file
buildExportFileHTML()
build xml export file
buildExportFileSCORM($ver)
build xml export file

References buildExportFileHTML(), buildExportFileHTMLOne(), buildExportFileISO(), buildExportFilePDF(), and buildExportFileSCORM().

+ Here is the call graph for this function:

◆ buildExportFileHTML()

ilScorm2004Export::buildExportFileHTML ( )

build xml export file

Definition at line 204 of file class.ilSCORM2004Export.php.

205 {
206 require_once("./Services/Xml/classes/class.ilXmlWriter.php");
207
208 // init the mathjax rendering for HTML export
209 include_once './Services/MathJax/classes/class.ilMathJax.php';
211
212 // create directories
213 $this->createExportDirectory();
214 ilUtil::makeDir($this->export_dir."/".$this->subdir);
215
216 // get Log File
217 $expDir = $this->export_dir;
218 include_once './Services/Logging/classes/class.ilLog.php';
219 $expLog = new ilLog($expDir, "export.log");
220 $expLog->delete();
221 $expLog->setLogFormat("");
222 $expLog->write(date("[y-m-d H:i:s] ")."Start Export");
223
224 // get xml content
225 $this->cont_obj->exportHTML($this->inst_id, $this->export_dir."/".$this->subdir, $expLog);
226
227 // zip the file
228 ilUtil::zip($this->export_dir."/".$this->subdir, $this->export_dir."/".$this->subdir.".zip", true);
229
230 ilUtil::delDir($this->export_dir."/".$this->subdir);
231
232 $expLog->write(date("[y-m-d H:i:s] ")."Finished Export");
233
234 return $this->export_dir."/".$this->subdir.".zip";
235 }
logging
Definition: class.ilLog.php:19
static getInstance()
Singleton: get instance.
const PURPOSE_EXPORT
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
static zip($a_dir, $a_file, $compress_content=false)
static makeDir($a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...

References $export_dir, createExportDirectory(), date, ilUtil\delDir(), ilMathJax\getInstance(), ilUtil\makeDir(), ilMathJax\PURPOSE_EXPORT, and ilUtil\zip().

Referenced by buildExportFile().

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

◆ buildExportFileHTMLOne()

ilScorm2004Export::buildExportFileHTMLOne ( )

build xml export file

Definition at line 240 of file class.ilSCORM2004Export.php.

241 {
242 require_once("./Services/Xml/classes/class.ilXmlWriter.php");
243
244 // init the mathjax rendering for HTML export
245 include_once './Services/MathJax/classes/class.ilMathJax.php';
247
248 // create directories
249 $this->createExportDirectory();
250 ilUtil::makeDir($this->export_dir."/".$this->subdir);
251
252 // get Log File
253 $expDir = $this->export_dir;
254 include_once './Services/Logging/classes/class.ilLog.php';
255 $expLog = new ilLog($expDir, "export.log");
256 $expLog->delete();
257 $expLog->setLogFormat("");
258 $expLog->write(date("[y-m-d H:i:s] ")."Start Export");
259
260 // get xml content
261 $this->cont_obj->exportHTMLOne($this->inst_id, $this->export_dir."/".$this->subdir, $expLog);
262
263 // zip the file
264 ilUtil::zip($this->export_dir."/".$this->subdir, $this->export_dir."/".$this->subdir.".zip", true);
265
266 ilUtil::delDir($this->export_dir."/".$this->subdir);
267
268 $expLog->write(date("[y-m-d H:i:s] ")."Finished Export");
269
270 return $this->export_dir."/".$this->subdir.".zip";
271 }

References $export_dir, createExportDirectory(), date, ilUtil\delDir(), ilMathJax\getInstance(), ilUtil\makeDir(), ilMathJax\PURPOSE_EXPORT, and ilUtil\zip().

Referenced by buildExportFile().

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

◆ buildExportFileISO()

ilScorm2004Export::buildExportFileISO ( )

Definition at line 273 of file class.ilSCORM2004Export.php.

274 {
275 global $ilBench;
276 $result = "";
277 $ilBench->start("ContentObjectExport", "buildExportFile");
278
279 // init the mathjax rendering for HTML export
280 include_once './Services/MathJax/classes/class.ilMathJax.php';
282
283 require_once("./Services/Xml/classes/class.ilXmlWriter.php");
284
285 // create directories
286 $this->createExportDirectory();
287 ilUtil::makeDir($this->export_dir."/".$this->subdir);
288
289 // get Log File
290 $expDir = $this->export_dir;
291 include_once './Services/Logging/classes/class.ilLog.php';
292 $expLog = new ilLog($expDir, "export.log");
293 $expLog->delete();
294 $expLog->setLogFormat("");
295 $expLog->write(date("[y-m-d H:i:s] ")."Start Export");
296
297 // get xml content
298
299 $ilBench->start("ContentObjectExport", "buildExportFile_getXML");
300 $this->cont_obj->exportHTML($this->inst_id, $this->export_dir."/".$this->subdir, $expLog);
301 $ilBench->stop("ContentObjectExport", "buildExportFile_getXML");
302
303 // zip the file
304 $ilBench->start("ContentObjectExport", "buildExportFile_zipFile");
305 if(ilUtil::CreateIsoFromFolder($this->export_dir."/".$this->subdir, $this->export_dir."/".$this->subdir.".iso"))
306 {
307 $result = $this->export_dir."/".$this->subdir.".iso";
308 }
309 $ilBench->stop("ContentObjectExport", "buildExportFile_zipFile");
310
311 ilUtil::delDir($this->export_dir."/".$this->subdir);
312
313 $expLog->write(date("[y-m-d H:i:s] ")."Finished Export");
314 $ilBench->stop("ContentObjectExport", "buildExportFile");
315
316 return $result;
317 }
$result
static CreateIsoFromFolder($a_dir, $a_file)
global $ilBench
Definition: ilias.php:18

References $export_dir, $ilBench, $result, createExportDirectory(), ilUtil\CreateIsoFromFolder(), date, ilUtil\delDir(), ilMathJax\getInstance(), ilUtil\makeDir(), and ilMathJax\PURPOSE_EXPORT.

Referenced by buildExportFile().

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

◆ buildExportFilePDF()

ilScorm2004Export::buildExportFilePDF ( )

Definition at line 319 of file class.ilSCORM2004Export.php.

320 {
321 global $ilBench;
322 /*include_once('./Services/WebServices/RPC/classes/class.ilRPCServerSettings.php');
323 $pp = ilRPCServerSettings::getInstance();
324 if(!$pp->isEnabled()||!$pp->pingServer())
325 {
326 $this->ilias->raiseError("Xml Rpc Server is not running. Check Administration/Webservices/Java-Server settings", $this->ilias->error_obj->MESSAGE);
327 return;
328 }*/
329
330 $ilBench->start("ContentObjectExport", "buildExportFile");
331
332 // don't render mathjax before fo code is generated
333 include_once './Services/MathJax/classes/class.ilMathJax.php';
335
336 require_once("./Services/Xml/classes/class.ilXmlWriter.php");
337
338 // create directories
339 $this->createExportDirectory();
340 ilUtil::makeDir($this->export_dir."/".$this->subdir);
341
342 // get Log File
343 $expDir = $this->export_dir;
344 include_once './Services/Logging/classes/class.ilLog.php';
345 $expLog = new ilLog($expDir, "export.log");
346 $expLog->delete();
347 $expLog->setLogFormat("");
348 $expLog->write(date("[y-m-d H:i:s] ")."Start Export");
349
350 $ilBench->start("ContentObjectExport", "buildExportFile_getXML");
351 $fo_string = $this->cont_obj->exportPDF($this->inst_id, $this->export_dir."/".$this->subdir, $expLog);
352
353 // now render mathjax for pdf generation
354 $fo_string = ilMathJax::getInstance()
357 ->insertLatexImages($fo_string);
358
359 $ilBench->stop("ContentObjectExport", "buildExportFile_getXML");
360
361 $ilBench->start("ContentObjectExport", "buildExportFile_pdfFile");
362 fputs(fopen($this->export_dir."/".$this->subdir.'/temp.fo','w+'),$fo_string);
363
364 global $ilLog;
365 include_once './Services/WebServices/RPC/classes/class.ilRpcClientFactory.php';
366 try
367 {
368 $pdf_base64 = ilRpcClientFactory::factory('RPCTransformationHandler')->ilFO2PDF($fo_string);
369 //ilUtil::deliverData($pdf_base64->scalar,'learning_progress.pdf','application/pdf');
370 fputs(fopen($this->export_dir.'/'.$this->subdir.'.pdf','w+'),$pdf_base64->scalar);
371 }
372 catch(Exception $e)
373 {
374 ilUtil::sendFailure($e->getMessage(),true);
375 return false;
376 }
377 $ilBench->stop("ContentObjectExport", "buildExportFile_pdfFile");
378
379 ilUtil::delDir($this->export_dir."/".$this->subdir);
380
381 $expLog->write(date("[y-m-d H:i:s] ")."Finished Export");
382 $ilBench->stop("ContentObjectExport", "buildExportFile");
383
384 return $this->export_dir."/".$this->subdir.".pdf";
385 }
const PURPOSE_PDF
const PURPOSE_DEFERRED_PDF
const RENDER_PNG_AS_FO_FILE
static factory($a_package, $a_timeout=0)
Creates an ilRpcClient instance to our ilServer.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.

References $export_dir, $ilBench, $ilLog, createExportDirectory(), date, ilUtil\delDir(), ilRpcClientFactory\factory(), ilMathJax\getInstance(), ilUtil\makeDir(), ilMathJax\PURPOSE_DEFERRED_PDF, ilMathJax\PURPOSE_PDF, ilMathJax\RENDER_PNG_AS_FO_FILE, and ilUtil\sendFailure().

Referenced by buildExportFile().

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

◆ buildExportFileSCORM()

ilScorm2004Export::buildExportFileSCORM (   $ver)

build xml export file

Definition at line 158 of file class.ilSCORM2004Export.php.

159 {
160 global $ilBench;
161
162 $ilBench->start("ContentObjectExport", "buildExportFile");
163
164 // init the mathjax rendering for HTML export
165 include_once './Services/MathJax/classes/class.ilMathJax.php';
167
168 require_once("./Services/Xml/classes/class.ilXmlWriter.php");
169
170 // create directories
171 $this->createExportDirectory();
172 ilUtil::makeDir($this->export_dir."/".$this->subdir);
173
174 // get Log File
175 $expDir = $this->export_dir;
176 include_once './Services/Logging/classes/class.ilLog.php';
177 $expLog = new ilLog($expDir, "export.log");
178 $expLog->delete();
179 $expLog->setLogFormat("");
180 $expLog->write(date("[y-m-d H:i:s] ")."Start Export");
181
182 // get xml content
183
184 $ilBench->start("ContentObjectExport", "buildExportFile_getXML");
185 $this->cont_obj->exportScorm($this->inst_id, $this->export_dir."/".$this->subdir, $ver, $expLog);
186 $ilBench->stop("ContentObjectExport", "buildExportFile_getXML");
187
188 // zip the file
189 $ilBench->start("ContentObjectExport", "buildExportFile_zipFile");
190 ilUtil::zip($this->export_dir."/".$this->subdir, $this->export_dir."/".$this->subdir.".zip", true);
191 $ilBench->stop("ContentObjectExport", "buildExportFile_zipFile");
192
193 ilUtil::delDir($this->export_dir."/".$this->subdir);
194
195 $expLog->write(date("[y-m-d H:i:s] ")."Finished Export");
196 $ilBench->stop("ContentObjectExport", "buildExportFile");
197
198 return $this->export_dir."/".$this->subdir.".zip";
199 }

References $export_dir, $ilBench, createExportDirectory(), date, ilUtil\delDir(), ilMathJax\getInstance(), ilUtil\makeDir(), ilMathJax\PURPOSE_EXPORT, and ilUtil\zip().

Referenced by buildExportFile().

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

◆ createExportDirectory()

ilScorm2004Export::createExportDirectory ( )

Definition at line 387 of file class.ilSCORM2004Export.php.

388 {
389 $lm_data_dir = ilUtil::getDataDir()."/lm_data";
390 if(!is_writable($lm_data_dir))
391 {
392 $this->ilias->raiseError("Content object Data Directory (".$lm_data_dir.") not writeable.",$this->ilias->error_obj->FATAL);
393 }
394 // create learning module directory (data_dir/lm_data/lm_<id>)
395 $lm_dir = $lm_data_dir."/lm_".$this->module_id;
396 ilUtil::makeDir($lm_dir);
397 if(!@is_dir($lm_dir))
398 {
399 $this->ilias->raiseError("Creation of Learning Module Directory failed.",$this->ilias->error_obj->FATAL);
400 }
401
402 //$export_dir = $lm_dir."/export_".$this->mode;
403 ilUtil::makeDir($this->export_dir);
404
405 if(!@is_dir($this->export_dir))
406 {
407 $this->ilias->raiseError("Creation of Export Directory failed.",$this->ilias->error_obj->FATAL);
408 }
409 }
static getDataDir()
get data directory (outside webspace)

References $module_id, ilUtil\getDataDir(), and ilUtil\makeDir().

Referenced by buildExportFileHTML(), buildExportFileHTMLOne(), buildExportFileISO(), buildExportFilePDF(), and buildExportFileSCORM().

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

◆ getExportDirectory()

ilScorm2004Export::getExportDirectory ( )

Definition at line 72 of file class.ilSCORM2004Export.php.

73 {
74 return $this->getExportDirectoryForType($this->mode);
75 }

References getExportDirectoryForType().

Referenced by __construct().

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

◆ getExportDirectoryForType()

ilScorm2004Export::getExportDirectoryForType (   $type)

Definition at line 77 of file class.ilSCORM2004Export.php.

78 {
79 $ret = ilUtil::getDataDir()."/lm_data"."/lm_".$this->module_id."/export_";
80 switch($type)
81 {
82 case "ISO":
83 return $ret."_iso";
84 case "PDF":
85 return $ret."_pdf";
86 case "SCORM 2004 3rd":
87 return $ret."_scorm2004";
88 case "SCORM 2004 4th":
89 return $ret."_scorm2004_4th";
90 case "HTML":
91 return $ret."_html";
92 case "HTMLOne":
93 return $ret."_html_one";
94 case "SCORM 1.2":
95 return $ret."_scorm12";
96 }
97
98 }
$ret
Definition: parser.php:6

References $ret, and ilUtil\getDataDir().

Referenced by getExportDirectory().

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

◆ getExportFileName()

ilScorm2004Export::getExportFileName ( )

Definition at line 105 of file class.ilSCORM2004Export.php.

106 {
107 switch($this->mode)
108 {
109 case "ISO":
110 return $this->subdir.".iso";
111 case "PDF":
112 return $this->subdir.".pdf";
113 default:
114 return $this->subdir.".zip";
115 }
116 }

Referenced by __construct().

+ Here is the caller graph for this function:

◆ getExportSubDirectory()

ilScorm2004Export::getExportSubDirectory ( )

Definition at line 100 of file class.ilSCORM2004Export.php.

101 {
102 return $this->date."__".$this->inst_id."__".$this->cont_obj->getType()."_".$this->cont_obj_id;
103 }

References $cont_obj_id, and date.

Referenced by __construct().

+ Here is the caller graph for this function:

◆ getInstId()

ilScorm2004Export::getInstId ( )

Definition at line 123 of file class.ilSCORM2004Export.php.

124 {
125 return $this->inst_id;
126 }

References $inst_id.

◆ getSupportedExportTypes()

ilScorm2004Export::getSupportedExportTypes ( )

Definition at line 118 of file class.ilSCORM2004Export.php.

References $export_types.

Field Documentation

◆ $cont_obj

ilScorm2004Export::$cont_obj
private

Definition at line 15 of file class.ilSCORM2004Export.php.

◆ $cont_obj_id

ilScorm2004Export::$cont_obj_id
private

Definition at line 16 of file class.ilSCORM2004Export.php.

Referenced by getExportSubDirectory().

◆ $date

ilScorm2004Export::$date
private

Definition at line 22 of file class.ilSCORM2004Export.php.

◆ $db

ilScorm2004Export::$db
private

Definition at line 13 of file class.ilSCORM2004Export.php.

◆ $err

ilScorm2004Export::$err
private

Definition at line 12 of file class.ilSCORM2004Export.php.

◆ $export_dir

ilScorm2004Export::$export_dir
private

◆ $export_types

ilScorm2004Export::$export_types
private

Definition at line 19 of file class.ilSCORM2004Export.php.

Referenced by getSupportedExportTypes().

◆ $filename

ilScorm2004Export::$filename
private

Definition at line 26 of file class.ilSCORM2004Export.php.

◆ $ilias

ilScorm2004Export::$ilias
private

Definition at line 14 of file class.ilSCORM2004Export.php.

Referenced by __construct().

◆ $inst_id

ilScorm2004Export::$inst_id
private

Definition at line 17 of file class.ilSCORM2004Export.php.

Referenced by getInstId().

◆ $mode

ilScorm2004Export::$mode
private

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

◆ $module_id

ilScorm2004Export::$module_id
private

Definition at line 20 of file class.ilSCORM2004Export.php.

Referenced by createExportDirectory().

◆ $settings

ilScorm2004Export::$settings
private

Definition at line 23 of file class.ilSCORM2004Export.php.

Referenced by __construct().

◆ $subdir

ilScorm2004Export::$subdir
private

Definition at line 25 of file class.ilSCORM2004Export.php.


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