ILIAS  release_7 Revision v7.30-3-g800a261c036
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 $deps[] = array(
93 "component" => "Services/Object",
94 "entity" => "transl_entry",
95 "ids" => $a_ids);
96 }
97 $deps[] = array(
98 "component" => "Services/Object",
99 "entity" => "tile",
100 "ids" => $a_ids);
101
102 // help export
103 foreach ($a_ids as $id) {
105 $deps[] = array(
106 "component" => "Services/Help",
107 "entity" => "help",
108 "ids" => array($id));
109 }
110 }
111
112 // style
113 foreach ($a_ids as $id) {
114 if (($s = ilObjContentObject::_lookupStyleSheetId($id)) > 0) {
115 $deps[] = array(
116 "component" => "Services/Style",
117 "entity" => "sty",
118 "ids" => $s
119 );
120 }
121 }
122 }
123
124 return $deps;
125 }
126
127
128
137 public function getXmlRepresentation($a_entity, $a_schema_version, $a_id)
138 {
139 // workaround: old question export
140 $q_ids = array();
141 $pages = ilLMPageObject::getPageList($a_id);
142 foreach ($pages as $p) {
143 $langs = array("-");
144 if (!$this->config->getMasterLanguageOnly()) {
145 $trans = ilPageObject::lookupTranslations("lm", $p["obj_id"]);
146 foreach ($trans as $t) {
147 if ($t != "-") {
148 $langs[] = $t;
149 }
150 }
151 }
152 foreach ($langs as $l) {
153 // collect questions
154 foreach (ilPCQuestion::_getQuestionIdsForPage("lm", $p["obj_id"], $l) as $q_id) {
155 $q_ids[$q_id] = $q_id;
156 }
157 }
158 }
159 if (count($q_ids) > 0) {
160 $dir = $this->getExport()->export_run_dir;
161 $qti_file = fopen($dir . "/qti.xml", "w");
162 $pool = new ilObjQuestionPool();
163 fwrite($qti_file, $pool->questionsToXML($q_ids));
164 fclose($qti_file);
165 }
166
167 return $this->ds->getXmlRepresentation($a_entity, $a_schema_version, $a_id, "", true, true);
168 }
169
177 public function getValidSchemaVersions($a_entity)
178 {
179 return array(
180 "5.4.0" => array(
181 "namespace" => "http://www.ilias.de/Modules/LearningModule/lm/5_4",
182 "xsd_file" => "ilias_lm_5_4.xsd",
183 "uses_dataset" => true,
184 "min" => "5.4.0",
185 "max" => ""),
186 "5.1.0" => array(
187 "namespace" => "http://www.ilias.de/Modules/LearningModule/lm/5_1",
188 "xsd_file" => "ilias_lm_5_1.xsd",
189 "uses_dataset" => true,
190 "min" => "5.1.0",
191 "max" => ""),
192 "4.1.0" => array(
193 "namespace" => "http://www.ilias.de/Modules/LearningModule/lm/4_1",
194 "xsd_file" => "ilias_lm_4_1.xsd",
195 "uses_dataset" => false,
196 "min" => "4.1.0",
197 "max" => "")
198 );
199 }
200}
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.
$c
Definition: cli.php:37