ILIAS  Release_4_2_x_branch Revision 61807
 All Data Structures Namespaces Files Functions Variables Groups Pages
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 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

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:
class.ilQuestionpoolExport.php 34789 2012-05-24 09:40:57Z smeyer

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

Member Function Documentation

ilQuestionpoolExport::buildExportFile ( )

build export file (complete zip file)

public

Returns

Definition at line 104 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 226 of file class.ilQuestionpoolExport.php.

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

Referenced by buildExportFile().

{
global $ilBench;
$ilBench->start("QuestionpoolExport", "buildExportFile");
include_once "./Services/Excel/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 "./Services/Excel/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["description"], "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++;
// ilDatePresentation::formatDate(new ilDateTime($question["created"],IL_CAL_UNIX))
$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["tstamp"]), "date"), "latin1"));
$col = 0;
$row++;
}
$workbook->close();
ilUtil::zip($this->export_dir . "/" . $this->filename, $this->export_dir . "/" . $this->zipfilename);
if (@file_exists($this->export_dir . "/" . $this->filename)) @unlink($this->export_dir . "/" . $this->filename);
}

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

References $ilBench, exportXHTMLMediaObjects(), ilUtil\makeDir(), ilUtil\makeDirParents(), ilXmlWriter\xmlSetDtdDef(), and ilUtil\zip().

Referenced by buildExportFile().

{
global $ilBench;
$ilBench->start("QuestionpoolExport", "buildExportFile");
include_once("./Services/Xml/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");
if (@is_dir($this->export_dir."/".$this->subdir))
{
// Do not delete this dir, since it is required for container exports
#ilUtil::delDir($this->export_dir."/".$this->subdir);
}
$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 204 of file class.ilQuestionpoolExport.php.

References $mobs, ilObjMediaObject\_exists(), 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 92 of file class.ilQuestionpoolExport.php.

References $inst_id.

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

Constructor public.

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

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

{
global $ilErr, $ilDB, $ilias, $lng;
$this->qpl_obj =& $a_qpl_obj;
if (!is_array($array_questions))
{
$array_questions =& $a_qpl_obj->getAllQuestionIds();
}
$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('xls');
$this->filename = $date."__".$this->inst_id."__".
"qpl"."_".$this->qpl_obj->getId() . ".xls";
$this->zipfilename = $date."__".$this->inst_id."__".
"qpl"."_".$this->qpl_obj->getId() . ".zip";
break;
case "xml":
default:
$this->export_dir = $this->qpl_obj->getExportDirectory('zip');
$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;
}
}

Field Documentation

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.

Referenced by getInstId().

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().


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