ILIAS  eassessment Revision 61809
 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)
 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 32739 2012-01-23 23:52:09Z hschottm

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

References $file, $ilBench, $questions, $row, CELL_FORMAT_TITLE, ilExcelUtils\ExcelAdapter(), ilFormat\formatDate(), and ilFormat\ftimestamp2dateDB().

Referenced by buildExportFile().

{
global $ilBench;
$ilBench->start("QuestionpoolExport", "buildExportFile");
include_once "./Services/Excel/classes/class.ilExcelUtils.php";
$adapter->setWorksheetTitle($this->lng->txt("tst_results_aggregated"));
$row = 0;
$col = 0;
// title row
include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
$adapter->setCellValue($row, $col, $this->lng->txt("title"), CELL_FORMAT_TITLE);
$col++;
$adapter->setCellValue($row, $col, $this->lng->txt("description"), CELL_FORMAT_TITLE);
$col++;
$adapter->setCellValue($row, $col, $this->lng->txt("question_type"), CELL_FORMAT_TITLE);
$col++;
$adapter->setCellValue($row, $col, $this->lng->txt("author"), CELL_FORMAT_TITLE);
$col++;
$adapter->setCellValue($row, $col, $this->lng->txt("create_date"), CELL_FORMAT_TITLE);
$col++;
$adapter->setCellValue($row, $col, $this->lng->txt("last_update"), CELL_FORMAT_TITLE);
$col = 0;
$row++;
$questions = $this->qpl_obj->getQuestionList();
foreach ($questions as $question)
{
$adapter->setCellValue($row, $col, $question["title"]);
$col++;
$adapter->setCellValue($row, $col, $question["description"]);
$col++;
$adapter->setCellValue($row, $col, $this->lng->txt($question["type_tag"]));
$col++;
$adapter->setCellValue($row, $col, $question["author"]);
$col++;
// ilDatePresentation::formatDate(new ilDateTime($question["created"],IL_CAL_UNIX))
$adapter->setCellValue($row, $col, ilFormat::formatDate(ilFormat::ftimestamp2dateDB($question["created"]), "date"));
$col++;
$adapter->setCellValue($row, $col, ilFormat::formatDate(ilFormat::ftimestamp2dateDB($question["tstamp"]), "date"));
$col = 0;
$row++;
}
$file = $adapter->save();
@rename($file, $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 117 of file class.ilQuestionpoolExport.php.

References $ilBench, exportXHTMLMediaObjects(), ilUtil\makeDir(), 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");
$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 193 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 88 of file class.ilQuestionpoolExport.php.

References $inst_id.

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

Constructor public.

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

References $ilDB, $ilErr, $ilias, $lng, and ilExcelUtils\ExcelAdapter().

{
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":
include_once "./Services/Excel/classes/class.ilExcelUtils.php";
$this->export_dir = $this->qpl_obj->getExportDirectory();
$this->filename = $date."__".$this->inst_id."__".
"qpl"."__".$this->qpl_obj->getId() . "." . $adapter->getFileExtension();
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;
}
}

+ Here is the call graph for this function:

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: