ILIAS  release_8 Revision v8.23
ilSurveyExport Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Collaboration diagram for ilSurveyExport:

Public Member Functions

 __construct (ilObjSurvey $a_survey_obj, $a_mode="xml")
 
 getInstId ()
 
 buildExportFile ()
 
 buildExportFileXML ()
 build xml export file More...
 
 exportXHTMLMediaObjects (string $a_export_dir)
 

Data Fields

ilDBInterface $db
 
ilObjSurvey $survey_obj
 
int $inst_id
 
string $mode
 
string $subdir
 
string $filename
 
string $export_dir
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning 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

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

Constructor & Destructor Documentation

◆ __construct()

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

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

References $DIC, $ilDB, IL_INST_ID, and ILIAS\Repository\int().

36  {
37  global $DIC;
38 
39  $ilDB = $DIC->database();
40 
41  $this->survey_obj = $a_survey_obj;
42 
43  $this->db = $ilDB;
44  $this->mode = $a_mode;
45  $this->inst_id = (int) IL_INST_ID;
46 
47  $date = time();
48  switch ($this->mode) {
49  default:
50  $this->export_dir = $this->survey_obj->getExportDirectory();
51  $this->subdir = $date . "__" . $this->inst_id . "__" .
52  "svy" . "_" . $this->survey_obj->getId();
53  $this->filename = $this->subdir . ".xml";
54  break;
55  }
56  }
const IL_INST_ID
Definition: constants.php:40
global $DIC
Definition: feed.php:28
+ Here is the call graph for this function:

Member Function Documentation

◆ buildExportFile()

ilSurveyExport::buildExportFile ( )
Returns
string export file name

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

References buildExportFileXML().

67  : string
68  {
69  switch ($this->mode) {
70  default:
71  return $this->buildExportFileXML();
72  }
73  }
buildExportFileXML()
build xml export file
+ Here is the call graph for this function:

◆ buildExportFileXML()

ilSurveyExport::buildExportFileXML ( )

build xml export file

Returns
string export file name
Exceptions
ilLogException
ilSurveyException

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

References ilFileUtils\delDir(), exportXHTMLMediaObjects(), ilFileUtils\makeDir(), and ilFileUtils\zip().

Referenced by buildExportFile().

81  : string
82  {
83 
84  // create directories
85  $this->survey_obj->createExportDirectory();
86  ilFileUtils::makeDir($this->export_dir . "/" . $this->subdir);
87  ilFileUtils::makeDir($this->export_dir . "/" . $this->subdir . "/objects");
88 
89  // get Log File
90  $expDir = $this->survey_obj->getExportDirectory();
91  $expLog = new ilLog($expDir, "export.log");
92  $expLog->delete();
93  $expLog->setLogFormat("");
94  $expLog->write(date("[y-m-d H:i:s] ") . "Start Export");
95 
96  // write xml file
97  $xmlFile = fopen($this->export_dir . "/" . $this->subdir . "/" . $this->filename, 'wb');
98  fwrite($xmlFile, $this->survey_obj->toXML());
99  fclose($xmlFile);
100 
101  // add media objects which were added with tiny mce
102  $this->exportXHTMLMediaObjects($this->export_dir . "/" . $this->subdir);
103 
104  // zip the file
105  ilFileUtils::zip($this->export_dir . "/" . $this->subdir, $this->export_dir . "/" . $this->subdir . ".zip");
106 
107  if (file_exists($this->export_dir . "/" . $this->subdir . ".zip")) {
108  // remove export directory and contents
109  if (is_dir($this->export_dir . "/" . $this->subdir)) {
110  ilFileUtils::delDir($this->export_dir . "/" . $this->subdir);
111  }
112  }
113  $expLog->write(date("[y-m-d H:i:s] ") . "Finished Export");
114 
115  return $this->export_dir . "/" . $this->subdir . ".zip";
116  }
exportXHTMLMediaObjects(string $a_export_dir)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: class.ilLog.php:30
static delDir(string $a_dir, bool $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
static zip(string $a_dir, string $a_file, bool $compress_content=false)
zips given directory/file into given zip.file
static makeDir(string $a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ exportXHTMLMediaObjects()

ilSurveyExport::exportXHTMLMediaObjects ( string  $a_export_dir)

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

References $mobs, and ilObjMediaObject\_getMobsOfObject().

Referenced by buildExportFileXML().

120  : void {
121  $mobs = ilObjMediaObject::_getMobsOfObject("svy:html", $this->survey_obj->getId());
122  foreach ($mobs as $mob) {
123  $mob_obj = new ilObjMediaObject($mob);
124  $mob_obj->exportFiles($a_export_dir);
125  unset($mob_obj);
126  }
127  // #14850
128  foreach ($this->survey_obj->questions as $question_id) {
129  $mobs = ilObjMediaObject::_getMobsOfObject("spl:html", $question_id);
130  foreach ($mobs as $mob) {
131  $mob_obj = new ilObjMediaObject($mob);
132  $mob_obj->exportFiles($a_export_dir);
133  unset($mob_obj);
134  }
135  }
136  }
$mobs
Definition: imgupload.php:70
static _getMobsOfObject(string $a_type, int $a_id, int $a_usage_hist_nr=0, string $a_lang="-")
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getInstId()

ilSurveyExport::getInstId ( )

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

References $inst_id.

58  : int
59  {
60  return $this->inst_id;
61  }

Field Documentation

◆ $db

ilDBInterface ilSurveyExport::$db

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

◆ $export_dir

string ilSurveyExport::$export_dir

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

◆ $filename

string ilSurveyExport::$filename

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

◆ $inst_id

int ilSurveyExport::$inst_id

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

Referenced by getInstId().

◆ $mode

string ilSurveyExport::$mode

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

◆ $subdir

string ilSurveyExport::$subdir

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

◆ $survey_obj

ilObjSurvey ilSurveyExport::$survey_obj

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


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