ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilSurveyExport Class Reference

Export class for surveys. More...

+ Collaboration diagram for ilSurveyExport:

Public Member Functions

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

Data Fields

 $db
 
 $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.

Constructor & Destructor Documentation

◆ __construct()

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

Constructor public.

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

References $ilDB, and time.

46  {
47  global $ilDB;
48 
49  $this->survey_obj = $a_survey_obj;
50 
51  $this->db = $ilDB;
52  $this->mode = $a_mode;
53  $this->inst_id = IL_INST_ID;
54 
55  $date = time();
56  switch($this->mode)
57  {
58  default:
59  $this->export_dir = $this->survey_obj->getExportDirectory();
60  $this->subdir = $date."__".$this->inst_id."__".
61  "svy"."_".$this->survey_obj->getId();
62  $this->filename = $this->subdir.".xml";
63  break;
64  }
65  }
global $ilDB
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.

Member Function Documentation

◆ buildExportFile()

ilSurveyExport::buildExportFile ( )

build export file (complete zip file)

public

Returns

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

References buildExportFileXML().

80  {
81  switch ($this->mode)
82  {
83  default:
84  return $this->buildExportFileXML();
85  break;
86  }
87  }
buildExportFileXML()
build xml export file
+ Here is the call graph for this function:

◆ buildExportFileXML()

ilSurveyExport::buildExportFileXML ( )

build xml export file

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

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

Referenced by buildExportFile().

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

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

Referenced by buildExportFileXML().

139  {
140  global $ilBench;
141  $ilBench->start("SurveyExport", "exportXHTMLMediaObjects");
142  include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
143 
144  $mobs = ilObjMediaObject::_getMobsOfObject("svy:html", $this->survey_obj->getId());
145  foreach ($mobs as $mob)
146  {
147  $mob_obj = new ilObjMediaObject($mob);
148  $mob_obj->exportFiles($a_export_dir);
149  unset($mob_obj);
150  }
151  // #14850
152  foreach ($this->survey_obj->questions as $question_id)
153  {
154  $mobs = ilObjMediaObject::_getMobsOfObject("spl:html", $question_id);
155  foreach ($mobs as $mob)
156  {
157  $mob_obj = new ilObjMediaObject($mob);
158  $mob_obj->exportFiles($a_export_dir);
159  unset($mob_obj);
160  }
161  }
162  $ilBench->stop("SurveyExport", "exportXHTMLMediaObjects");
163  }
static _getMobsOfObject($a_type, $a_id, $a_usage_hist_nr=0, $a_lang="-")
get mobs of object
$mobs
Class ilObjMediaObject.
global $ilBench
Definition: ilias.php:18
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getInstId()

ilSurveyExport::getInstId ( )

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

References $inst_id.

68  {
69  return $this->inst_id;
70  }

Field Documentation

◆ $db

ilSurveyExport::$db

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

◆ $export_dir

ilSurveyExport::$export_dir

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

◆ $filename

ilSurveyExport::$filename

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

◆ $inst_id

ilSurveyExport::$inst_id

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

Referenced by getInstId().

◆ $mode

ilSurveyExport::$mode

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

◆ $subdir

ilSurveyExport::$subdir

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

◆ $survey_obj

ilSurveyExport::$survey_obj

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


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