ILIAS  release_7 Revision v7.30-3-g800a261c036
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 public $db; // database object
34 public $spl_obj; // survey questionpool object
35 public $inst_id; // installation id
36 public $mode;
37
42 public function __construct($a_spl_obj, $a_mode = "xml")
43 {
44 global $DIC;
45
46 $ilDB = $DIC->database();
47
48 $this->spl_obj = $a_spl_obj;
49
50 $this->db = $ilDB;
51 $this->mode = $a_mode;
52
53 $this->inst_id = IL_INST_ID;
54
55 $date = time();
56 switch ($this->mode) {
57 default:
58 $this->export_dir = $this->spl_obj->getExportDirectory();
59 $this->subdir = $date . "__" . $this->inst_id . "__" .
60 "spl" . "_" . $this->spl_obj->getId();
61 $this->filename = $this->subdir . ".xml";
62 break;
63 }
64 }
65
66 public function getInstId()
67 {
68 return $this->inst_id;
69 }
70
71
78 public function buildExportFile($questions = null)
79 {
80 switch ($this->mode) {
81 default:
82 return $this->buildExportFileXML($questions);
83 break;
84 }
85 }
86
90 public function buildExportFileXML($questions = null)
91 {
92 // create directories
93 $this->spl_obj->createExportDirectory();
94 ilUtil::makeDir($this->export_dir . "/" . $this->subdir);
95
96 // get Log File
97 $expLog = new ilLog($this->spl_obj->getExportDirectory(), "export.log");
98 $expLog->delete();
99 $expLog->setLogFormat("");
100 $expLog->write(date("[y-m-d H:i:s] ") . "Start Export");
101 // write qti file
102 $qti_file = fopen($this->export_dir . "/" . $this->subdir . "/" . $this->filename, "w");
103 fwrite($qti_file, $this->spl_obj->toXML($questions));
104 fclose($qti_file);
105 // destroy writer object
106 $this->xml->_XmlWriter;
107
109 $this->export_dir . "/" . $this->subdir,
110 $this->export_dir . "/" . $this->subdir . ".zip"
111 );
112
113 $expLog->write(date("[y-m-d H:i:s] ") . "Finished Export");
114
115 return $this->export_dir . "/" . $this->subdir . ".zip";
116 }
117}
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)
zips given directory/file into given zip.file
static makeDir($a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...
const IL_INST_ID
Definition: constants.php:38
global $DIC
Definition: goto.php:24
global $ilDB