ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilSurveyQuestionpoolExport.php
Go to the documentation of this file.
1<?php
2/*
3 +-----------------------------------------------------------------------------+
4 | ILIAS open source |
5 +-----------------------------------------------------------------------------+
6 | Copyright (c) 1998-2001 ILIAS open source, University of Cologne |
7 | |
8 | This program is free software; you can redistribute it and/or |
9 | modify it under the terms of the GNU General Public License |
10 | as published by the Free Software Foundation; either version 2 |
11 | of the License, or (at your option) any later version. |
12 | |
13 | This program is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | GNU General Public License for more details. |
17 | |
18 | You should have received a copy of the GNU General Public License |
19 | along with this program; if not, write to the Free Software |
20 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21 +-----------------------------------------------------------------------------+
22*/
23
32{
33 var $err; // error object
34 var $db; // database object
35 var $ilias; // ilias object
36 var $spl_obj; // survey questionpool object
37 var $inst_id; // installation id
38 var $mode;
39
44 function ilSurveyQuestionpoolExport(&$a_spl_obj, $a_mode = "xml")
45 {
46 global $ilErr, $ilDB, $ilias;
47
48 $this->spl_obj =& $a_spl_obj;
49
50 $this->err =& $ilErr;
51 $this->ilias =& $ilias;
52 $this->db =& $ilDB;
53 $this->mode = $a_mode;
54
55 $settings = $this->ilias->getAllSettings();
56 $this->inst_id = IL_INST_ID;
57
58 $date = time();
59 switch($this->mode)
60 {
61 default:
62 $this->export_dir = $this->spl_obj->getExportDirectory();
63 $this->subdir = $date."__".$this->inst_id."__".
64 "spl"."_".$this->spl_obj->getId();
65 $this->filename = $this->subdir.".xml";
66 break;
67 }
68 }
69
70 function getInstId()
71 {
72 return $this->inst_id;
73 }
74
75
82 function buildExportFile($questions = null)
83 {
84 switch ($this->mode)
85 {
86 default:
87 return $this->buildExportFileXML($questions);
88 break;
89 }
90 }
91
95 function buildExportFileXML($questions = null)
96 {
97 global $ilBench;
98
99 $ilBench->start("SurveyQuestionpoolExport", "buildExportFile");
100
101 // create directories
102 $this->spl_obj->createExportDirectory();
103 include_once "./Services/Utilities/classes/class.ilUtil.php";
104 ilUtil::makeDir($this->export_dir."/".$this->subdir);
105
106 // get Log File
107 include_once "./Services/Logging/classes/class.ilLog.php";
108 $expLog = new ilLog($this->spl_obj->getExportDirectory(), "export.log");
109 $expLog->delete();
110 $expLog->setLogFormat("");
111 $expLog->write(date("[y-m-d H:i:s] ")."Start Export");
112 // write qti file
113 $qti_file = fopen($this->export_dir."/".$this->subdir."/". $this->filename, "w");
114 fwrite($qti_file, $this->spl_obj->toXML($questions));
115 fclose($qti_file);
116 // destroy writer object
117 $this->xml->_XmlWriter;
118
119 ilUtil::zip($this->export_dir."/".$this->subdir,
120 $this->export_dir."/".$this->subdir.".zip");
121
122 $expLog->write(date("[y-m-d H:i:s] ")."Finished Export");
123 $ilBench->stop("SurveyQuestionpoolExport", "buildExportFile");
124
125 return $this->export_dir."/".$this->subdir.".zip";
126 }
127}
128
129?>
logging
Definition: class.ilLog.php:19
Export class for survey questionpools.
buildExportFile($questions=null)
build export file (complete zip file)
buildExportFileXML($questions=null)
build xml export file
ilSurveyQuestionpoolExport(&$a_spl_obj, $a_mode="xml")
Constructor @access public.
static zip($a_dir, $a_file, $compress_content=false)
static makeDir($a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...
global $ilBench
Definition: ilias.php:18
redirection script todo: (a better solution should control the processing via a xml file)
global $ilDB