ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilLearningModuleExporter.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4include_once("./Services/Export/classes/class.ilXmlExporter.php");
5
14{
15 private $ds;
19 private $config;
20
24 public function init()
25 {
26 include_once("./Modules/LearningModule/classes/class.ilLearningModuleDataSet.php");
27 $this->ds = new ilLearningModuleDataSet();
28 $this->ds->setExportDirectories($this->dir_relative, $this->dir_absolute);
29 $this->ds->setDSPrefix("ds");
30 $this->config = $this->getExport()->getConfig("Modules/LearningModule");
31 if ($this->config->getMasterLanguageOnly()) {
32 $conf = $this->getExport()->getConfig("Services/COPage");
33 $conf->setMasterLanguageOnly(true, $this->config->getIncludeMedia());
34 $this->ds->setMasterLanguageOnly(true);
35 }
36 }
37
46 public function getXmlExportTailDependencies($a_entity, $a_target_release, $a_ids)
47 {
48 include_once("./Modules/LearningModule/classes/class.ilLMObject.php");
49 include_once("./Modules/LearningModule/classes/class.ilLMPageObject.php");
50
51 $deps = array();
52
53 if ($a_entity == "lm") {
54 $md_ids = array();
55
56 // lm related ids
57 foreach ($a_ids as $id) {
58 $md_ids[] = $id . ":0:lm";
59 }
60
61 // chapter related ids
62 foreach ($a_ids as $id) {
63 $chaps = ilLMObject::getObjectList($id, "st");
64 foreach ($chaps as $c) {
65 $md_ids[] = $id . ":" . $c["obj_id"] . ":st";
66 }
67 }
68
69 // page related ids
70 $pg_ids = array();
71 foreach ($a_ids as $id) {
73 foreach ($pages as $p) {
74 $pg_ids[] = "lm:" . $p["obj_id"];
75 $md_ids[] = $id . ":" . $p["obj_id"] . ":pg";
76 }
77 }
78
79 // style, multilang, metadata per page/chap?
80
81 $deps = array(
82 array(
83 "component" => "Services/COPage",
84 "entity" => "pg",
85 "ids" => $pg_ids),
86 array(
87 "component" => "Services/MetaData",
88 "entity" => "md",
89 "ids" => $md_ids),
90 );
91
92 if (!$this->config->getMasterLanguageOnly()) {
93 $deps[] = array(
94 "component" => "Services/Object",
95 "entity" => "transl",
96 "ids" => $md_ids);
97 }
98
99 // help export
100 foreach ($a_ids as $id) {
101 include_once("./Modules/LearningModule/classes/class.ilObjContentObject.php");
103 $deps[] = array(
104 "component" => "Services/Help",
105 "entity" => "help",
106 "ids" => array($id));
107 }
108 }
109
110 // style
111 foreach ($a_ids as $id) {
112 include_once("./Modules/LearningModule/classes/class.ilObjContentObject.php");
114 $deps[] = array(
115 "component" => "Services/Style",
116 "entity" => "sty",
117 "ids" => $s
118 );
119 }
120 }
121 }
122
123 return $deps;
124 }
125
126
127
136 public function getXmlRepresentation($a_entity, $a_schema_version, $a_id)
137 {
138 // workaround: old question export
139 $q_ids = array();
140 include_once("./Modules/LearningModule/classes/class.ilLMPageObject.php");
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 include_once("./Services/COPage/classes/class.ilPCQuestion.php");
155 foreach (ilPCQuestion::_getQuestionIdsForPage("lm", $p["obj_id"], $l) as $q_id) {
156 $q_ids[$q_id] = $q_id;
157 }
158 }
159 }
160 if (count($q_ids) > 0) {
161 $dir = $this->getExport()->export_run_dir;
162 $qti_file = fopen($dir . "/qti.xml", "w");
163 include_once("./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php");
164 $pool = new ilObjQuestionPool();
165 fwrite($qti_file, $pool->questionsToXML($q_ids));
166 fclose($qti_file);
167 }
168
169 return $this->ds->getXmlRepresentation($a_entity, $a_schema_version, $a_id, "", true, true);
170
171 /*include_once './Modules/LearningModule/classes/class.ilObjLearningModule.php';
172 $lm = new ilObjLearningModule($a_id,false);
173
174 include_once './Modules/LearningModule/classes/class.ilContObjectExport.php';
175 $exp = new ilContObjectExport($lm);
176 $zip = $exp->buildExportFile();*/
177 }
178
186 public function getValidSchemaVersions($a_entity)
187 {
188 return array(
189 "5.1.0" => array(
190 "namespace" => "http://www.ilias.de/Modules/LearningModule/lm/5_1",
191 "xsd_file" => "ilias_lm_5_1.xsd",
192 "uses_dataset" => true,
193 "min" => "5.1.0",
194 "max" => ""),
195 "4.1.0" => array(
196 "namespace" => "http://www.ilias.de/Modules/LearningModule/lm/4_1",
197 "xsd_file" => "ilias_lm_4_1.xsd",
198 "uses_dataset" => false,
199 "min" => "4.1.0",
200 "max" => "")
201 );
202 }
203}
global $l
Definition: afr.php:30
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.
if(!array_key_exists('StateId', $_REQUEST)) $id
$s
Definition: pwgen.php:45