ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
class.ilSurveyExporter.php
Go to the documentation of this file.
1 <?php
2 
20 
27 {
30 
31  public function init(): void
32  {
33  global $DIC;
34 
35  $this->domain = $DIC->survey()->internal()->domain();
36  $this->ds = new ilSurveyDataSet();
37  $this->ds->setExportDirectories($this->dir_relative, $this->dir_absolute);
38  $this->ds->setDSPrefix("ds");
39  }
40 
41  public function getXmlRepresentation(
42  string $a_entity,
43  string $a_schema_version,
44  string $a_id
45  ): string {
46  if ($a_entity === "svy") {
47  $svy = new ilObjSurvey($a_id, false);
48  $svy->loadFromDb();
49 
50  $svy_exp = new ilSurveyExport($svy, 'xml');
51  $zip = $svy_exp->buildExportFile();
52 
53  // Unzip, since survey deletes this dir
54  $this->domain->resources()->zip()->unzipFile($zip);
55 
56  // unzip does not extract the included directory
57  // Modules/Survey/set_1 anymore (since 7/2023)
58  $missing = $svy_exp->export_dir . "/" . $svy_exp->subdir .
59  "/Modules/Survey/set_1";
61 
62  // here: svy_data/svy_301/export/1698817474__0__svy_301
63  // svy_301/export/1698817474__0__svy_301/Modules/Survey/set_1
64  // svy_data/svy_301/export/1698817474__0__svy_301.zip
65  $GLOBALS['ilLog']->write(__METHOD__ . ': Created zip file ' . $zip);
66  return "";
67  } else {
68  return $this->ds->getXmlRepresentation($a_entity, $a_schema_version, [$a_id], "", true, true);
69  }
70  }
71 
73  string $a_entity,
74  string $a_target_release,
75  array $a_ids
76  ): array {
77  if ($a_entity === "svy") {
78  return array(
79  array(
80  "component" => "Modules/Survey",
81  "entity" => "svy_quest_skill",
82  "ids" => $a_ids),
83  array(
84  "component" => "Modules/Survey",
85  "entity" => "svy_skill_threshold",
86  "ids" => $a_ids),
87  array(
88  "component" => "Services/Object",
89  "entity" => "common",
90  "ids" => $a_ids)
91  );
92  }
93  return array();
94  }
95 
96  public function getValidSchemaVersions(
97  string $a_entity
98  ): array {
99  if ($a_entity === "svy") {
100  return array(
101  "4.1.0" => array(
102  "namespace" => "https://www.ilias.de/Modules/Survey/htlm/4_1",
103  "xsd_file" => "ilias_svy_4_1.xsd",
104  "uses_dataset" => false,
105  "min" => "4.1.0",
106  "max" => "")
107  );
108  } else {
109  return array(
110  "5.1.0" => array(
111  "namespace" => "https://www.ilias.de/Modules/Survey/svy/5_1",
112  "xsd_file" => "ilias_svy_5_1.xsd",
113  "uses_dataset" => true,
114  "min" => "5.1.0",
115  "max" => "")
116  );
117  }
118  }
119 }
getXmlExportTailDependencies(string $a_entity, string $a_target_release, array $a_ids)
getValidSchemaVersions(string $a_entity)
Used for container export with tests.
static makeDirParents(string $a_dir)
Create a new directory and all parent directories.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: feed.php:28
InternalDomainService $domain
$GLOBALS["DIC"]
Definition: wac.php:31
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getXmlRepresentation(string $a_entity, string $a_schema_version, string $a_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...