Export class for questionpools. More...
Public Member Functions | |
| ilQuestionpoolExport (&$a_qpl_obj, $a_mode="xml", $array_questions) | |
| Constructor public. | |
| getInstId () | |
| buildExportFile () | |
| build export file (complete zip file) | |
| buildExportFileXML () | |
| build xml export file | |
| exportXHTMLMediaObjects ($a_export_dir) | |
| buildExportFileXLS () | |
| build xml export file | |
Data Fields | |
| $err | |
| $db | |
| $ilias | |
| $qpl_obj | |
| $questions | |
| $inst_id | |
| $mode | |
| $lng | |
Export class for questionpools.
Definition at line 35 of file class.ilQuestionpoolExport.php.
| ilQuestionpoolExport::buildExportFile | ( | ) |
build export file (complete zip file)
public
Definition at line 98 of file class.ilQuestionpoolExport.php.
References buildExportFileXLS(), and buildExportFileXML().
{
switch ($this->mode)
{
case "xls":
return $this->buildExportFileXLS();
break;
case "xml":
default:
return $this->buildExportFileXML();
break;
}
}
Here is the call graph for this function:| ilQuestionpoolExport::buildExportFileXLS | ( | ) |
build xml export file
Definition at line 210 of file class.ilQuestionpoolExport.php.
References $ilBench, $questions, ilExcelUtils::_convert_text(), ilFormat::formatDate(), and ilFormat::ftimestamp2dateDB().
Referenced by buildExportFile().
{
global $ilBench;
$ilBench->start("QuestionpoolExport", "buildExportFile");
include_once "./classes/class.ilExcelWriterAdapter.php";
$adapter = new ilExcelWriterAdapter($this->export_dir . "/" . $this->filename, FALSE);
$workbook = $adapter->getWorkbook();
$workbook->setVersion(8); // Use Excel97/2000 Format
$format_bold =& $workbook->addFormat();
$format_bold->setBold();
$format_percent =& $workbook->addFormat();
$format_percent->setNumFormat("0.00%");
$format_datetime =& $workbook->addFormat();
$format_datetime->setNumFormat("DD/MM/YYYY hh:mm:ss");
$format_title =& $workbook->addFormat();
$format_title->setBold();
$format_title->setColor('black');
$format_title->setPattern(1);
$format_title->setFgColor('silver');
$worksheet =& $workbook->addWorksheet();
$row = 0;
$col = 0;
// title row
include_once "./classes/class.ilExcelUtils.php";
include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
$worksheet->write($row, $col, ilExcelUtils::_convert_text($this->lng->txt("title"), "latin1"), $format_title);
$col++;
$worksheet->write($row, $col, ilExcelUtils::_convert_text($this->lng->txt("description"), "latin1"), $format_title);
$col++;
$worksheet->write($row, $col, ilExcelUtils::_convert_text($this->lng->txt("question_type"), "latin1"), $format_title);
$col++;
$worksheet->write($row, $col, ilExcelUtils::_convert_text($this->lng->txt("author"), "latin1"), $format_title);
$col++;
$worksheet->write($row, $col, ilExcelUtils::_convert_text($this->lng->txt("create_date"), "latin1"), $format_title);
$col++;
$worksheet->write($row, $col, ilExcelUtils::_convert_text($this->lng->txt("last_update"), "latin1"), $format_title);
$col = 0;
$row++;
$questions = $this->qpl_obj->getQuestionList();
foreach ($questions as $question)
{
$worksheet->write($row, $col, ilExcelUtils::_convert_text($question["title"], "latin1"));
$col++;
$worksheet->write($row, $col, ilExcelUtils::_convert_text($question["comment"], "latin1"));
$col++;
$worksheet->write($row, $col, ilExcelUtils::_convert_text($this->lng->txt($question["type_tag"]), "latin1"));
$col++;
$worksheet->write($row, $col, ilExcelUtils::_convert_text($question["author"], "latin1"));
$col++;
$worksheet->write($row, $col, ilExcelUtils::_convert_text(ilFormat::formatDate(ilFormat::ftimestamp2dateDB($question["created"]), "date"), "latin1"));
$col++;
$worksheet->write($row, $col, ilExcelUtils::_convert_text(ilFormat::formatDate(ilFormat::ftimestamp2dateDB($question["TIMESTAMP14"]), "date"), "latin1"));
$col = 0;
$row++;
}
$workbook->close();
}
Here is the call graph for this function:
Here is the caller graph for this function:| ilQuestionpoolExport::buildExportFileXML | ( | ) |
build xml export file
Definition at line 115 of file class.ilQuestionpoolExport.php.
References $ilBench, exportXHTMLMediaObjects(), ilUtil::makeDir(), and ilUtil::zip().
Referenced by buildExportFile().
{
global $ilBench;
$ilBench->start("QuestionpoolExport", "buildExportFile");
include_once("classes/class.ilXmlWriter.php");
$this->xml = new ilXmlWriter;
// set dtd definition
$this->xml->xmlSetDtdDef("<!DOCTYPE Test SYSTEM \"http://www.ilias.uni-koeln.de/download/dtd/ilias_co.dtd\">");
// set generated comment
$this->xml->xmlSetGenCmt("Export of ILIAS Test Questionpool ".
$this->qpl_obj->getId()." of installation ".$this->inst.".");
// set xml header
$this->xml->xmlHeader();
// create directories
include_once "./Services/Utilities/classes/class.ilUtil.php";
ilUtil::makeDir($this->export_dir."/".$this->subdir);
ilUtil::makeDir($this->export_dir."/".$this->subdir."/objects");
// get Log File
$expDir = $this->qpl_obj->getExportDirectory();
include_once "./Services/Logging/classes/class.ilLog.php";
$expLog = new ilLog($expDir, "export.log");
$expLog->delete();
$expLog->setLogFormat("");
$expLog->write(date("[y-m-d H:i:s] ")."Start Export");
// write qti file
$qti_file = fopen($this->export_dir."/".$this->subdir."/".$this->qti_filename, "w");
fwrite($qti_file, $this->qpl_obj->toXML($this->questions));
fclose($qti_file);
// get xml content
$ilBench->start("QuestionpoolExport", "buildExportFile_getXML");
$this->qpl_obj->exportPagesXML($this->xml, $this->inst_id,
$this->export_dir."/".$this->subdir, $expLog, $this->questions);
$ilBench->stop("QuestionpoolExport", "buildExportFile_getXML");
// dump xml document to screen (only for debugging reasons)
/*
echo "<PRE>";
echo htmlentities($this->xml->xmlDumpMem($format));
echo "</PRE>";
*/
// dump xml document to file
$ilBench->start("QuestionpoolExport", "buildExportFile_dumpToFile");
$this->xml->xmlDumpFile($this->export_dir."/".$this->subdir."/".$this->filename
, false);
$ilBench->stop("QuestionpoolExport", "buildExportFile_dumpToFile");
// add media objects which were added with tiny mce
$ilBench->start("QuestionpoolExport", "buildExportFile_saveAdditionalMobs");
$this->exportXHTMLMediaObjects($this->export_dir."/".$this->subdir);
$ilBench->stop("QuestionpoolExport", "buildExportFile_saveAdditionalMobs");
// zip the file
$ilBench->start("QuestionpoolExport", "buildExportFile_zipFile");
ilUtil::zip($this->export_dir."/".$this->subdir,
$this->export_dir."/".$this->subdir.".zip");
$ilBench->stop("QuestionpoolExport", "buildExportFile_zipFile");
// destroy writer object
$this->xml->_XmlWriter;
$expLog->write(date("[y-m-d H:i:s] ")."Finished Export");
$ilBench->stop("QuestionpoolExport", "buildExportFile");
return $this->export_dir."/".$this->subdir.".zip";
}
Here is the call graph for this function:
Here is the caller graph for this function:| ilQuestionpoolExport::exportXHTMLMediaObjects | ( | $ | a_export_dir | ) |
Definition at line 191 of file class.ilQuestionpoolExport.php.
References $mobs, and ilObjMediaObject::_getMobsOfObject().
Referenced by buildExportFileXML().
{
include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
foreach ($this->questions as $question_id)
{
$mobs = ilObjMediaObject::_getMobsOfObject("qpl:html", $question_id);
foreach ($mobs as $mob)
{
$mob_obj =& new ilObjMediaObject($mob);
$mob_obj->exportFiles($a_export_dir);
unset($mob_obj);
}
}
}
Here is the call graph for this function:
Here is the caller graph for this function:| ilQuestionpoolExport::getInstId | ( | ) |
Definition at line 86 of file class.ilQuestionpoolExport.php.
{
return $this->inst_id;
}
| ilQuestionpoolExport::ilQuestionpoolExport | ( | &$ | a_qpl_obj, | |
| $ | a_mode = "xml", |
|||
| $ | array_questions | |||
| ) |
Constructor public.
Definition at line 50 of file class.ilQuestionpoolExport.php.
References $ilErr, $ilias, and $lng.
{
global $ilErr, $ilDB, $ilias, $lng;
$this->qpl_obj =& $a_qpl_obj;
$this->err =& $ilErr;
$this->ilias =& $ilias;
$this->db =& $ilDB;
$this->mode = $a_mode;
$this->lng =& $lng;
$settings = $this->ilias->getAllSettings();
$this->inst_id = IL_INST_ID;
$this->questions = $array_questions;
$date = time();
$this->qpl_obj->createExportDirectory();
switch($this->mode)
{
case "xls":
$this->export_dir = $this->qpl_obj->getExportDirectory();
$this->filename = $date."__".$this->inst_id."__".
"qpl"."__".$this->qpl_obj->getId() . ".xls";
break;
case "xml":
default:
$this->export_dir = $this->qpl_obj->getExportDirectory();
$this->subdir = $date."__".$this->inst_id."__".
"qpl"."__".$this->qpl_obj->getId();
$this->filename = $this->subdir.".xml";
$this->qti_filename = $date."__".$this->inst_id."__".
"qti"."__".$this->qpl_obj->getId().".xml";
break;
}
}
| ilQuestionpoolExport::$db |
Definition at line 38 of file class.ilQuestionpoolExport.php.
| ilQuestionpoolExport::$err |
Definition at line 37 of file class.ilQuestionpoolExport.php.
| ilQuestionpoolExport::$ilias |
Definition at line 39 of file class.ilQuestionpoolExport.php.
Referenced by ilQuestionpoolExport().
| ilQuestionpoolExport::$inst_id |
Definition at line 42 of file class.ilQuestionpoolExport.php.
| ilQuestionpoolExport::$lng |
Definition at line 44 of file class.ilQuestionpoolExport.php.
Referenced by ilQuestionpoolExport().
| ilQuestionpoolExport::$mode |
Definition at line 43 of file class.ilQuestionpoolExport.php.
| ilQuestionpoolExport::$qpl_obj |
Definition at line 40 of file class.ilQuestionpoolExport.php.
| ilQuestionpoolExport::$questions |
Definition at line 41 of file class.ilQuestionpoolExport.php.
Referenced by buildExportFileXLS().
1.7.1