ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
ilSurveyExport Class Reference

Export class for surveys. More...

+ Collaboration diagram for ilSurveyExport:

Public Member Functions

 ilSurveyExport (&$a_survey_obj, $a_mode="xml")
 Constructor @access public. More...
 
 getInstId ()
 
 buildExportFile ()
 build export file (complete zip file) More...
 
 buildExportFileXML ()
 build xml export file More...
 
 exportXHTMLMediaObjects ($a_export_dir)
 

Data Fields

 $err
 
 $db
 
 $ilias
 
 $survey_obj
 
 $inst_id
 
 $mode
 
 $subdir
 
 $filename
 
 $export_dir
 

Detailed Description

Export class for surveys.

Author
Helmut Schottmüller helmu.nosp@m.t.sc.nosp@m.hottm.nosp@m.uell.nosp@m.er@ma.nosp@m.c.co.nosp@m.m
Version
$Id$

Definition at line 31 of file class.ilSurveyExport.php.

Member Function Documentation

◆ buildExportFile()

ilSurveyExport::buildExportFile ( )

build export file (complete zip file)

@access public

Returns

Definition at line 86 of file class.ilSurveyExport.php.

87 {
88 switch ($this->mode)
89 {
90 default:
91 return $this->buildExportFileXML();
92 break;
93 }
94 }
buildExportFileXML()
build xml export file

References buildExportFileXML().

+ Here is the call graph for this function:

◆ buildExportFileXML()

ilSurveyExport::buildExportFileXML ( )

build xml export file

Definition at line 99 of file class.ilSurveyExport.php.

100 {
101 global $ilBench;
102
103 $ilBench->start("SurveyExport", "buildExportFile");
104
105 // create directories
106 $this->survey_obj->createExportDirectory();
107 include_once "./Services/Utilities/classes/class.ilUtil.php";
108 ilUtil::makeDir($this->export_dir."/".$this->subdir);
109 ilUtil::makeDir($this->export_dir."/".$this->subdir."/objects");
110
111 // get Log File
112 $expDir = $this->survey_obj->getExportDirectory();
113 include_once "./Services/Logging/classes/class.ilLog.php";
114 $expLog = new ilLog($expDir, "export.log");
115 $expLog->delete();
116 $expLog->setLogFormat("");
117 $expLog->write(date("[y-m-d H:i:s] ")."Start Export");
118
119 // write xml file
120 $xmlFile = fopen($this->export_dir."/".$this->subdir."/".$this->filename, "w");
121 fwrite($xmlFile, $this->survey_obj->toXML());
122 fclose($xmlFile);
123
124 // add media objects which were added with tiny mce
125 $this->exportXHTMLMediaObjects($this->export_dir."/".$this->subdir);
126
127 // zip the file
128 $ilBench->start("SurveyExport", "buildExportFileXML_zipFile");
129 ilUtil::zip($this->export_dir."/".$this->subdir, $this->export_dir."/".$this->subdir.".zip");
130 $ilBench->stop("SurveyExport", "buildExportFileXML_zipFile");
131
132 if (@file_exists($this->export_dir."/".$this->subdir.".zip"))
133 {
134 // remove export directory and contents
135 if (@is_dir($this->export_dir."/".$this->subdir))
136 {
137 ilUtil::delDir($this->export_dir."/".$this->subdir);
138 }
139 }
140 $expLog->write(date("[y-m-d H:i:s] ")."Finished Export");
141 $ilBench->stop("SurveyExport", "buildExportFile");
142
143 return $this->export_dir."/".$this->subdir.".zip";
144 }
logging
Definition: class.ilLog.php:19
exportXHTMLMediaObjects($a_export_dir)
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
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

References $ilBench, ilUtil\delDir(), exportXHTMLMediaObjects(), ilUtil\makeDir(), and ilUtil\zip().

Referenced by buildExportFile().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ exportXHTMLMediaObjects()

ilSurveyExport::exportXHTMLMediaObjects (   $a_export_dir)

Definition at line 146 of file class.ilSurveyExport.php.

147 {
148 global $ilBench;
149 $ilBench->start("SurveyExport", "exportXHTMLMediaObjects");
150 include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
151
152 $mobs = ilObjMediaObject::_getMobsOfObject("svy:html", $this->survey_obj->getId());
153 foreach ($mobs as $mob)
154 {
155 $mob_obj =& new ilObjMediaObject($mob);
156 $mob_obj->exportFiles($a_export_dir);
157 unset($mob_obj);
158 }
159 // #14850
160 foreach ($this->survey_obj->questions as $question_id)
161 {
162 $mobs = ilObjMediaObject::_getMobsOfObject("spl:html", $question_id);
163 foreach ($mobs as $mob)
164 {
165 $mob_obj =& new ilObjMediaObject($mob);
166 $mob_obj->exportFiles($a_export_dir);
167 unset($mob_obj);
168 }
169 }
170 $ilBench->stop("SurveyExport", "exportXHTMLMediaObjects");
171 }
Class ilObjMediaObject.
_getMobsOfObject($a_type, $a_id, $a_usage_hist_nr=0, $a_lang="-")
get mobs of object
$mobs

References $ilBench, $mobs, and ilObjMediaObject\_getMobsOfObject().

Referenced by buildExportFileXML().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getInstId()

ilSurveyExport::getInstId ( )

Definition at line 74 of file class.ilSurveyExport.php.

75 {
76 return $this->inst_id;
77 }

References $inst_id.

◆ ilSurveyExport()

ilSurveyExport::ilSurveyExport ( $a_survey_obj,
  $a_mode = "xml" 
)

Constructor @access public.

Definition at line 47 of file class.ilSurveyExport.php.

48 {
49 global $ilErr, $ilDB, $ilias;
50
51 $this->survey_obj =& $a_survey_obj;
52
53 $this->err =& $ilErr;
54 $this->ilias =& $ilias;
55 $this->db =& $ilDB;
56 $this->mode = $a_mode;
57
58 $settings = $this->ilias->getAllSettings();
59 //$this->inst_id = $settings["inst_id"];
60 $this->inst_id = IL_INST_ID;
61
62 $date = time();
63 switch($this->mode)
64 {
65 default:
66 $this->export_dir = $this->survey_obj->getExportDirectory();
67 $this->subdir = $date."__".$this->inst_id."__".
68 "svy"."_".$this->survey_obj->getId();
69 $this->filename = $this->subdir.".xml";
70 break;
71 }
72 }
redirection script todo: (a better solution should control the processing via a xml file)
global $ilDB

References $ilDB, $ilErr, and $ilias.

Field Documentation

◆ $db

ilSurveyExport::$db

Definition at line 34 of file class.ilSurveyExport.php.

◆ $err

ilSurveyExport::$err

Definition at line 33 of file class.ilSurveyExport.php.

◆ $export_dir

ilSurveyExport::$export_dir

Definition at line 41 of file class.ilSurveyExport.php.

◆ $filename

ilSurveyExport::$filename

Definition at line 40 of file class.ilSurveyExport.php.

◆ $ilias

ilSurveyExport::$ilias

Definition at line 35 of file class.ilSurveyExport.php.

Referenced by ilSurveyExport().

◆ $inst_id

ilSurveyExport::$inst_id

Definition at line 37 of file class.ilSurveyExport.php.

Referenced by getInstId().

◆ $mode

ilSurveyExport::$mode

Definition at line 38 of file class.ilSurveyExport.php.

◆ $subdir

ilSurveyExport::$subdir

Definition at line 39 of file class.ilSurveyExport.php.

◆ $survey_obj

ilSurveyExport::$survey_obj

Definition at line 36 of file class.ilSurveyExport.php.


The documentation for this class was generated from the following file: