Public Member Functions | Data Fields

ilTestExport Class Reference

Public Member Functions

 ilTestExport (&$a_test_obj, $a_mode="xml")
 Constructor public.
 getExtension ()
 getInstId ()
 buildExportFile ()
 build export file (complete zip file)
 buildExportResultFile ()
 build xml export file
 buildExportFileXML ()
 build xml export file
 exportXHTMLMediaObjects ($a_export_dir)

Data Fields

 $err
 $db
 $ilias
 $test_obj
 $inst_id
 $mode

Detailed Description

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


Member Function Documentation

ilTestExport::buildExportFile (  ) 

build export file (complete zip file)

public

Returns:

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

References buildExportFileXML(), and buildExportResultFile().

        {
                switch ($this->mode)
                {
                        case "results":
                                return $this->buildExportResultFile();
                                break;
                        default:
                                return $this->buildExportFileXML();
                                break;
                }
        }

Here is the call graph for this function:

ilTestExport::buildExportFileXML (  ) 

build xml export file

Definition at line 154 of file class.ilTestExport.php.

References $ilBench, exportXHTMLMediaObjects(), ilUtil::makeDir(), and ilUtil::zip().

Referenced by buildExportFile().

        {
                global $ilBench;

                $ilBench->start("TestExport", "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 ".
                        $this->test_obj->getId()." of installation ".$this->inst.".");

                // set xml header
                $this->xml->xmlHeader();

                // create directories
                $this->test_obj->createExportDirectory();
                include_once "./classes/class.ilUtil.php";
                ilUtil::makeDir($this->export_dir."/".$this->subdir);
                ilUtil::makeDir($this->export_dir."/".$this->subdir."/objects");

                // get Log File
                $expDir = $this->test_obj->getExportDirectory();
                include_once "./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->test_obj->to_xml());
                fclose($qti_file);

                // get xml content
                $ilBench->start("TestExport", "buildExportFile_getXML");
                $this->test_obj->exportPagesXML($this->xml, $this->inst_id,
                        $this->export_dir."/".$this->subdir, $expLog);
                $ilBench->stop("TestExport", "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("TestExport", "buildExportFile_dumpToFile");
                $this->xml->xmlDumpFile($this->export_dir."/".$this->subdir."/".$this->filename
                        , false);
                $ilBench->stop("TestExport", "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("TestExport", "buildExportFile_zipFile");
                ilUtil::zip($this->export_dir."/".$this->subdir,
                        $this->export_dir."/".$this->subdir.".zip");
                $ilBench->stop("TestExport", "buildExportFile_zipFile");

                // destroy writer object
                $this->xml->_XmlWriter;

                $expLog->write(date("[y-m-d H:i:s] ")."Finished Export");
                $ilBench->stop("TestExport", "buildExportFile");

                return $this->export_dir."/".$this->subdir.".zip";
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilTestExport::buildExportResultFile (  ) 

build xml export file

Definition at line 118 of file class.ilTestExport.php.

References $data, $file, $ilBench, $log, $row, and ilUtil::makeDir().

Referenced by buildExportFile().

        {
                global $ilBench;
                global $log;
                //get Log File
                $expDir = $this->test_obj->getExportDirectory();
                $expLog = &$log;
                $expLog->delete();
                $expLog->setLogFormat("");
                $expLog->write(date("[y-m-d H:i:s] ")."Start Export Of Results");

                // make_directories
                $this->test_obj->createExportDirectory();
                include_once "./classes/class.ilUtil.php";
                ilUtil::makeDir($this->export_dir);

                //get data
                $participants = $this->test_obj->getInvitedUsers("matriculation");
                $data =  $this->test_obj->getAllTestResults($participants);

                $file = fopen($this->export_dir."/".$this->filename, "w");
                foreach ($data as $row) {
                        fwrite($file, join (";",$row)."\n");
                }
                fclose($file);

                // end
                $expLog->write(date("[y-m-d H:i:s] ")."Finished Export of Results");

                return $this->export_dir."/".$this->filename;
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilTestExport::exportXHTMLMediaObjects ( a_export_dir  ) 

Definition at line 231 of file class.ilTestExport.php.

References $mobs, and ilObjMediaObject::_getMobsOfObject().

Referenced by buildExportFileXML().

        {
                include_once("./content/classes/Media/class.ilObjMediaObject.php");

                $mobs = ilObjMediaObject::_getMobsOfObject("tst:html", $this->test_obj->getId());
                foreach ($mobs as $mob)
                {
                        $mob_obj =& new ilObjMediaObject($mob);
                        $mob_obj->exportFiles($a_export_dir);
                        unset($mob_obj);
                }
                foreach ($this->test_obj->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:

ilTestExport::getExtension (  ) 

Definition at line 81 of file class.ilTestExport.php.

Referenced by ilTestExport().

                                 {
                switch ($this->mode) {
                        case "results":
                                return "csv"; break;
                        default:
                                return "xml"; break;
                }
        }

Here is the caller graph for this function:

ilTestExport::getInstId (  ) 

Definition at line 90 of file class.ilTestExport.php.

        {
                return $this->inst_id;
        }

ilTestExport::ilTestExport ( &$  a_test_obj,
a_mode = "xml" 
)

Constructor public.

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

References $ilErr, $ilias, and getExtension().

        {
                global $ilErr, $ilDB, $ilias;

                $this->test_obj =& $a_test_obj;

                $this->err =& $ilErr;
                $this->ilias =& $ilias;
                $this->db =& $ilDB;
                $this->mode = $a_mode;

                $settings = $this->ilias->getAllSettings();
                //$this->inst_id = $settings["inst_id"];
                $this->inst_id = IL_INST_ID;

                $date = time();
                $this->export_dir = $this->test_obj->getExportDirectory();
                switch($this->mode)
                {
                        case "results":
                                $this->subdir = $date."__".$this->inst_id."__".
                                        "test__results__".$this->test_obj->getId();
                                break;
                        default:
                                $this->subdir = $date."__".$this->inst_id."__".
                                        "test"."__".$this->test_obj->getId();
                                $this->filename = $this->subdir.".xml";
                                $this->qti_filename = $date."__".$this->inst_id."__".
                                        "qti"."__".$this->test_obj->getId().".xml";
                                break;
                }
                $this->filename = $this->subdir.".".$this->getExtension();
        }

Here is the call graph for this function:


Field Documentation

ilTestExport::$db

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

ilTestExport::$err

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

ilTestExport::$ilias

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

Referenced by ilTestExport().

ilTestExport::$inst_id

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

ilTestExport::$mode

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

ilTestExport::$test_obj

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


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