ILIAS  trunk Revision v11.0_alpha-1866-gfa368f7776e
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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: shib_login.php:22
+ 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  // create directories
84  $this->survey_obj->createExportDirectory();
85  ilFileUtils::makeDir($this->export_dir . "/" . $this->subdir);
86  ilFileUtils::makeDir($this->export_dir . "/" . $this->subdir . "/objects");
87 
88  // get Log File
89  $expDir = $this->survey_obj->getExportDirectory();
90  $expLog = new ilLog($expDir, "export.log");
91  $expLog->delete();
92  $expLog->setLogFormat("");
93  $expLog->write(date("[y-m-d H:i:s] ") . "Start Export");
94 
95  // write xml file
96  $xmlFile = fopen($this->export_dir . "/" . $this->subdir . "/" . $this->filename, 'wb');
97  fwrite($xmlFile, $this->survey_obj->toXML());
98  fclose($xmlFile);
99 
100  // add media objects which were added with tiny mce
101  $this->exportXHTMLMediaObjects($this->export_dir . "/" . $this->subdir);
102 
103  // zip the file
104  ilFileUtils::zip($this->export_dir . "/" . $this->subdir, $this->export_dir . "/" . $this->subdir . ".zip");
105 
106  if (file_exists($this->export_dir . "/" . $this->subdir . ".zip")) {
107  // remove export directory and contents
108  if (is_dir($this->export_dir . "/" . $this->subdir)) {
109  ilFileUtils::delDir($this->export_dir . "/" . $this->subdir);
110  }
111  }
112  $expLog->write(date("[y-m-d H:i:s] ") . "Finished Export");
113 
114  return $this->export_dir . "/" . $this->subdir . ".zip";
115  }
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)
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 117 of file class.ilSurveyExport.php.

References ilObjMediaObject\_getMobsOfObject().

Referenced by buildExportFileXML().

119  : void {
120  $mobs = ilObjMediaObject::_getMobsOfObject("svy:html", $this->survey_obj->getId());
121  foreach ($mobs as $mob) {
122  $mob_obj = new ilObjMediaObject($mob);
123  $mob_obj->exportFiles($a_export_dir);
124  unset($mob_obj);
125  }
126  // #14850
127  foreach ($this->survey_obj->questions as $question_id) {
128  $mobs = ilObjMediaObject::_getMobsOfObject("spl:html", $question_id);
129  foreach ($mobs as $mob) {
130  $mob_obj = new ilObjMediaObject($mob);
131  $mob_obj->exportFiles($a_export_dir);
132  unset($mob_obj);
133  }
134  }
135  }
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: