ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilSCORM2004Chapter.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2011 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
5 require_once("./Modules/Scorm2004/classes/class.ilSCORM2004Node.php");
6 
18 {
19  var $tree;
20 
25  function ilSCORM2004Chapter($a_slm_object, $a_id = 0)
26  {
27  parent::ilSCORM2004Node($a_slm_object, $a_id);
28  $this->setType("chap");
29  }
30 
34  function delete($a_delete_meta_data = true)
35  {
36  $node_data = $this->tree->getNodeData($this->getId());
37  $this->delete_rec($a_delete_meta_data);
38  $this->tree->deleteTree($node_data);
40  }
41 
45  private function delete_rec($a_delete_meta_data = true)
46  {
47  $childs = $this->tree->getChilds($this->getId());
48  foreach ($childs as $child)
49  {
50  $obj =& ilSCORM2004NodeFactory::getInstance($this->slm_object, $child["obj_id"], false);
51  if (is_object($obj))
52  {
53  if ($obj->getType() == "chap")
54  {
55  $obj->delete_rec($a_tree, $a_delete_meta_data);
56  }
57  if ($obj->getType() == "sco")
58  {
59  $obj->delete($a_delete_meta_data);
60  }
61  }
62  unset($obj);
63  }
64  parent::delete($a_delete_meta_data);
65  }
66 
67 
71  function copy($a_target_slm)
72  {
73  $chap = new ilSCORM2004Chapter($a_target_slm);
74  $chap->setTitle($this->getTitle());
75  if ($this->getSLMId() != $a_target_slm->getId())
76  {
77  $chap->setImportId("il__chap_".$this->getId());
78  }
79  $chap->setSLMId($a_target_slm->getId());
80  $chap->setType($this->getType());
81  $chap->setDescription($this->getDescription());
82  $chap->create(true);
83  $a_copied_nodes[$this->getId()] = $chap->getId();
84 
85  // copy meta data
86  include_once("Services/MetaData/classes/class.ilMD.php");
87  $md = new ilMD($this->getSLMId(), $this->getId(), $this->getType());
88  $new_md =& $md->cloneMD($a_target_slm->getId(), $chap->getId(), $this->getType());
89 
90  return $chap;
91  }
92 
99  function exportXML(&$a_xml_writer, $a_inst, &$expLog)
100  {
101 // @todo
102 /*
103  global $ilBench;
104 
105  $expLog->write(date("[y-m-d H:i:s] ")."Structure Object ".$this->getId());
106  $attrs = array();
107  $a_xml_writer->xmlStartTag("StructureObject", $attrs);
108 
109  // MetaData
110  $ilBench->start("ContentObjectExport", "exportStructureObject_exportMeta");
111  $this->exportXMLMetaData($a_xml_writer);
112  $ilBench->stop("ContentObjectExport", "exportStructureObject_exportMeta");
113 
114  // StructureObjects
115  $ilBench->start("ContentObjectExport", "exportStructureObject_exportPageObjects");
116  $this->exportXMLPageObjects($a_xml_writer, $a_inst);
117  $ilBench->stop("ContentObjectExport", "exportStructureObject_exportPageObjects");
118 
119  // PageObjects
120  $this->exportXMLStructureObjects($a_xml_writer, $a_inst, $expLog);
121 
122  // Layout
123  // not implemented
124 
125  $a_xml_writer->xmlEndTag("StructureObject");
126 */
127  }
128 
129 
136  function exportXMLMetaData(&$a_xml_writer)
137  {
138 // @todo
139 /*
140  include_once("Services/MetaData/classes/class.ilMD2XML.php");
141  $md2xml = new ilMD2XML($this->getLMId(), $this->getId(), $this->getType());
142  $md2xml->setExportMode(true);
143  $md2xml->startExport();
144  $a_xml_writer->appendXML($md2xml->getXML());
145 */
146  }
147 
148 // @todo Check this
149 /*
150  function modifyExportIdentifier($a_tag, $a_param, $a_value)
151  {
152 
153  if ($a_tag == "Identifier" && $a_param == "Entry")
154  {
155  $a_value = "il_".IL_INST_ID."_st_".$this->getId();
156  //$a_value = ilUtil::insertInstIntoID($a_value);
157  }
158 
159  return $a_value;
160  }
161 */
162 
167 // @todo Check this
168  function _getPresentationTitle($a_st_id, $a_include_numbers = false)
169  {
170  global $ilDB;
171 /*
172  // get chapter data
173  $query = "SELECT * FROM lm_data WHERE obj_id = ".$ilDB->quote($a_st_id);
174  $st_set = $ilDB->query($query);
175  $st_rec = $st_set->fetchRow(DB_FETCHMODE_ASSOC);
176 
177  $tree = new ilTree($st_rec["lm_id"]);
178  $tree->setTableNames('lm_tree','lm_data');
179  $tree->setTreeTablePK("lm_id");
180 
181  if ($a_include_numbers)
182  {
183  if ($tree->isInTree($st_rec["obj_id"]))
184  {
185  // get chapter tree node
186  $query = "SELECT * FROM lm_tree WHERE child = ".
187  $ilDB->quote($a_st_id)." AND lm_id = ".
188  $ilDB->quote($st_rec["lm_id"]);
189  $tree_set = $ilDB->query($query);
190  $tree_node = $tree_set->fetchRow(DB_FETCHMODE_ASSOC);
191  $depth = $tree_node["depth"];
192 
193  $nr = $tree->getChildSequenceNumber($tree_node, "st")." ";
194  for ($i = $depth - 1; $i > 1; $i --)
195  {
196  // get next parent tree node
197  $query = "SELECT * FROM lm_tree WHERE child = ".
198  $ilDB->quote($tree_node["parent"])." AND lm_id = ".
199  $ilDB->quote($st_rec["lm_id"]);
200  $tree_set = $ilDB->query($query);
201  $tree_node = $tree_set->fetchRow(DB_FETCHMODE_ASSOC);
202  $seq = $tree->getChildSequenceNumber($tree_node, "st");
203 
204  $nr = $seq.".".$nr;
205  }
206  }
207  }
208 
209  return $nr.$st_rec["title"];
210 */
211  }
212 
213 
214 
221  function exportXMLPageObjects(&$a_xml_writer, $a_inst = 0)
222  {
223 // @todo Check this
224 /*
225  include_once './Modules/LearningModule/classes/class.ilLMPageObject.php';
226 
227  global $ilBench;
228 
229  $this->tree = new ilTree($this->getLmId());
230  $this->tree->setTableNames('lm_tree', 'lm_data');
231  $this->tree->setTreeTablePK("lm_id");
232 
233  $childs = $this->tree->getChilds($this->getId());
234  foreach ($childs as $child)
235  {
236  if($child["type"] != "pg")
237  {
238  continue;
239  }
240 
241  // export xml to writer object
242  $ilBench->start("ContentObjectExport", "exportStructureObject_exportPageObjectAlias");
243  //$ilBench->start("ContentObjectExport", "exportStructureObject_getLMPageObject");
244  //$page_obj = new ilLMPageObject($this->getContentObject(), $child["obj_id"]);
245  //$ilBench->stop("ContentObjectExport", "exportStructureObject_getLMPageObject");
246  ilLMPageObject::_exportXMLAlias($a_xml_writer, $child["obj_id"], $a_inst);
247  //$page_obj->exportXML($a_xml_writer, "alias", $a_inst);
248  //unset($page_obj);
249  $ilBench->stop("ContentObjectExport", "exportStructureObject_exportPageObjectAlias");
250  }
251 */
252  }
253 
254 
261  function exportXMLStructureObjects(&$a_xml_writer, $a_inst, &$expLog)
262  {
263 // @todo Check this
264 /*
265  $this->tree = new ilTree($this->getLmId());
266  $this->tree->setTableNames('lm_tree', 'lm_data');
267  $this->tree->setTreeTablePK("lm_id");
268 
269  $childs = $this->tree->getChilds($this->getId());
270  foreach ($childs as $child)
271  {
272  if($child["type"] != "st")
273  {
274  continue;
275  }
276 
277  // export xml to writer object
278  $structure_obj = new ilStructureObject($this->getContentObject(),
279  $child["obj_id"]);
280  $structure_obj->exportXML($a_xml_writer, $a_inst, $expLog);
281  unset($structure_obj);
282  }
283 */
284  }
285 
292 // @todo Check this
293 /*
294  function exportFO(&$a_xml_writer)
295  {
296  global $ilBench;
297 
298  //$expLog->write(date("[y-m-d H:i:s] ")."Structure Object ".$this->getId());
299 
300  // fo:block (complete)
301  $attrs = array();
302  $attrs["font-family"] = "Times";
303  $attrs["font-size"] = "14pt";
304  $a_xml_writer->xmlElement("fo:block", $attrs, $this->getTitle());
305 
306  // page objects
307  //$ilBench->start("ContentObjectExport", "exportStructureObject_exportPageObjects");
308  $this->exportFOPageObjects($a_xml_writer);
309  //$ilBench->stop("ContentObjectExport", "exportStructureObject_exportPageObjects");
310 
311  // structure objects
312  //$this->exportFOStructureObjects($a_xml_writer);
313 
314  }
315 */
316 
323  function exportFOPageObjects(&$a_xml_writer)
324  {
325 // @todo Check this
326 /*
327  global $ilBench;
328 
329  $this->tree = new ilTree($this->getLmId());
330  $this->tree->setTableNames('lm_tree', 'lm_data');
331  $this->tree->setTreeTablePK("lm_id");
332 
333  $childs = $this->tree->getChilds($this->getId());
334  foreach ($childs as $child)
335  {
336  if($child["type"] != "pg")
337  {
338  continue;
339  }
340 
341  // export xml to writer object
342  //$ilBench->start("ContentObjectExport", "exportStructureObject_exportPageObjectAlias");
343 
344  $page_obj = new ilLMPageObject($this->getContentObject(), $child["obj_id"]);
345  $page_obj->exportFO($a_xml_writer);
346 
347  //$ilBench->stop("ContentObjectExport", "exportStructureObject_exportPageObjectAlias");
348  }
349 */
350  }
351 
352 }
353 ?>