ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilLearningModuleExporter.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2019 ILIAS open source, Extended GPL, see docs/LICENSE */
4
13{
14 private $ds;
18 private $config;
19
23 public function init()
24 {
25 $this->ds = new ilLearningModuleDataSet();
26 $this->ds->setExportDirectories($this->dir_relative, $this->dir_absolute);
27 $this->ds->setDSPrefix("ds");
28 $this->config = $this->getExport()->getConfig("Modules/LearningModule");
29 if ($this->config->getMasterLanguageOnly()) {
30 $conf = $this->getExport()->getConfig("Services/COPage");
31 $conf->setMasterLanguageOnly(true, $this->config->getIncludeMedia());
32 $this->ds->setMasterLanguageOnly(true);
33 }
34 }
35
44 public function getXmlExportTailDependencies($a_entity, $a_target_release, $a_ids)
45 {
46 $deps = array();
47
48 if ($a_entity == "lm") {
49 $md_ids = array();
50
51 // lm related ids
52 foreach ($a_ids as $id) {
53 $md_ids[] = $id . ":0:lm";
54 }
55
56 // chapter related ids
57 foreach ($a_ids as $id) {
58 $chaps = ilLMObject::getObjectList($id, "st");
59 foreach ($chaps as $c) {
60 $md_ids[] = $id . ":" . $c["obj_id"] . ":st";
61 }
62 }
63
64 // page related ids
65 $pg_ids = array();
66 foreach ($a_ids as $id) {
67 $pages = ilLMPageObject::getPageList($id);
68 foreach ($pages as $p) {
69 $pg_ids[] = "lm:" . $p["obj_id"];
70 $md_ids[] = $id . ":" . $p["obj_id"] . ":pg";
71 }
72 }
73
74 // style, multilang, metadata per page/chap?
75
76 $deps = array(
77 array(
78 "component" => "Services/COPage",
79 "entity" => "pg",
80 "ids" => $pg_ids),
81 array(
82 "component" => "Services/MetaData",
83 "entity" => "md",
84 "ids" => $md_ids),
85 );
86
87 if (!$this->config->getMasterLanguageOnly()) {
88 $deps[] = array(
89 "component" => "Services/Object",
90 "entity" => "transl",
91 "ids" => $md_ids);
92 }
93 $deps[] = array(
94 "component" => "Services/Object",
95 "entity" => "tile",
96 "ids" => $a_ids);
97
98 // help export
99 foreach ($a_ids as $id) {
101 $deps[] = array(
102 "component" => "Services/Help",
103 "entity" => "help",
104 "ids" => array($id));
105 }
106 }
107
108 // style
109 foreach ($a_ids as $id) {
110 if (($s = ilObjContentObject::_lookupStyleSheetId($id)) > 0) {
111 $deps[] = array(
112 "component" => "Services/Style",
113 "entity" => "sty",
114 "ids" => $s
115 );
116 }
117 }
118 }
119
120 return $deps;
121 }
122
123
124
133 public function getXmlRepresentation($a_entity, $a_schema_version, $a_id)
134 {
135 // workaround: old question export
136 $q_ids = array();
137 $pages = ilLMPageObject::getPageList($a_id);
138 foreach ($pages as $p) {
139 $langs = array("-");
140 if (!$this->config->getMasterLanguageOnly()) {
141 $trans = ilPageObject::lookupTranslations("lm", $p["obj_id"]);
142 foreach ($trans as $t) {
143 if ($t != "-") {
144 $langs[] = $t;
145 }
146 }
147 }
148 foreach ($langs as $l) {
149 // collect questions
150 foreach (ilPCQuestion::_getQuestionIdsForPage("lm", $p["obj_id"], $l) as $q_id) {
151 $q_ids[$q_id] = $q_id;
152 }
153 }
154 }
155 if (count($q_ids) > 0) {
156 $dir = $this->getExport()->export_run_dir;
157 $qti_file = fopen($dir . "/qti.xml", "w");
158 $pool = new ilObjQuestionPool();
159 fwrite($qti_file, $pool->questionsToXML($q_ids));
160 fclose($qti_file);
161 }
162
163 return $this->ds->getXmlRepresentation($a_entity, $a_schema_version, $a_id, "", true, true);
164 }
165
173 public function getValidSchemaVersions($a_entity)
174 {
175 return array(
176 "5.4.0" => array(
177 "namespace" => "http://www.ilias.de/Modules/LearningModule/lm/5_4",
178 "xsd_file" => "ilias_lm_5_4.xsd",
179 "uses_dataset" => true,
180 "min" => "5.4.0",
181 "max" => ""),
182 "5.1.0" => array(
183 "namespace" => "http://www.ilias.de/Modules/LearningModule/lm/5_1",
184 "xsd_file" => "ilias_lm_5_1.xsd",
185 "uses_dataset" => true,
186 "min" => "5.1.0",
187 "max" => ""),
188 "4.1.0" => array(
189 "namespace" => "http://www.ilias.de/Modules/LearningModule/lm/4_1",
190 "xsd_file" => "ilias_lm_4_1.xsd",
191 "uses_dataset" => false,
192 "min" => "4.1.0",
193 "max" => "")
194 );
195 }
196}
An exception for terminatinating execution or to throw for unit testing.
static getObjectList($lm_id, $type="")
static
static getPageList($lm_id)
static
LearningModule Data set class.
Exporter class for html learning modules.
getXmlRepresentation($a_entity, $a_schema_version, $a_id)
Get xml representation.
getXmlExportTailDependencies($a_entity, $a_target_release, $a_ids)
Get tail dependencies.
getValidSchemaVersions($a_entity)
Returns schema versions that the component can export to.
static _lookupStyleSheetId($a_cont_obj_id)
lookup style sheet ID
static isOnlineHelpModule($a_id, $a_as_obj_id=false)
Is module an online module.
static _getQuestionIdsForPage($a_parent_type, $a_page_id, $a_lang="-")
Get all questions of a page.
static lookupTranslations($a_parent_type, $a_id)
Lookup translations.
Xml Exporter class.
getExport()
Get export.