ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
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 
24 include_once "./Modules/Survey/classes/inc.SurveyConstants.php";
25 
34 {
35  var $err; // error object
36  var $db; // database object
37  var $ilias; // ilias object
38  var $spl_obj; // survey questionpool object
39  var $inst_id; // installation id
40  var $mode;
41 
46  function ilSurveyQuestionpoolExport(&$a_spl_obj, $a_mode = "xml")
47  {
48  global $ilErr, $ilDB, $ilias;
49 
50  $this->spl_obj =& $a_spl_obj;
51 
52  $this->err =& $ilErr;
53  $this->ilias =& $ilias;
54  $this->db =& $ilDB;
55  $this->mode = $a_mode;
56 
57  $settings = $this->ilias->getAllSettings();
58  $this->inst_id = IL_INST_ID;
59 
60  $date = time();
61  switch($this->mode)
62  {
63  default:
64  $this->export_dir = $this->spl_obj->getExportDirectory();
65  $this->subdir = $date."__".$this->inst_id."__".
66  "spl"."_".$this->spl_obj->getId();
67  $this->filename = $this->subdir.".xml";
68  break;
69  }
70  }
71 
72  function getInstId()
73  {
74  return $this->inst_id;
75  }
76 
77 
84  function buildExportFile($questions = null)
85  {
86  switch ($this->mode)
87  {
88  default:
89  return $this->buildExportFileXML($questions);
90  break;
91  }
92  }
93 
97  function buildExportFileXML($questions = null)
98  {
99  global $ilBench;
100 
101  $ilBench->start("SurveyQuestionpoolExport", "buildExportFile");
102 
103  // create directories
104  $this->spl_obj->createExportDirectory();
105  include_once "./Services/Utilities/classes/class.ilUtil.php";
106  ilUtil::makeDir($this->export_dir."/".$this->subdir);
107 
108  // get Log File
109  include_once "./Services/Logging/classes/class.ilLog.php";
110  $expLog = new ilLog($this->spl_obj->getExportDirectory(), "export.log");
111  $expLog->delete();
112  $expLog->setLogFormat("");
113  $expLog->write(date("[y-m-d H:i:s] ")."Start Export");
114  // write qti file
115  $qti_file = fopen($this->export_dir."/".$this->subdir."/". $this->filename, "w");
116  fwrite($qti_file, $this->spl_obj->toXML($questions));
117  fclose($qti_file);
118  // destroy writer object
119  $this->xml->_XmlWriter;
120 
121  ilUtil::zip($this->export_dir."/".$this->subdir,
122  $this->export_dir."/".$this->subdir.".zip");
123 
124  $expLog->write(date("[y-m-d H:i:s] ")."Finished Export");
125  $ilBench->stop("SurveyQuestionpoolExport", "buildExportFile");
126 
127  return $this->export_dir."/".$this->subdir.".zip";
128  }
129 }
130 
131 ?>