ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 $db; // database object
34 var $spl_obj; // survey questionpool object
35 var $inst_id; // installation id
36 var $mode;
37
42 function __construct($a_spl_obj, $a_mode = "xml")
43 {
44 global $ilDB;
45
46 $this->spl_obj = $a_spl_obj;
47
48 $this->db = $ilDB;
49 $this->mode = $a_mode;
50
51 $this->inst_id = IL_INST_ID;
52
53 $date = time();
54 switch($this->mode)
55 {
56 default:
57 $this->export_dir = $this->spl_obj->getExportDirectory();
58 $this->subdir = $date."__".$this->inst_id."__".
59 "spl"."_".$this->spl_obj->getId();
60 $this->filename = $this->subdir.".xml";
61 break;
62 }
63 }
64
65 function getInstId()
66 {
67 return $this->inst_id;
68 }
69
70
77 function buildExportFile($questions = null)
78 {
79 switch ($this->mode)
80 {
81 default:
82 return $this->buildExportFileXML($questions);
83 break;
84 }
85 }
86
90 function buildExportFileXML($questions = null)
91 {
92 global $ilBench;
93
94 $ilBench->start("SurveyQuestionpoolExport", "buildExportFile");
95
96 // create directories
97 $this->spl_obj->createExportDirectory();
98 ilUtil::makeDir($this->export_dir."/".$this->subdir);
99
100 // get Log File
101 include_once "./Services/Logging/classes/class.ilLog.php";
102 $expLog = new ilLog($this->spl_obj->getExportDirectory(), "export.log");
103 $expLog->delete();
104 $expLog->setLogFormat("");
105 $expLog->write(date("[y-m-d H:i:s] ")."Start Export");
106 // write qti file
107 $qti_file = fopen($this->export_dir."/".$this->subdir."/". $this->filename, "w");
108 fwrite($qti_file, $this->spl_obj->toXML($questions));
109 fclose($qti_file);
110 // destroy writer object
111 $this->xml->_XmlWriter;
112
113 ilUtil::zip($this->export_dir."/".$this->subdir,
114 $this->export_dir."/".$this->subdir.".zip");
115
116 $expLog->write(date("[y-m-d H:i:s] ")."Finished Export");
117 $ilBench->stop("SurveyQuestionpoolExport", "buildExportFile");
118
119 return $this->export_dir."/".$this->subdir.".zip";
120 }
121}
122
123?>
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
An exception for terminatinating execution or to throw for unit testing.
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
__construct($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
global $ilDB