ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilLearningModuleExporter.php
Go to the documentation of this file.
1 <?php
2 
25 {
28  protected \ILIAS\Style\Content\DomainService $content_style_domain;
29 
30  public function init(): void
31  {
32  global $DIC;
33 
34  $this->ds = new ilLearningModuleDataSet();
35  $this->ds->setExportDirectories($this->dir_relative, $this->dir_absolute);
36  $this->ds->setDSPrefix("ds");
37  $this->config = $this->getExport()->getConfig("Modules/LearningModule");
38  if ($this->config->getMasterLanguageOnly()) {
39  $conf = $this->getExport()->getConfig("Services/COPage");
40  $conf->setMasterLanguageOnly(true, $this->config->getIncludeMedia());
41  $this->ds->setMasterLanguageOnly(true);
42  }
43  $this->content_style_domain = $DIC->contentStyle()
44  ->domain();
45  }
46 
48  string $a_entity,
49  string $a_target_release,
50  array $a_ids
51  ): array {
52  $deps = array();
53 
54  if ($a_entity == "lm") {
55  $md_ids = array();
56 
57  // lm related ids
58  foreach ($a_ids as $id) {
59  $md_ids[] = $id . ":0:lm";
60  }
61 
62  // chapter related ids
63  foreach ($a_ids as $id) {
64  $chaps = ilLMObject::getObjectList($id, "st");
65  foreach ($chaps as $c) {
66  $md_ids[] = $id . ":" . $c["obj_id"] . ":st";
67  }
68  }
69 
70  // page related ids
71  $pg_ids = array();
72  foreach ($a_ids as $id) {
73  $pages = ilLMPageObject::getPageList($id);
74  foreach ($pages as $p) {
75  $pg_ids[] = "lm:" . $p["obj_id"];
76  $md_ids[] = $id . ":" . $p["obj_id"] . ":pg";
77  }
78  }
79 
80  // style, multilang, metadata per page/chap?
81 
82  $deps = array(
83  array(
84  "component" => "Services/COPage",
85  "entity" => "pg",
86  "ids" => $pg_ids),
87  array(
88  "component" => "Services/MetaData",
89  "entity" => "md",
90  "ids" => $md_ids),
91  );
92 
93  if (!$this->config->getMasterLanguageOnly()) {
94  $deps[] = array(
95  "component" => "Services/Object",
96  "entity" => "transl",
97  "ids" => $md_ids);
98  $deps[] = array(
99  "component" => "Services/Object",
100  "entity" => "transl_entry",
101  "ids" => $a_ids);
102  }
103  $deps[] = array(
104  "component" => "Services/Object",
105  "entity" => "tile",
106  "ids" => $a_ids);
107 
108  $deps[] = array(
109  "component" => "Services/Object",
110  "entity" => "service_settings",
111  "ids" => $a_ids);
112 
113  // help export
114  foreach ($a_ids as $id) {
116  $deps[] = array(
117  "component" => "Services/Help",
118  "entity" => "help",
119  "ids" => array($id));
120  }
121  }
122 
123  // style
124  foreach ($a_ids as $id) {
125  $style_id = $this->content_style_domain->styleForObjId($id)->getStyleId();
126  if ($style_id > 0) {
127  $deps[] = array(
128  "component" => "Services/Style",
129  "entity" => "sty",
130  "ids" => $style_id
131  );
132  }
133  }
134  }
135 
136  return $deps;
137  }
138 
139  public function getXmlRepresentation(
140  string $a_entity,
141  string $a_schema_version,
142  string $a_id
143  ): string {
144  // workaround: old question export
145  $q_ids = array();
146  $pages = ilLMPageObject::getPageList($a_id);
147  foreach ($pages as $p) {
148  $langs = array("-");
149  if (!$this->config->getMasterLanguageOnly()) {
150  $trans = ilPageObject::lookupTranslations("lm", $p["obj_id"]);
151  foreach ($trans as $t) {
152  if ($t != "-") {
153  $langs[] = $t;
154  }
155  }
156  }
157  foreach ($langs as $l) {
158  // collect questions
159  foreach (ilPCQuestion::_getQuestionIdsForPage("lm", $p["obj_id"], $l) as $q_id) {
160  $q_ids[$q_id] = $q_id;
161  }
162  }
163  }
164  if (count($q_ids) > 0) {
165  $dir = $this->getExport()->export_run_dir;
166  $qti_file = fopen($dir . "/qti.xml", "w");
167  $pool = new ilObjQuestionPool();
168  fwrite($qti_file, $pool->questionsToXML($q_ids));
169  fclose($qti_file);
170  }
171 
172  return $this->ds->getXmlRepresentation($a_entity, $a_schema_version, [$a_id], "", true, true);
173  }
174 
175  public function getValidSchemaVersions(
176  string $a_entity
177  ): array {
178  return array(
179  "8.0" => array(
180  "namespace" => "https://www.ilias.de/Modules/LearningModule/lm/8",
181  "xsd_file" => "ilias_lm_8.xsd",
182  "uses_dataset" => true,
183  "min" => "8.0",
184  "max" => ""),
185  "5.4.0" => array(
186  "namespace" => "https://www.ilias.de/Modules/LearningModule/lm/5_4",
187  "xsd_file" => "ilias_lm_5_4.xsd",
188  "uses_dataset" => true,
189  "min" => "5.4.0",
190  "max" => "7.99.99"),
191  "5.1.0" => array(
192  "namespace" => "https://www.ilias.de/Modules/LearningModule/lm/5_1",
193  "xsd_file" => "ilias_lm_5_1.xsd",
194  "uses_dataset" => true,
195  "min" => "5.1.0",
196  "max" => "5.3.99"),
197  "4.1.0" => array(
198  "namespace" => "https://www.ilias.de/Modules/LearningModule/lm/4_1",
199  "xsd_file" => "ilias_lm_4_1.xsd",
200  "uses_dataset" => false,
201  "min" => "4.1.0",
202  "max" => "5.0.99")
203  );
204  }
205 }
$c
Definition: cli.php:38
static getObjectList(int $lm_id, string $type="")
static lookupTranslations(string $a_parent_type, int $a_id)
Lookup translations.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: feed.php:28
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)
ILIAS Style Content DomainService $content_style_domain
getXmlExportTailDependencies(string $a_entity, string $a_target_release, array $a_ids)
LearningModule Data set class.
static getPageList(int $lm_id)
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _getQuestionIdsForPage(string $a_parent_type, int $a_page_id, string $a_lang="-")
static isOnlineHelpModule(int $a_id, bool $a_as_obj_id=false)
Is module an online module.