ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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;
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) {
72  $pages = ilLMPageObject::getPageList($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  $deps[] = array(
99  "component" => "Services/Object",
100  "entity" => "tile",
101  "ids" => $a_ids);
102 
103  // help export
104  foreach ($a_ids as $id) {
105  include_once("./Modules/LearningModule/classes/class.ilObjContentObject.php");
107  $deps[] = array(
108  "component" => "Services/Help",
109  "entity" => "help",
110  "ids" => array($id));
111  }
112  }
113 
114  // style
115  foreach ($a_ids as $id) {
116  include_once("./Modules/LearningModule/classes/class.ilObjContentObject.php");
117  if (($s = ilObjContentObject::_lookupStyleSheetId($id)) > 0) {
118  $deps[] = array(
119  "component" => "Services/Style",
120  "entity" => "sty",
121  "ids" => $s
122  );
123  }
124  }
125  }
126 
127  return $deps;
128  }
129 
130 
131 
140  public function getXmlRepresentation($a_entity, $a_schema_version, $a_id)
141  {
142  // workaround: old question export
143  $q_ids = array();
144  include_once("./Modules/LearningModule/classes/class.ilLMPageObject.php");
145  $pages = ilLMPageObject::getPageList($a_id);
146  foreach ($pages as $p) {
147  $langs = array("-");
148  if (!$this->config->getMasterLanguageOnly()) {
149  $trans = ilPageObject::lookupTranslations("lm", $p["obj_id"]);
150  foreach ($trans as $t) {
151  if ($t != "-") {
152  $langs[] = $t;
153  }
154  }
155  }
156  foreach ($langs as $l) {
157  // collect questions
158  include_once("./Services/COPage/classes/class.ilPCQuestion.php");
159  foreach (ilPCQuestion::_getQuestionIdsForPage("lm", $p["obj_id"], $l) as $q_id) {
160  $q_ids[$q_id] = $q_id;
161  }
162  }
163  }
164  if (count($q_ids) > 0) {
165  $dir = $this->getExport()->export_run_dir;
166  $qti_file = fopen($dir . "/qti.xml", "w");
167  include_once("./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php");
168  $pool = new ilObjQuestionPool();
169  fwrite($qti_file, $pool->questionsToXML($q_ids));
170  fclose($qti_file);
171  }
172 
173  return $this->ds->getXmlRepresentation($a_entity, $a_schema_version, $a_id, "", true, true);
174 
175  /*include_once './Modules/LearningModule/classes/class.ilObjLearningModule.php';
176  $lm = new ilObjLearningModule($a_id,false);
177 
178  include_once './Modules/LearningModule/classes/class.ilContObjectExport.php';
179  $exp = new ilContObjectExport($lm);
180  $zip = $exp->buildExportFile();*/
181  }
182 
190  public function getValidSchemaVersions($a_entity)
191  {
192  return array(
193  "5.4.0" => array(
194  "namespace" => "http://www.ilias.de/Modules/LearningModule/lm/5_4",
195  "xsd_file" => "ilias_lm_5_4.xsd",
196  "uses_dataset" => true,
197  "min" => "5.4.0",
198  "max" => ""),
199  "5.1.0" => array(
200  "namespace" => "http://www.ilias.de/Modules/LearningModule/lm/5_1",
201  "xsd_file" => "ilias_lm_5_1.xsd",
202  "uses_dataset" => true,
203  "min" => "5.1.0",
204  "max" => ""),
205  "4.1.0" => array(
206  "namespace" => "http://www.ilias.de/Modules/LearningModule/lm/4_1",
207  "xsd_file" => "ilias_lm_4_1.xsd",
208  "uses_dataset" => false,
209  "min" => "4.1.0",
210  "max" => "")
211  );
212  }
213 }
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.
if(!array_key_exists('StateId', $_REQUEST)) $id
$s
Definition: pwgen.php:45
Xml Exporter class.
getValidSchemaVersions($a_entity)
Returns schema versions that the component can export to.
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.