ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilSCORM2004Chapter.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2008 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
24 require_once("./Modules/Scorm2004/classes/class.ilSCORM2004Node.php");
25 
37 {
38  var $tree;
39 
44  function ilSCORM2004Chapter($a_slm_object, $a_id = 0)
45  {
46  parent::ilSCORM2004Node($a_slm_object, $a_id);
47  $this->setType("chap");
48  }
49 
53  function delete($a_delete_meta_data = true)
54  {
55  $node_data = $this->tree->getNodeData($this->getId());
56  $this->delete_rec($a_delete_meta_data);
57  $this->tree->deleteTree($node_data);
59  }
60 
64  private function delete_rec($a_delete_meta_data = true)
65  {
66  $childs = $this->tree->getChilds($this->getId());
67  foreach ($childs as $child)
68  {
69  $obj =& ilSCORM2004NodeFactory::getInstance($this->slm_object, $child["obj_id"], false);
70  if (is_object($obj))
71  {
72  if ($obj->getType() == "chap")
73  {
74  $obj->delete_rec($a_tree, $a_delete_meta_data);
75  }
76  if ($obj->getType() == "sco")
77  {
78  $obj->delete($a_delete_meta_data);
79  }
80  }
81  unset($obj);
82  }
83  parent::delete($a_delete_meta_data);
84  }
85 
86 
90  function copy($a_target_slm)
91  {
92  $chap = new ilSCORM2004Chapter($a_target_slm);
93  $chap->setTitle($this->getTitle());
94  if ($this->getSLMId() != $a_target_slm->getId())
95  {
96  $chap->setImportId("il__chap_".$this->getId());
97  }
98  $chap->setSLMId($a_target_slm->getId());
99  $chap->setType($this->getType());
100  $chap->setDescription($this->getDescription());
101  $chap->create(true);
102  $a_copied_nodes[$this->getId()] = $chap->getId();
103 
104  // copy meta data
105  include_once("Services/MetaData/classes/class.ilMD.php");
106  $md = new ilMD($this->getSLMId(), $this->getId(), $this->getType());
107  $new_md =& $md->cloneMD($a_target_slm->getId(), $chap->getId(), $this->getType());
108 
109  return $chap;
110  }
111 
118  function exportXML(&$a_xml_writer, $a_inst, &$expLog)
119  {
120 // @todo
121 /*
122  global $ilBench;
123 
124  $expLog->write(date("[y-m-d H:i:s] ")."Structure Object ".$this->getId());
125  $attrs = array();
126  $a_xml_writer->xmlStartTag("StructureObject", $attrs);
127 
128  // MetaData
129  $ilBench->start("ContentObjectExport", "exportStructureObject_exportMeta");
130  $this->exportXMLMetaData($a_xml_writer);
131  $ilBench->stop("ContentObjectExport", "exportStructureObject_exportMeta");
132 
133  // StructureObjects
134  $ilBench->start("ContentObjectExport", "exportStructureObject_exportPageObjects");
135  $this->exportXMLPageObjects($a_xml_writer, $a_inst);
136  $ilBench->stop("ContentObjectExport", "exportStructureObject_exportPageObjects");
137 
138  // PageObjects
139  $this->exportXMLStructureObjects($a_xml_writer, $a_inst, $expLog);
140 
141  // Layout
142  // not implemented
143 
144  $a_xml_writer->xmlEndTag("StructureObject");
145 */
146  }
147 
148 
155  function exportXMLMetaData(&$a_xml_writer)
156  {
157 // @todo
158 /*
159  include_once("Services/MetaData/classes/class.ilMD2XML.php");
160  $md2xml = new ilMD2XML($this->getLMId(), $this->getId(), $this->getType());
161  $md2xml->setExportMode(true);
162  $md2xml->startExport();
163  $a_xml_writer->appendXML($md2xml->getXML());
164 */
165  }
166 
167 // @todo Check this
168 /*
169  function modifyExportIdentifier($a_tag, $a_param, $a_value)
170  {
171 
172  if ($a_tag == "Identifier" && $a_param == "Entry")
173  {
174  $a_value = "il_".IL_INST_ID."_st_".$this->getId();
175  //$a_value = ilUtil::insertInstIntoID($a_value);
176  }
177 
178  return $a_value;
179  }
180 */
181 
186 // @todo Check this
187  function _getPresentationTitle($a_st_id, $a_include_numbers = false)
188  {
189  global $ilDB;
190 /*
191  // get chapter data
192  $query = "SELECT * FROM lm_data WHERE obj_id = ".$ilDB->quote($a_st_id);
193  $st_set = $ilDB->query($query);
194  $st_rec = $st_set->fetchRow(DB_FETCHMODE_ASSOC);
195 
196  $tree = new ilTree($st_rec["lm_id"]);
197  $tree->setTableNames('lm_tree','lm_data');
198  $tree->setTreeTablePK("lm_id");
199 
200  if ($a_include_numbers)
201  {
202  if ($tree->isInTree($st_rec["obj_id"]))
203  {
204  // get chapter tree node
205  $query = "SELECT * FROM lm_tree WHERE child = ".
206  $ilDB->quote($a_st_id)." AND lm_id = ".
207  $ilDB->quote($st_rec["lm_id"]);
208  $tree_set = $ilDB->query($query);
209  $tree_node = $tree_set->fetchRow(DB_FETCHMODE_ASSOC);
210  $depth = $tree_node["depth"];
211 
212  $nr = $tree->getChildSequenceNumber($tree_node, "st")." ";
213  for ($i = $depth - 1; $i > 1; $i --)
214  {
215  // get next parent tree node
216  $query = "SELECT * FROM lm_tree WHERE child = ".
217  $ilDB->quote($tree_node["parent"])." AND lm_id = ".
218  $ilDB->quote($st_rec["lm_id"]);
219  $tree_set = $ilDB->query($query);
220  $tree_node = $tree_set->fetchRow(DB_FETCHMODE_ASSOC);
221  $seq = $tree->getChildSequenceNumber($tree_node, "st");
222 
223  $nr = $seq.".".$nr;
224  }
225  }
226  }
227 
228  return $nr.$st_rec["title"];
229 */
230  }
231 
232 
233 
240  function exportXMLPageObjects(&$a_xml_writer, $a_inst = 0)
241  {
242 // @todo Check this
243 /*
244  include_once './Modules/LearningModule/classes/class.ilLMPageObject.php';
245 
246  global $ilBench;
247 
248  $this->tree = new ilTree($this->getLmId());
249  $this->tree->setTableNames('lm_tree', 'lm_data');
250  $this->tree->setTreeTablePK("lm_id");
251 
252  $childs = $this->tree->getChilds($this->getId());
253  foreach ($childs as $child)
254  {
255  if($child["type"] != "pg")
256  {
257  continue;
258  }
259 
260  // export xml to writer object
261  $ilBench->start("ContentObjectExport", "exportStructureObject_exportPageObjectAlias");
262  //$ilBench->start("ContentObjectExport", "exportStructureObject_getLMPageObject");
263  //$page_obj = new ilLMPageObject($this->getContentObject(), $child["obj_id"]);
264  //$ilBench->stop("ContentObjectExport", "exportStructureObject_getLMPageObject");
265  ilLMPageObject::_exportXMLAlias($a_xml_writer, $child["obj_id"], $a_inst);
266  //$page_obj->exportXML($a_xml_writer, "alias", $a_inst);
267  //unset($page_obj);
268  $ilBench->stop("ContentObjectExport", "exportStructureObject_exportPageObjectAlias");
269  }
270 */
271  }
272 
273 
280  function exportXMLStructureObjects(&$a_xml_writer, $a_inst, &$expLog)
281  {
282 // @todo Check this
283 /*
284  $this->tree = new ilTree($this->getLmId());
285  $this->tree->setTableNames('lm_tree', 'lm_data');
286  $this->tree->setTreeTablePK("lm_id");
287 
288  $childs = $this->tree->getChilds($this->getId());
289  foreach ($childs as $child)
290  {
291  if($child["type"] != "st")
292  {
293  continue;
294  }
295 
296  // export xml to writer object
297  $structure_obj = new ilStructureObject($this->getContentObject(),
298  $child["obj_id"]);
299  $structure_obj->exportXML($a_xml_writer, $a_inst, $expLog);
300  unset($structure_obj);
301  }
302 */
303  }
304 
311 // @todo Check this
312 /*
313  function exportFO(&$a_xml_writer)
314  {
315  global $ilBench;
316 
317  //$expLog->write(date("[y-m-d H:i:s] ")."Structure Object ".$this->getId());
318 
319  // fo:block (complete)
320  $attrs = array();
321  $attrs["font-family"] = "Times";
322  $attrs["font-size"] = "14pt";
323  $a_xml_writer->xmlElement("fo:block", $attrs, $this->getTitle());
324 
325  // page objects
326  //$ilBench->start("ContentObjectExport", "exportStructureObject_exportPageObjects");
327  $this->exportFOPageObjects($a_xml_writer);
328  //$ilBench->stop("ContentObjectExport", "exportStructureObject_exportPageObjects");
329 
330  // structure objects
331  //$this->exportFOStructureObjects($a_xml_writer);
332 
333  }
334 */
335 
342  function exportFOPageObjects(&$a_xml_writer)
343  {
344 // @todo Check this
345 /*
346  global $ilBench;
347 
348  $this->tree = new ilTree($this->getLmId());
349  $this->tree->setTableNames('lm_tree', 'lm_data');
350  $this->tree->setTreeTablePK("lm_id");
351 
352  $childs = $this->tree->getChilds($this->getId());
353  foreach ($childs as $child)
354  {
355  if($child["type"] != "pg")
356  {
357  continue;
358  }
359 
360  // export xml to writer object
361  //$ilBench->start("ContentObjectExport", "exportStructureObject_exportPageObjectAlias");
362 
363  $page_obj = new ilLMPageObject($this->getContentObject(), $child["obj_id"]);
364  $page_obj->exportFO($a_xml_writer);
365 
366  //$ilBench->stop("ContentObjectExport", "exportStructureObject_exportPageObjectAlias");
367  }
368 */
369  }
370 
371 }
372 ?>