ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 
4 include_once("./Services/Export/classes/class.ilXmlExporter.php");
5 
14 {
15  private $ds;
16  private $config;
17 
21  function init()
22  {
23  include_once("./Modules/LearningModule/classes/class.ilLearningModuleDataSet.php");
24  $this->ds = new ilLearningModuleDataSet();
25  $this->ds->setExportDirectories($this->dir_relative, $this->dir_absolute);
26  $this->ds->setDSPrefix("ds");
27  $this->config = $this->getExport()->getConfig("Modules/LearningModule");
28  if ($this->config->getMasterLanguageOnly())
29  {
30  $conf = $this->getExport()->getConfig("Services/COPage");
31  $conf->setMasterLanguageOnly(true);
32  $this->ds->setMasterLanguageOnly(true);
33  }
34  }
35 
44  function getXmlExportTailDependencies($a_entity, $a_target_release, $a_ids)
45  {
46  include_once("./Modules/LearningModule/classes/class.ilLMObject.php");
47  include_once("./Modules/LearningModule/classes/class.ilLMPageObject.php");
48 
49  $deps = array();
50 
51  if ($a_entity == "lm")
52  {
53  $md_ids = array();
54 
55  // lm related ids
56  foreach ($a_ids as $id)
57  {
58  $md_ids[] = $id . ":0:lm";
59  }
60 
61  // chapter related ids
62  foreach ($a_ids as $id)
63  {
64  $chaps = ilLMObject::getObjectList($id, "st");
65  foreach ($chaps as $c)
66  {
67  $md_ids[] = $id . ":" . $c["obj_id"] . ":st";
68  }
69  }
70 
71  // page related ids
72  $pg_ids = array();
73  foreach ($a_ids as $id)
74  {
75  $pages = ilLMPageObject::getPageList($id);
76  foreach ($pages as $p)
77  {
78  $pg_ids[] = "lm:" . $p["obj_id"];
79  $md_ids[] = $id . ":" . $p["obj_id"] . ":pg";
80  }
81  }
82 
83  // style, multilang, metadata per page/chap?
84 
85  $deps = array(
86  array(
87  "component" => "Services/COPage",
88  "entity" => "pg",
89  "ids" => $pg_ids),
90  array(
91  "component" => "Services/MetaData",
92  "entity" => "md",
93  "ids" => $md_ids),
94  );
95 
96  if (!$this->config->getMasterLanguageOnly())
97  {
98  $deps[] = array(
99  "component" => "Services/Object",
100  "entity" => "transl",
101  "ids" => $md_ids);
102  }
103 
104  // help export
105  foreach ($a_ids as $id)
106  {
107  include_once("./Modules/LearningModule/classes/class.ilObjContentObject.php");
109  {
110  $deps[] = array(
111  "component" => "Services/Help",
112  "entity" => "help",
113  "ids" => array($id));
114  }
115  }
116 
117  // style
118  foreach ($a_ids as $id)
119  {
120  include_once("./Modules/LearningModule/classes/class.ilObjContentObject.php");
121  if (($s = ilObjContentObject::_lookupStyleSheetId($id)) > 0)
122  {
123  $deps[] = array(
124  "component" => "Services/Style",
125  "entity" => "sty",
126  "ids" => $s
127  );
128  }
129  }
130  }
131 
132  return $deps;
133  }
134 
135 
136 
145  public function getXmlRepresentation($a_entity, $a_schema_version, $a_id)
146  {
147  // workaround: old question export
148  $q_ids = array();
149  include_once("./Modules/LearningModule/classes/class.ilLMPageObject.php");
150  $pages = ilLMPageObject::getPageList($a_id);
151  foreach ($pages as $p)
152  {
153  $langs = array("-");
154  if (!$this->config->getMasterLanguageOnly())
155  {
156  $trans = ilPageObject::lookupTranslations("lm", $p["obj_id"]);
157  foreach ($trans as $t)
158  {
159  if ($t != "-")
160  {
161  $langs[] = $t;
162  }
163  }
164  }
165  foreach ($langs as $l)
166  {
167  // collect questions
168  include_once("./Services/COPage/classes/class.ilPCQuestion.php");
169  foreach (ilPCQuestion::_getQuestionIdsForPage("lm", $p["obj_id"], $l) as $q_id)
170  {
171  $q_ids[$q_id] = $q_id;
172  }
173  }
174  }
175  if (count($q_ids) > 0)
176  {
177  $dir = $this->getExport()->export_run_dir;
178  $qti_file = fopen($dir."/qti.xml", "w");
179  include_once("./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php");
180  $pool = new ilObjQuestionPool();
181  fwrite($qti_file, $pool->questionsToXML($q_ids));
182  fclose($qti_file);
183  }
184 
185  return $this->ds->getXmlRepresentation($a_entity, $a_schema_version, $a_id, "", true, true);
186 
187  /*include_once './Modules/LearningModule/classes/class.ilObjLearningModule.php';
188  $lm = new ilObjLearningModule($a_id,false);
189 
190  include_once './Modules/LearningModule/classes/class.ilContObjectExport.php';
191  $exp = new ilContObjectExport($lm);
192  $zip = $exp->buildExportFile();*/
193  }
194 
202  function getValidSchemaVersions($a_entity)
203  {
204  return array (
205  "5.1.0" => array(
206  "namespace" => "http://www.ilias.de/Modules/LearningModule/lm/5_1",
207  "xsd_file" => "ilias_lm_5_1.xsd",
208  "uses_dataset" => true,
209  "min" => "5.1.0",
210  "max" => ""),
211  "4.1.0" => array(
212  "namespace" => "http://www.ilias.de/Modules/LearningModule/lm/4_1",
213  "xsd_file" => "ilias_lm_4_1.xsd",
214  "uses_dataset" => false,
215  "min" => "4.1.0",
216  "max" => "")
217  );
218  }
219 
220 }
221 
222 ?>
static _lookupStyleSheetId($a_cont_obj_id)
lookup style sheet ID
getXmlExportTailDependencies($a_entity, $a_target_release, $a_ids)
Get tail dependencies.
static _getQuestionIdsForPage($a_parent_type, $a_page_id, $a_lang="-")
Get all questions of a page.
Xml Exporter class.
getValidSchemaVersions($a_entity)
Returns schema versions that the component can export to.
Create styles array
The data for the language used.
static isOnlineHelpModule($a_id, $a_as_obj_id=false)
Is module an online module.
LearningModule Data set class.
global $l
Definition: afr.php:30
static lookupTranslations($a_parent_type, $a_id)
Lookup translations.
Exporter class for html learning modules.
static getObjectList($lm_id, $type="")
static
static getPageList($lm_id)
static
getXmlRepresentation($a_entity, $a_schema_version, $a_id)
Get xml representation.
getExport()
Get export.