ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilSurveyExporter.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
4
5
12{
16 private $ds;
17
21 public function init()
22 {
23 $this->ds = new ilSurveyDataSet();
24 $this->ds->setExportDirectories($this->dir_relative, $this->dir_absolute);
25 $this->ds->setDSPrefix("ds");
26 }
27
28
37 public function getXmlRepresentation($a_entity, $a_schema_version, $a_id)
38 {
39 if ($a_entity == "svy") {
40 $svy = new ilObjSurvey($a_id, false);
41 $svy->loadFromDb();
42
43 $svy_exp = new ilSurveyExport($svy, 'xml');
44 $zip = $svy_exp->buildExportFile();
45
46 // Unzip, since survey deletes this dir
47 ilUtil::unzip($zip);
48
49 // unzip does not extract the included directory
50 // Modules/Survey/set_1 anymore (since 7/2023)
51 $missing = $svy_exp->export_dir . "/" . $svy_exp->subdir .
52 "/Modules/Survey/set_1";
53 ilUtil::makeDirParents($missing);
54
55 // here: svy_data/svy_301/export/1698817474__0__svy_301
56 // svy_301/export/1698817474__0__svy_301/Modules/Survey/set_1
57 // svy_data/svy_301/export/1698817474__0__svy_301.zip
58 $GLOBALS['ilLog']->write(__METHOD__ . ': Created zip file ' . $zip);
59 return "";
60 } else {
61 return $this->ds->getXmlRepresentation($a_entity, $a_schema_version, $a_id, "", true, true);
62 }
63 }
64
73 public function getXmlExportTailDependencies($a_entity, $a_target_release, $a_ids)
74 {
75 if ($a_entity == "svy") {
76 return array(
77 array(
78 "component" => "Modules/Survey",
79 "entity" => "svy_quest_skill",
80 "ids" => $a_ids),
81 array(
82 "component" => "Modules/Survey",
83 "entity" => "svy_skill_threshold",
84 "ids" => $a_ids),
85 array(
86 "component" => "Services/Object",
87 "entity" => "common",
88 "ids" => $a_ids)
89 );
90 }
91 return array();
92 }
93
101 public function getValidSchemaVersions($a_entity)
102 {
103 if ($a_entity == "svy") {
104 return array(
105 "4.1.0" => array(
106 "namespace" => "http://www.ilias.de/Modules/Survey/htlm/4_1",
107 "xsd_file" => "ilias_svy_4_1.xsd",
108 "uses_dataset" => false,
109 "min" => "4.1.0",
110 "max" => "")
111 );
112 } else {
113 return array(
114 "5.1.0" => array(
115 "namespace" => "http://www.ilias.de/Modules/Survey/svy/5_1",
116 "xsd_file" => "ilias_svy_5_1.xsd",
117 "uses_dataset" => true,
118 "min" => "5.1.0",
119 "max" => "")
120 );
121 }
122 }
123}
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
An exception for terminatinating execution or to throw for unit testing.
Class ilObjSurvey.
Survey Data set class.
Export class for surveys.
Used for container export with tests.
getXmlExportTailDependencies($a_entity, $a_target_release, $a_ids)
Get tail dependencies.
getValidSchemaVersions($a_entity)
Returns schema versions that the component can export to.
getXmlRepresentation($a_entity, $a_schema_version, $a_id)
Get xml representation.
static unzip(string $path_to_zip_file, bool $overwrite_existing=false, bool $unpack_flat=false)
static makeDirParents($a_dir)
Create a new directory and all parent directories.
Xml Exporter class.