ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
ilQuestionpoolExport Class Reference

Export class for questionpools. More...

+ Collaboration diagram for ilQuestionpoolExport:

Public Member Functions

 ilQuestionpoolExport (&$a_qpl_obj, $a_mode="xml", $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)
 
 buildExportFileXLS ()
 build xml export file More...
 

Data Fields

 $err
 
 $db
 
 $ilias
 
 $qpl_obj
 
 $questions
 
 $inst_id
 
 $mode
 
 $lng
 

Detailed Description

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 15 of file class.ilQuestionpoolExport.php.

Member Function Documentation

◆ buildExportFile()

ilQuestionpoolExport::buildExportFile ( )

build export file (complete zip file)

@access public

Returns

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

95 {
96 switch ($this->mode)
97 {
98 case "xls":
99 return $this->buildExportFileXLS();
100 break;
101 case "xml":
102 default:
103 return $this->buildExportFileXML();
104 break;
105 }
106 }
buildExportFileXLS()
build xml export file
buildExportFileXML()
build xml export file

References buildExportFileXLS(), and buildExportFileXML().

+ Here is the call graph for this function:

◆ buildExportFileXLS()

ilQuestionpoolExport::buildExportFileXLS ( )

build xml export file

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

217 {
218 global $ilBench;
219
220 $ilBench->start("QuestionpoolExport", "buildExportFile");
221 include_once "./Services/Excel/classes/class.ilExcelWriterAdapter.php";
222 $adapter = new ilExcelWriterAdapter($this->export_dir . "/" . $this->filename, FALSE);
223 $workbook = $adapter->getWorkbook();
224 $workbook->setVersion(8); // Use Excel97/2000 Format
225 $format_bold =& $workbook->addFormat();
226 $format_bold->setBold();
227 $format_percent =& $workbook->addFormat();
228 $format_percent->setNumFormat("0.00%");
229 $format_datetime =& $workbook->addFormat();
230 $format_datetime->setNumFormat("DD/MM/YYYY hh:mm:ss");
231 $format_title =& $workbook->addFormat();
232 $format_title->setBold();
233 $format_title->setColor('black');
234 $format_title->setPattern(1);
235 $format_title->setFgColor('silver');
236 $worksheet =& $workbook->addWorksheet();
237 $row = 0;
238 $col = 0;
239 // title row
240 include_once "./Services/Excel/classes/class.ilExcelUtils.php";
241 include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
242 $worksheet->write($row, $col, ilExcelUtils::_convert_text($this->lng->txt("title"), "latin1"), $format_title);
243 $col++;
244 $worksheet->write($row, $col, ilExcelUtils::_convert_text($this->lng->txt("description"), "latin1"), $format_title);
245 $col++;
246 $worksheet->write($row, $col, ilExcelUtils::_convert_text($this->lng->txt("question_type"), "latin1"), $format_title);
247 $col++;
248 $worksheet->write($row, $col, ilExcelUtils::_convert_text($this->lng->txt("author"), "latin1"), $format_title);
249 $col++;
250 $worksheet->write($row, $col, ilExcelUtils::_convert_text($this->lng->txt("create_date"), "latin1"), $format_title);
251 $col++;
252 $worksheet->write($row, $col, ilExcelUtils::_convert_text($this->lng->txt("last_update"), "latin1"), $format_title);
253 $col = 0;
254 $row++;
255 $questions = $this->qpl_obj->getQuestionList();
256 foreach ($questions as $question)
257 {
258 $worksheet->write($row, $col, ilExcelUtils::_convert_text($question["title"], "latin1"));
259 $col++;
260 $worksheet->write($row, $col, ilExcelUtils::_convert_text($question["description"], "latin1"));
261 $col++;
262 $worksheet->write($row, $col, ilExcelUtils::_convert_text($this->lng->txt($question["type_tag"]), "latin1"));
263 $col++;
264 $worksheet->write($row, $col, ilExcelUtils::_convert_text($question["author"], "latin1"));
265 $col++;
266
267// ilDatePresentation::formatDate(new ilDateTime($question["created"],IL_CAL_UNIX))
268 $worksheet->write($row, $col, ilExcelUtils::_convert_text(ilFormat::formatDate(date('Y-m-d', $question["created"]), "date", false, false), "latin1"));
269 $col++;
270 $worksheet->write($row, $col, ilExcelUtils::_convert_text(ilFormat::formatDate(date('Y-m-d', $question["tstamp"]), "date", false, false), "latin1"));
271 $col = 0;
272 $row++;
273 }
274 $workbook->close();
275 ilUtil::zip($this->export_dir . "/" . $this->filename, $this->export_dir . "/" . $this->zipfilename);
276 if (@file_exists($this->export_dir . "/" . $this->filename)) @unlink($this->export_dir . "/" . $this->filename);
277 }
_convert_text($a_text, $a_target="has been removed")
Class ilExcelWriterAdapter.
formatDate($a_date, $a_mode="datetime", $a_omit_seconds=false, $a_relative=TRUE)
format a date according to the user language shortcut for Format::fmtDateTime @access public
static zip($a_dir, $a_file, $compress_content=false)
global $ilBench
Definition: ilias.php:18

References $ilBench, $questions, $row, ilExcelUtils\_convert_text(), ilFormat\formatDate(), and ilUtil\zip().

Referenced by buildExportFile().

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

◆ buildExportFileXML()

ilQuestionpoolExport::buildExportFileXML ( )

build xml export file

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

112 {
113 global $ilBench;
114
115 $ilBench->start("QuestionpoolExport", "buildExportFile");
116
117 include_once("./Services/Xml/classes/class.ilXmlWriter.php");
118 $this->xml = new ilXmlWriter;
119
120 // set dtd definition
121 $this->xml->xmlSetDtdDef("<!DOCTYPE Test SYSTEM \"http://www.ilias.uni-koeln.de/download/dtd/ilias_co.dtd\">");
122
123 // set generated comment
124 $this->xml->xmlSetGenCmt("Export of ILIAS Test Questionpool ".
125 $this->qpl_obj->getId()." of installation ".$this->inst.".");
126
127 // set xml header
128 $this->xml->xmlHeader();
129
130 // create directories
131 include_once "./Services/Utilities/classes/class.ilUtil.php";
132 ilUtil::makeDir($this->export_dir."/".$this->subdir);
133 ilUtil::makeDir($this->export_dir."/".$this->subdir."/objects");
134
135 // get Log File
136 $expDir = $this->qpl_obj->getExportDirectory();
137 ilUtil::makeDirParents($expDir);
138
139 include_once "./Services/Logging/classes/class.ilLog.php";
140 $expLog = new ilLog($expDir, "export.log");
141 $expLog->delete();
142 $expLog->setLogFormat("");
143 $expLog->write(date("[y-m-d H:i:s] ")."Start Export");
144
145 // write qti file
146 $qti_file = fopen($this->export_dir."/".$this->subdir."/".$this->qti_filename, "w");
147 fwrite($qti_file, $this->qpl_obj->toXML($this->questions));
148 fclose($qti_file);
149
150 // get xml content
151 $ilBench->start("QuestionpoolExport", "buildExportFile_getXML");
152 $this->qpl_obj->exportPagesXML($this->xml, $this->inst_id,
153 $this->export_dir."/".$this->subdir, $expLog, $this->questions);
154 $ilBench->stop("QuestionpoolExport", "buildExportFile_getXML");
155
156 // dump xml document to screen (only for debugging reasons)
157 /*
158 echo "<PRE>";
159 echo htmlentities($this->xml->xmlDumpMem($format));
160 echo "</PRE>";
161 */
162
163 // dump xml document to file
164 $ilBench->start("QuestionpoolExport", "buildExportFile_dumpToFile");
165 $this->xml->xmlDumpFile($this->export_dir."/".$this->subdir."/".$this->filename
166 , false);
167 $ilBench->stop("QuestionpoolExport", "buildExportFile_dumpToFile");
168
169 // add media objects which were added with tiny mce
170 $ilBench->start("QuestionpoolExport", "buildExportFile_saveAdditionalMobs");
171 $this->exportXHTMLMediaObjects($this->export_dir."/".$this->subdir);
172 $ilBench->stop("QuestionpoolExport", "buildExportFile_saveAdditionalMobs");
173
174 // zip the file
175 $ilBench->start("QuestionpoolExport", "buildExportFile_zipFile");
176 ilUtil::zip($this->export_dir."/".$this->subdir, $this->export_dir."/".$this->subdir.".zip");
177 if (@is_dir($this->export_dir."/".$this->subdir))
178 {
179 // Do not delete this dir, since it is required for container exports
180 #ilUtil::delDir($this->export_dir."/".$this->subdir);
181 }
182
183 $ilBench->stop("QuestionpoolExport", "buildExportFile_zipFile");
184
185 // destroy writer object
186 $this->xml->_XmlWriter;
187
188 $expLog->write(date("[y-m-d H:i:s] ")."Finished Export");
189 $ilBench->stop("QuestionpoolExport", "buildExportFile");
190
191 return $this->export_dir."/".$this->subdir.".zip";
192 }
logging
Definition: class.ilLog.php:19
static makeDirParents($a_dir)
Create a new directory and all parent directories.
static makeDir($a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...
XML writer class.
xmlSetDtdDef($dtdDef)
Sets dtd definition.

References $ilBench, exportXHTMLMediaObjects(), ilUtil\makeDir(), ilUtil\makeDirParents(), ilXmlWriter\xmlSetDtdDef(), and ilUtil\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 194 of file class.ilQuestionpoolExport.php.

195 {
196 include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
197
198 foreach ($this->questions as $question_id)
199 {
200 $mobs = ilObjMediaObject::_getMobsOfObject("qpl:html", $question_id);
201 foreach ($mobs as $mob)
202 {
204 {
205 $mob_obj =& new ilObjMediaObject($mob);
206 $mob_obj->exportFiles($a_export_dir);
207 unset($mob_obj);
208 }
209 }
210 }
211 }
Class ilObjMediaObject.
_getMobsOfObject($a_type, $a_id, $a_usage_hist_nr=0, $a_lang="-")
get mobs of object
static _exists($a_id)
checks wether a lm content object with specified id exists or not
$mobs

References $mobs, 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 82 of file class.ilQuestionpoolExport.php.

References $inst_id.

◆ ilQuestionpoolExport()

ilQuestionpoolExport::ilQuestionpoolExport ( $a_qpl_obj,
  $a_mode = "xml",
  $array_questions = null 
)

Constructor @access public.

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

34 {
35 global $ilErr, $ilDB, $ilias, $lng;
36
37 $this->qpl_obj =& $a_qpl_obj;
38 if (!is_array($array_questions))
39 {
40 $array_questions =& $a_qpl_obj->getAllQuestionIds();
41 }
42
43 $this->err =& $ilErr;
44 $this->ilias =& $ilias;
45 $this->db =& $ilDB;
46 $this->mode = $a_mode;
47 $this->lng =& $lng;
48
49 $settings = $this->ilias->getAllSettings();
50 $this->inst_id = IL_INST_ID;
51 $this->questions = $array_questions;
52 $date = time();
53 $this->qpl_obj->createExportDirectory();
54 switch($this->mode)
55 {
56 case "xml":
57 $this->export_dir = $this->qpl_obj->getExportDirectory('xml');
58 $this->subdir = $date."__".$this->inst_id."__".
59 "qpl"."_".$this->qpl_obj->getId();
60 $this->filename = $this->subdir.".xml";
61 $this->qti_filename = $date."__".$this->inst_id."__".
62 "qti"."_".$this->qpl_obj->getId().".xml";
63 break;
64 case "xls":
65 $this->export_dir = $this->qpl_obj->getExportDirectory('xls');
66 $this->filename = $date."__".$this->inst_id."__".
67 "qpl"."_".$this->qpl_obj->getId() . ".xls";
68 $this->zipfilename = $date."__".$this->inst_id."__".
69 "qpl"."_".$this->qpl_obj->getId() . ".zip";
70 break;
71 default:
72 $this->export_dir = $this->qpl_obj->getExportDirectory('zip');
73 $this->subdir = $date."__".$this->inst_id."__".
74 "qpl"."_".$this->qpl_obj->getId();
75 $this->filename = $this->subdir.".xml";
76 $this->qti_filename = $date."__".$this->inst_id."__".
77 "qti"."_".$this->qpl_obj->getId().".xml";
78 break;
79 }
80 }
redirection script todo: (a better solution should control the processing via a xml file)
global $ilDB

References $ilDB, $ilErr, $ilias, and $lng.

Field Documentation

◆ $db

ilQuestionpoolExport::$db

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

◆ $err

ilQuestionpoolExport::$err

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

◆ $ilias

ilQuestionpoolExport::$ilias

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

Referenced by ilQuestionpoolExport().

◆ $inst_id

ilQuestionpoolExport::$inst_id

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

Referenced by getInstId().

◆ $lng

ilQuestionpoolExport::$lng

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

Referenced by ilQuestionpoolExport().

◆ $mode

ilQuestionpoolExport::$mode

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

◆ $qpl_obj

ilQuestionpoolExport::$qpl_obj

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

◆ $questions

ilQuestionpoolExport::$questions

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

Referenced by buildExportFileXLS().


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