ILIAS  eassessment Revision 61809
 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)
85  {
86  switch ($this->mode)
87  {
88  default:
89  return $this->buildExportFileXML($questions);
90  break;
91  }
92  }
93 
97  function buildExportFileXML($questions)
98  {
99  global $ilBench;
100 
101  $ilBench->start("SurveyQuestionpoolExport", "buildExportFile");
102 
103  // create directories
104  $this->spl_obj->createExportDirectory();
105 
106  // get Log File
107  $expDir = $this->spl_obj->getExportDirectory();
108  include_once "./Services/Logging/classes/class.ilLog.php";
109  $expLog = new ilLog($expDir, "export.log");
110  $expLog->delete();
111  $expLog->setLogFormat("");
112  $expLog->write(date("[y-m-d H:i:s] ")."Start Export");
113  // write qti file
114  $qti_file = fopen($expDir . "/" . $this->filename, "w");
115  fwrite($qti_file, $this->spl_obj->toXML($questions));
116  fclose($qti_file);
117 
118  // destroy writer object
119  $this->xml->_XmlWriter;
120 
121  $expLog->write(date("[y-m-d H:i:s] ")."Finished Export");
122  $ilBench->stop("SurveyQuestionpoolExport", "buildExportFile");
123 
124  return $this->filename;
125  }
126 }
127 
128 ?>