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