ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilQuestionpoolExport Class Reference

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

+ Collaboration diagram for ilQuestionpoolExport:

Public Member Functions

 __construct (protected ilObjQuestionPool $qpl_obj, protected string $mode="xml", protected ?array $questions=null)
 Constructor @access public. More...
 
 getInstId ()
 
 buildExportFile ()
 build export file (complete zip file) More...
 
 buildExportFileXML ()
 build xml export file More...
 
 exportXHTMLMediaObjects ($a_export_dir)
 

Data Fields

ilErrorHandling $err
 
ilDBInterface $db
 
ILIAS $ilias
 
string $inst_id
 
ilLanguage $lng
 

Private Attributes

string $export_dir = ''
 
string $subdir = ''
 
string $filename = ''
 
string $zipfilename = ''
 
string $qti_filename = ''
 
ilXmlWriter $xml
 

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 class for questionpools

Author
Helmut Schottmüller helmu.nosp@m.t.sc.nosp@m.hottm.nosp@m.uell.nosp@m.er@ma.nosp@m.c.co.nosp@m.m
Version
$Id$

\

Definition at line 28 of file class.ilQuestionpoolExport.php.

Constructor & Destructor Documentation

◆ __construct()

ilQuestionpoolExport::__construct ( protected ilObjQuestionPool  $qpl_obj,
protected string  $mode = "xml",
protected ?array  $questions = null 
)

Constructor @access public.

Definition at line 47 of file class.ilQuestionpoolExport.php.

51 {
52 global $DIC;
53 $this->err = $DIC['ilErr'];
54 $this->db = $DIC['ilDB'];
55 $this->ilias = $DIC['ilias'];
56 $this->lng = $DIC['lng'];
57
58 if (!is_array($this->questions)) {
59 $this->questions = $this->qpl_obj->getAllQuestionIds();
60 }
61
62 $this->inst_id = IL_INST_ID;
63 $date = time();
64
65 $this->qpl_obj->createExportDirectory();
66 switch ($this->mode) {
67 case "xml":
68 $this->export_dir = $this->qpl_obj->getExportDirectory('xml');
69 $this->subdir = $date . "__" . $this->inst_id . "__" .
70 "qpl" . "_" . $this->qpl_obj->getId();
71 $this->filename = $this->subdir . ".xml";
72 $this->qti_filename = $date . "__" . $this->inst_id . "__" .
73 "qti" . "_" . $this->qpl_obj->getId() . ".xml";
74 break;
75 case "xlsx":
76 $this->export_dir = $this->qpl_obj->getExportDirectory('xlsx');
77 $this->filename = $date . "__" . $this->inst_id . "__" .
78 "qpl" . "_" . $this->qpl_obj->getId() . ".xlsx";
79 $this->zipfilename = $date . "__" . $this->inst_id . "__" .
80 "qpl" . "_" . $this->qpl_obj->getId() . ".zip";
81 break;
82 default:
83 $this->export_dir = $this->qpl_obj->getExportDirectory('zip');
84 $this->subdir = $date . "__" . $this->inst_id . "__" .
85 "qpl" . "_" . $this->qpl_obj->getId();
86 $this->filename = $this->subdir . ".xml";
87 $this->qti_filename = $date . "__" . $this->inst_id . "__" .
88 "qti" . "_" . $this->qpl_obj->getId() . ".xml";
89 break;
90 }
91 }
const IL_INST_ID
Definition: constants.php:40
Class ilObjForumAdministration.
global $DIC
Definition: shib_login.php:26

References $DIC, IL_INST_ID, and ILIAS\Repository\lng().

+ Here is the call graph for this function:

Member Function Documentation

◆ buildExportFile()

ilQuestionpoolExport::buildExportFile ( )

build export file (complete zip file)

Definition at line 102 of file class.ilQuestionpoolExport.php.

102 : string
103 {
104 switch ($this->mode) {
105 case "xlsx":
106 return $this->buildExportFileXLSX();
107 case "xml":
108 default:
109 return $this->buildExportFileXML();
110 }
111 }
buildExportFileXML()
build xml export file

References buildExportFileXML().

+ Here is the call graph for this function:

◆ buildExportFileXML()

ilQuestionpoolExport::buildExportFileXML ( )

build xml export file

Definition at line 116 of file class.ilQuestionpoolExport.php.

116 : string
117 {
118 global $DIC;
119 $ilBench = $DIC['ilBench'];
120
121 $ilBench->start("QuestionpoolExport", "buildExportFile");
122
123 $this->xml = new ilXmlWriter();
124 $this->xml->xmlSetDtdDef("<!DOCTYPE Test SYSTEM \"http://www.ilias.uni-koeln.de/download/dtd/ilias_co.dtd\">");
125 $this->xml->xmlSetGenCmt("Export of ILIAS Test Questionpool " .
126 $this->qpl_obj->getId() . " of installation " . $this->inst_id);
127 $this->xml->xmlHeader();
128
129 ilFileUtils::makeDir($this->export_dir . "/" . $this->subdir);
130 ilFileUtils::makeDir($this->export_dir . "/" . $this->subdir . "/objects");
131
132 $expDir = $this->qpl_obj->getExportDirectory();
134
135 $expLog = new ilLog($expDir, "export.log");
136 $expLog->delete();
137 $expLog->setLogFormat("");
138 $expLog->write(date("[y-m-d H:i:s] ") . "Start Export");
139
140 $qti_file = fopen($this->export_dir . "/" . $this->subdir . "/" . $this->qti_filename, "w");
141 fwrite($qti_file, $this->qpl_obj->questionsToXML($this->questions));
142 fclose($qti_file);
143
144 $ilBench->start("QuestionpoolExport", "buildExportFile_getXML");
145 $this->qpl_obj->objectToXmlWriter(
146 $this->xml,
147 $this->inst_id,
148 $this->export_dir . "/" . $this->subdir,
149 $expLog,
150 $this->questions
151 );
152 $ilBench->stop("QuestionpoolExport", "buildExportFile_getXML");
153
154 $ilBench->start("QuestionpoolExport", "buildExportFile_dumpToFile");
155 $this->xml->xmlDumpFile($this->export_dir . "/" . $this->subdir . "/" . $this->filename, false);
156 $ilBench->stop("QuestionpoolExport", "buildExportFile_dumpToFile");
157
158 $ilBench->start("QuestionpoolExport", "buildExportFile_saveAdditionalMobs");
159 $this->exportXHTMLMediaObjects($this->export_dir . "/" . $this->subdir);
160 $ilBench->stop("QuestionpoolExport", "buildExportFile_saveAdditionalMobs");
161
162 $ilBench->start("QuestionpoolExport", "buildExportFile_zipFile");
163 ilFileUtils::zip($this->export_dir . "/" . $this->subdir, $this->export_dir . "/" . $this->subdir . ".zip");
164
165 $ilBench->stop("QuestionpoolExport", "buildExportFile_zipFile");
166
167 $expLog->write(date("[y-m-d H:i:s] ") . "Finished Export");
168 $ilBench->stop("QuestionpoolExport", "buildExportFile");
169
170 return $this->export_dir . "/" . $this->subdir . ".zip";
171 }
static makeDirParents(string $a_dir)
Create a new directory and all parent directories.
static zip(string $a_dir, string $a_file, bool $compress_content=false)
static makeDir(string $a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: class.ilLog.php:31
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

References $DIC, exportXHTMLMediaObjects(), ilFileUtils\makeDir(), ilFileUtils\makeDirParents(), and ilFileUtils\zip().

Referenced by buildExportFile().

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

◆ exportXHTMLMediaObjects()

ilQuestionpoolExport::exportXHTMLMediaObjects (   $a_export_dir)

Definition at line 173 of file class.ilQuestionpoolExport.php.

173 : void
174 {
175 foreach ($this->questions as $question_id) {
176 $mobs = ilObjMediaObject::_getMobsOfObject("qpl:html", $question_id);
177 foreach ($mobs as $mob) {
178 if (ilObjMediaObject::_exists($mob)) {
179 $mob_obj = new ilObjMediaObject($mob);
180 $mob_obj->exportFiles($a_export_dir);
181 unset($mob_obj);
182 }
183 }
184 }
185 }
static _exists(int $id, bool $reference=false, ?string $type=null)
checks if an object exists in object_data
static _getMobsOfObject(string $a_type, int $a_id, int $a_usage_hist_nr=0, string $a_lang="-")

References ilObjMediaObject\_exists(), and ilObjMediaObject\_getMobsOfObject().

Referenced by buildExportFileXML().

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

◆ getInstId()

ilQuestionpoolExport::getInstId ( )

Definition at line 93 of file class.ilQuestionpoolExport.php.

94 {
95 return $this->inst_id;
96 }

References $inst_id.

Field Documentation

◆ $db

ilDBInterface ilQuestionpoolExport::$db

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

◆ $err

ilErrorHandling ilQuestionpoolExport::$err

Definition at line 30 of file class.ilQuestionpoolExport.php.

◆ $export_dir

string ilQuestionpoolExport::$export_dir = ''
private

Definition at line 36 of file class.ilQuestionpoolExport.php.

◆ $filename

string ilQuestionpoolExport::$filename = ''
private

Definition at line 38 of file class.ilQuestionpoolExport.php.

◆ $ilias

ILIAS ilQuestionpoolExport::$ilias

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

◆ $inst_id

string ilQuestionpoolExport::$inst_id

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

Referenced by getInstId().

◆ $lng

ilLanguage ilQuestionpoolExport::$lng

Definition at line 34 of file class.ilQuestionpoolExport.php.

◆ $qti_filename

string ilQuestionpoolExport::$qti_filename = ''
private

Definition at line 40 of file class.ilQuestionpoolExport.php.

◆ $subdir

string ilQuestionpoolExport::$subdir = ''
private

Definition at line 37 of file class.ilQuestionpoolExport.php.

◆ $xml

ilXmlWriter ilQuestionpoolExport::$xml
private

Definition at line 41 of file class.ilQuestionpoolExport.php.

◆ $zipfilename

string ilQuestionpoolExport::$zipfilename = ''
private

Definition at line 39 of file class.ilQuestionpoolExport.php.


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