ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilSCORM2004Node.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
6require_once("./Services/MetaData/classes/class.ilMDLanguageItem.php");
7
19{
21 var $type;
22 var $id;
24
28 function ilSCORM2004Node($a_slm_object, $a_id = 0)
29 {
30 $this->id = $a_id;
31 $this->setSLMObject($a_slm_object);
32 $this->setSLMId($a_slm_object->getId());
33
34 include_once("./Modules/Scorm2004/classes/class.ilSCORM2004Tree.php");
35 $this->tree = new ilSCORM2004Tree($a_slm_object->getId());
36 /*$this->tree = new ilTree($a_slm_object->getId());
37 $this->tree->setTableNames('sahs_sc13_tree', 'sahs_sc13_tree_node');
38 $this->tree->setTreeTablePK("slm_id");*/
39
40 if($a_id != 0)
41 {
42 $this->read();
43 }
44 }
45
51 function setTitle($a_title)
52 {
53 $this->title = $a_title;
54 }
55
61 function getTitle()
62 {
63 return $this->title;
64 }
65
71 function setDescription($a_description)
72 {
73 $this->description = $a_description;
74 }
75
81 function getDescription()
82 {
83 return $this->description;
84 }
85
91 function setType($a_type)
92 {
93 $this->type = $a_type;
94 }
95
101 function getType()
102 {
103 return $this->type;
104 }
105
111 function setSLMId($a_slm_id)
112 {
113 $this->slm_id = $a_slm_id;
114
115 }
116
122 function getSLMId()
123 {
124 return $this->slm_id;
125 }
126
132 function setSLMObject($a_slm_obj)
133 {
134 $this->slm_object = $a_slm_obj;
135 }
136
142 function getSLMObject()
143 {
144 return $this->slm_object;
145 }
146
153 {
154 return $this->slm_object;
155 }
156
162 function setId($a_id)
163 {
164 $this->id = $a_id;
165 }
166
172 function getId()
173 {
174 return $this->id;
175 }
176
182 function getImportId()
183 {
184 return $this->import_id;
185 }
186
192 function setImportId($a_id)
193 {
194 $this->import_id = $a_id;
195 }
196
200 function read()
201 {
202 global $ilBench, $ilDB;
203
204 if(!isset($this->data_record))
205 {
206 $query = "SELECT * FROM sahs_sc13_tree_node WHERE obj_id = ".
207 $ilDB->quote($this->id, "integer");
208 $obj_set = $ilDB->query($query);
209 $this->data_record = $ilDB->fetchAssoc($obj_set);
210 }
211
212 $this->type = $this->data_record["type"];
213 $this->setImportId($this->data_record["import_id"]);
214 $this->setTitle($this->data_record["title"]);
215 }
216
228 function MDUpdateListener($a_element)
229 {
230 include_once 'Services/MetaData/classes/class.ilMD.php';
231
232 switch($a_element)
233 {
234 case 'General':
235
236 // Update Title and description
237 $md = new ilMD($this->getSLMId(), $this->getId(), $this->getType());
238 $md_gen = $md->getGeneral();
239
240 ilSCORM2004Node::_writeTitle($this->getId(), $md_gen->getTitle());
241
242 foreach($md_gen->getDescriptionIds() as $id)
243 {
244 $md_des = $md_gen->getDescription($id);
245// ilLMObject::_writeDescription($this->getId(),$md_des->getDescription());
246 break;
247 }
248
249 break;
250
251 default:
252 }
253 return true;
254 }
255
256
260 function createMetaData()
261 {
262 global $ilUser;
263
264 include_once 'Services/MetaData/classes/class.ilMDCreator.php';
265 $md_creator = new ilMDCreator($this->getSLMId(), $this->getId(), $this->getType());
266 $md_creator->setTitle($this->getTitle());
267 $md_creator->setTitleLanguage($ilUser->getPref('language'));
268 $md_creator->setDescription($this->getDescription());
269 $md_creator->setDescriptionLanguage($ilUser->getPref('language'));
270 $md_creator->setKeywordLanguage($ilUser->getPref('language'));
271 $md_creator->setLanguage($ilUser->getPref('language'));
272 $md_creator->create();
273
274 return true;
275 }
276
280 function updateMetaData()
281 {
282 include_once("Services/MetaData/classes/class.ilMD.php");
283 include_once("Services/MetaData/classes/class.ilMDGeneral.php");
284 include_once("Services/MetaData/classes/class.ilMDDescription.php");
285
286 $md = new ilMD($this->getSLMId(), $this->getId(), $this->getType());
287 $md_gen = $md->getGeneral();
288 $md_gen->setTitle($this->getTitle());
289
290 // sets first description
291 $md_des_ids = $md_gen->getDescriptionIds();
292 if (count($md_des_ids) > 0)
293 {
294 $md_des =& $md_gen->getDescription($md_des_ids[0]);
295// $md_des->setDescription($this->getDescription());
296 $md_des->update();
297 }
298 $md_gen->update();
299 }
300
301
305 function deleteMetaData()
306 {
307 // Delete meta data
308 include_once('Services/MetaData/classes/class.ilMD.php');
309 $md = new ilMD($this->getSLMId(), $this->getId(), $this->getType());
310 $md->deleteAll();
311 }
312
316 function setDataRecord($a_record)
317 {
318 $this->data_record = $a_record;
319 }
320
327 static function _lookupTitle($a_obj_id)
328 {
329 global $ilDB;
330
331 $query = "SELECT * FROM sahs_sc13_tree_node WHERE obj_id = ".
332 $ilDB->quote($a_obj_id, "integer");
333 $obj_set = $ilDB->query($query);
334 $obj_rec = $ilDB->fetchAssoc($obj_set);
335
336 return $obj_rec["title"];
337 }
338
345 static function _lookupType($a_obj_id)
346 {
347 global $ilDB;
348
349 $query = "SELECT * FROM sahs_sc13_tree_node WHERE obj_id = ".
350 $ilDB->quote($a_obj_id, "integer");
351 $obj_set = $ilDB->query($query);
352 $obj_rec = $ilDB->fetchAssoc($obj_set);
353
354 return $obj_rec["type"];
355 }
356
363 static function _writeTitle($a_obj_id, $a_title)
364 {
365 global $ilDB;
366
367 $query = "UPDATE sahs_sc13_tree_node SET ".
368 " title = ".$ilDB->quote($a_title, "text").
369 " WHERE obj_id = ".$ilDB->quote($a_obj_id, "integer");
370 $ilDB->manipulate($query);
371 }
372
379 static function _writeImportId($a_id, $a_import_id)
380 {
381 global $ilDB;
382
383 $q = "UPDATE sahs_sc13_tree_node ".
384 "SET ".
385 "import_id = ".$ilDB->quote($a_import_id, "text").",".
386 "last_update = ".$ilDB->now().
387 "WHERE obj_id = ".$ilDB->quote($a_id, "integer");
388
389 $ilDB->manipulate($q);
390 }
391
397 function create($a_upload = false)
398 {
399 global $ilDB;
400
401 // insert object data
402 $id = $ilDB->nextId("sahs_sc13_tree_node");
403 $query = "INSERT INTO sahs_sc13_tree_node (obj_id, title, type, slm_id, import_id, create_date) ".
404 "VALUES (".
405 $ilDB->quote($id, "integer").",".
406 $ilDB->quote($this->getTitle(), "text").",".
407 $ilDB->quote($this->getType(), "text").", ".
408 $ilDB->quote($this->getSLMId(), "integer").",".
409 $ilDB->quote($this->getImportId(), "text").
410 ", ".$ilDB->now().")";
411 $ilDB->manipulate($query);
412 $this->setId($id);
413
414 if (!$a_upload)
415 {
416 $this->createMetaData();
417 }
418 }
419
423 function update()
424 {
425 global $ilDB;
426
427 $this->updateMetaData();
428
429 $query = "UPDATE sahs_sc13_tree_node SET ".
430 " slm_id = ".$ilDB->quote($this->getSLMId(), "integer").
431 " ,title = ".$ilDB->quote($this->getTitle(), "text").
432 " WHERE obj_id = ".$ilDB->quote($this->getId(), "integer");
433
434 $ilDB->manipulate($query);
435 }
436
440 function delete()
441 {
442 global $ilDB;
443
444 $query = "DELETE FROM sahs_sc13_tree_node WHERE obj_id= ".
445 $ilDB->quote($this->getId(), "integer");
446 $ilDB->manipulate($query);
447
448 $this->deleteMetaData();
449 }
450
462 function _getIdForImportId($a_import_id)
463 {
464 global $ilDB;
465
466 $ilDB->setLimit(1);
467 $q = "SELECT * FROM sahs_sc13_tree_node WHERE import_id = ".
468 $ilDB->quote($a_import_id, "text")." ".
469 " ORDER BY create_date DESC";
470 $obj_set = $ilDB->query($q);
471 while ($obj_rec = $ilDB->fetchAssoc($obj_set))
472 {
473 $slm_id = ilSCORM2004Node::_lookupSLMID($obj_rec["obj_id"]);
474
475 // link only in learning module, that is not trashed
477 {
478 return $obj_rec["obj_id"];
479 }
480 }
481
482 return 0;
483 }
484
492 function _exists($a_id)
493 {
494 global $ilDB;
495
496 include_once("./Services/Link/classes/class.ilInternalLink.php");
497 if (is_int(strpos($a_id, "_")))
498 {
500 }
501
502 $q = "SELECT * FROM sahs_sc13_tree_node WHERE obj_id = ".
503 $ilDB->quote($a_id, "integer");
504 $obj_set = $ilDB->query($q);
505 if ($obj_rec = $ilDB->fetchAssoc($obj_set))
506 {
507 return true;
508 }
509 else
510 {
511 return false;
512 }
513
514 }
515
516
522 function _deleteAllSLMNodes($a_slm_object)
523 {
524 global $ilDB;
525
526 $query = "SELECT * FROM sahs_sc13_tree_node ".
527 "WHERE slm_id = ".$ilDB->quote($a_slm_object->getId(), "integer")." ";
528 $obj_set = $ilDB->query($query);
529
530 require_once("./Modules/Scorm2004/classes/class.ilSCORM2004NodeFactory.php");
531 while($obj_rec = $ilDB->fetchAssoc($obj_set))
532 {
533 $node_obj = ilSCORM2004NodeFactory::getInstance($a_slm_object, $obj_rec["obj_id"],false);
534
535 if (is_object($node_obj))
536 {
537 $node_obj->delete();
538 }
539 }
540
541 return true;
542 }
543
547 function _lookupSLMID($a_id)
548 {
549 global $ilDB;
550
551 $query = "SELECT * FROM sahs_sc13_tree_node WHERE obj_id = ".
552 $ilDB->quote($a_id, "integer")."";
553 $obj_set = $ilDB->query($query);
554 $obj_rec = $ilDB->fetchAssoc($obj_set);
555
556 return $obj_rec["slm_id"];
557 }
558
562 static function putInTree($a_obj, $a_parent_id = "", $a_target_node_id = "")
563 {
564 $tree =& new ilTree($a_obj->getSLMId());
565 $tree->setTreeTablePK("slm_id");
566 $tree->setTableNames('sahs_sc13_tree', 'sahs_sc13_tree_node');
567
568 // determine parent
569 $parent_id = ($a_parent_id != "")
570 ? $a_parent_id
571 : $tree->getRootId();
572
573 // determine target
574 if ($a_target_node_id != "")
575 {
576 $target = $a_target_node_id;
577 }
578 else
579 {
580 // determine last child that serves as predecessor
581 $childs =& $tree->getChilds($parent_id);
582
583 if (count($childs) == 0)
584 {
585 $target = IL_FIRST_NODE;
586 }
587 else
588 {
589 $target = $childs[count($childs) - 1]["obj_id"];
590 }
591 }
592
593 if ($tree->isInTree($parent_id) && !$tree->isInTree($a_obj->getId()))
594 {
595 $tree->insertNode($a_obj->getId(), $parent_id, $target);
596 }
597 }
598
606 static function getTree($a_slm_obj_id)
607 {
608 $tree = new ilTree($a_slm_obj_id);
609 $tree->setTableNames('sahs_sc13_tree', 'sahs_sc13_tree_node');
610 $tree->setTreeTablePK("slm_id");
611 $tree->readRootId();
612
613 return $tree;
614 }
615
619 static function clipboardCopy($a_slm_obj_id, $a_ids)
620 {
621 global $ilUser;
622
623 $tree = ilSCORM2004Node::getTree($a_slm_obj_id);
624
625 $ilUser->clipboardDeleteObjectsOfType("page");
626 $ilUser->clipboardDeleteObjectsOfType("chap");
627 $ilUser->clipboardDeleteObjectsOfType("sco");
628 $ilUser->clipboardDeleteObjectsOfType("ass");
629
630 // put them into the clipboard
631 $time = date("Y-m-d H:i:s", time());
632 foreach ($a_ids as $id)
633 {
634 $curnode = "";
635 if ($tree->isInTree($id))
636 {
637 $curnode = $tree->getNodeData($id);
638 $subnodes = $tree->getSubTree($curnode);
639 foreach($subnodes as $subnode)
640 {
641 if ($subnode["child"] != $id)
642 {
643 $ilUser->addObjectToClipboard($subnode["child"],
644 $subnode["type"], $subnode["title"],
645 $subnode["parent"], $time, $subnode["lft"]);
646 }
647 }
648 }
649 $order = ($curnode["lft"] > 0)
650 ? $curnode["lft"]
651 : (int) ($order + 1);
652 $ilUser->addObjectToClipboard($id,
654 $order);
655 }
656 }
657
661 function clipboardCut($a_slm_obj_id, $a_ids)
662 {
663 $tree = ilSCORM2004Node::getTree($a_slm_obj_id);
664
665 if (!is_array($a_ids))
666 {
667 return false;
668 }
669 else
670 {
671 // get all "top" ids, i.e. remove ids, that have a selected parent
672 foreach($a_ids as $id)
673 {
674 $path = $tree->getPathId($id);
675 $take = true;
676 foreach($path as $path_id)
677 {
678 if ($path_id != $id && in_array($path_id, $a_ids))
679 {
680 $take = false;
681 }
682 }
683 if ($take)
684 {
685 $cut_ids[] = $id;
686 }
687 }
688 }
689
690 ilSCORM2004Node::clipboardCopy($a_slm_obj_id, $cut_ids);
691
692 // remove the objects from the tree
693 // note: we are getting chapters, scos and pages which are *not* in the tree
694 // we do not delete any pages/chapters here
695 foreach ($cut_ids as $id)
696 {
697 $curnode = $tree->getNodeData($id);
698 if ($tree->isInTree($id))
699 {
700 $tree->deleteTree($curnode);
701 }
702 }
703
704 }
705
709 static function uniqueTypesCheck($a_items)
710 {
711 $types = array();
712 if (is_array($a_items))
713 {
714 foreach($a_items as $item)
715 {
717 $types[$type] = $type;
718 }
719 }
720
721 if (count($types) > 1)
722 {
723 return false;
724 }
725 return true;
726 }
727
731 static function insertPageClip($a_slm_obj)
732 {
733 global $ilUser;
734
735 // @todo: move this to a service since it can be used here, too
736 include_once("./Modules/LearningModule/classes/class.ilEditClipboard.php");
737
738 include_once("./Modules/Scorm2004/classes/class.ilSCORM2004OrganizationHFormGUI.php");
741
742 $tree = ilSCORM2004Node::getTree($a_slm_obj->getId());
743
744 if (!$first_child) // insert after node id
745 {
746 $parent_id = $tree->getParentId($node_id);
747 $target = $node_id;
748 }
749 else // insert as first child
750 {
751 $parent_id = $node_id;
752 $target = IL_FIRST_NODE;
753 }
754
755 // cut and paste
756 $source_parent_type = "";
757 if ($ilUser->getClipboardObjects("page"))
758 {
759 $pages = $ilUser->getClipboardObjects("page");
760 }
761 else if ($ilUser->getClipboardObjects("pg"))
762 {
763 $source_parent_type = "lm";
764 $pages = $ilUser->getClipboardObjects("pg");
765 }
766 $copied_nodes = array();
767
768 foreach ($pages as $pg)
769 {
770 $cid = ilSCORM2004Node::pasteTree($a_slm_obj, $pg["id"], $parent_id, $target,
771 $pg["insert_time"], $copied_nodes,
772 (ilEditClipboard::getAction() == "copy"), true, $source_parent_type);
773 $target = $cid;
774 }
775 //ilLMObject::updateInternalLinks($copied_nodes);
776
777 if (ilEditClipboard::getAction() == "cut")
778 {
779 $ilUser->clipboardDeleteObjectsOfType("page");
780 $ilUser->clipboardDeleteObjectsOfType("chap");
781 $ilUser->clipboardDeleteObjectsOfType("sco");
782 $ilUser->clipboardDeleteObjectsOfType("ass");
783 $ilUser->clipboardDeleteObjectsOfType("pg");
785 }
786 }
787
791 static function insertAssetClip($a_slm_obj, $a_type = "ass")
792 {
793 global $ilCtrl, $ilUser;
794
795 // @todo: move this to a service since it can be used here, too
796 include_once("./Modules/LearningModule/classes/class.ilEditClipboard.php");
797
798 include_once("./Modules/Scorm2004/classes/class.ilSCORM2004OrganizationHFormGUI.php");
801
802 $tree = ilSCORM2004Node::getTree($a_slm_obj->getId());
803
804 if (!$first_child) // insert after node id
805 {
806 $parent_id = $tree->getParentId($node_id);
807 $target = $node_id;
808 }
809 else // insert as first child
810 {
811 $parent_id = $node_id;
812 $target = IL_FIRST_NODE;
813 }
814
815 // cut and paste
816 $scos = $ilUser->getClipboardObjects($a_type);
817 $copied_nodes = array();
818 foreach ($scos as $sco)
819 {
820 $cid = ilSCORM2004Node::pasteTree($a_slm_obj, $sco["id"], $parent_id, $target,
821 $sco["insert_time"], $copied_nodes,
822 (ilEditClipboard::getAction() == "copy"));
823 $target = $cid;
824 }
825 //ilLMObject::updateInternalLinks($copied_nodes);
826
827 if (ilEditClipboard::getAction() == "cut")
828 {
829 $ilUser->clipboardDeleteObjectsOfType("page");
830 $ilUser->clipboardDeleteObjectsOfType("chap");
831 $ilUser->clipboardDeleteObjectsOfType("sco");
832 $ilUser->clipboardDeleteObjectsOfType("ass");
834 }
835 }
836
840 static function insertScoClip($a_slm_obj)
841 {
842 self::insertAssetClip($a_slm_obj, "sco");
843 }
844
845
849 function insertChapterClip($a_slm_obj, $a_as_sub = false)
850 {
851 global $ilUser, $ilCtrl, $ilLog;
852
853 // @todo: move this to a service since it can be used here, too
854 include_once("./Modules/LearningModule/classes/class.ilEditClipboard.php");
855
856 include_once("./Modules/Scorm2004/classes/class.ilSCORM2004OrganizationHFormGUI.php");
859
860 $tree = ilSCORM2004Node::getTree($a_slm_obj->getId());
861
862 if ($a_as_sub) // as subchapter
863 {
864 if (!$first_child) // insert under parent
865 {
866 $parent_id = $node_id;
867 $target = "";
868 }
869 else // we shouldnt end up here
870 {
871 return;
872 }
873 }
874 else // as chapter
875 {
876 if (!$first_child) // insert after node id
877 {
878 $parent_id = $tree->getParentId($node_id);
879 $target = $node_id;
880 }
881 else // insert as first child
882 {
883 $parent_id = $node_id;
884 $target = IL_FIRST_NODE;
885
886 // do not move a chapter in front of a sco (maybe never needed)
887 $childs = $tree->getChildsByType($parent_id, "sco");
888 if (count($childs) != 0)
889 {
890 $target = $childs[count($childs) - 1]["obj_id"];
891 }
892 }
893 }
894
895 // copy and paste
896 $chapters = $ilUser->getClipboardObjects("chap", true);
897 $copied_nodes = array();
898 foreach ($chapters as $chap)
899 {
900 $cid = ilSCORM2004Node::pasteTree($a_slm_obj, $chap["id"], $parent_id,
901 $target, $chap["insert_time"], $copied_nodes,
902 (ilEditClipboard::getAction() == "copy"));
903 $target = $cid;
904 }
905 //ilLMObject::updateInternalLinks($copied_nodes);
906
907 if (ilEditClipboard::getAction() == "cut")
908 {
909 $ilUser->clipboardDeleteObjectsOfType("page");
910 $ilUser->clipboardDeleteObjectsOfType("chap");
911 $ilUser->clipboardDeleteObjectsOfType("sco");
912 $ilUser->clipboardDeleteObjectsOfType("ass");
914 }
915 }
916
929 static function pasteTree($a_target_slm, $a_item_id, $a_parent_id, $a_target, $a_insert_time,
930 &$a_copied_nodes, $a_as_copy = false, $a_from_clipboard = true, $a_source_parent_type = "")
931 {
932 global $ilUser, $ilLog;
933
934 $item_type = "";
935
936 if (in_array($a_source_parent_type, array("", "sahs")))
937 {
938 // source lm id, item type and lm object
939 $item_slm_id = ilSCORM2004Node::_lookupSLMID($a_item_id);
940 $item_type = ilSCORM2004Node::_lookupType($a_item_id);
941 //$slm_obj = $ilias->obj_factory->getInstanceByObjId($item_slm_id);
942
943 include_once("./Modules/Scorm2004/classes/class.ilObjSCORM2004LearningModule.php");
944 $slm_obj = new ilObjSCORM2004LearningModule($item_slm_id, false);
945
946 $ilLog->write("Getting from clipboard type ".$item_type.", ".
947 "Item ID: ".$a_item_id.", of original SLM: ".$item_slm_id);
948 }
949 else if (in_array($a_source_parent_type, array("lm")))
950 {
951 include_once("./Modules/LearningModule/classes/class.ilLMObject.php");
952 $item_lm_id = ilLMObject::_lookupContObjId($a_item_id);
953 $item_type = ilLMObject::_lookupType($a_item_id, $item_lm_id);
954
955 include_once("./Modules/LearningModule/classes/class.ilObjLearningModule.php");
956 $lm_obj = new ilObjLearningModule($item_lm_id, false);
957
958 $ilLog->write("Getting from clipboard type ".$item_type.", ".
959 "Item ID: ".$a_item_id.", of original SLM: ".$item_lm_id);
960 }
961
962
963
964 if ($item_type == "chap")
965 {
966 include_once("./Modules/Scorm2004/classes/class.ilSCORM2004Chapter.php");
967 $item = new ilSCORM2004Chapter($slm_obj, $a_item_id);
968 }
969 else if ($item_type == "page")
970 {
971 include_once("./Modules/Scorm2004/classes/class.ilSCORM2004PageNode.php");
972 $item = new ilSCORM2004PageNode($slm_obj, $a_item_id);
973 }
974 else if ($item_type == "sco")
975 {
976 include_once("./Modules/Scorm2004/classes/class.ilSCORM2004Sco.php");
977 $item = new ilSCORM2004Sco($slm_obj, $a_item_id);
978 }
979 else if ($item_type == "ass")
980 {
981 include_once("./Modules/Scorm2004/classes/class.ilSCORM2004Asset.php");
982 $item = new ilSCORM2004Asset($slm_obj, $a_item_id);
983 }
984 else if ($item_type == "pg")
985 {
986 include_once("./Modules/LearningModule/classes/class.ilLMPageObject.php");
987 $item = new ilLMPageObject($lm_obj, $a_item_id);
988 }
989
990
991 if ($item_slm_id != $a_target_slm->getId() && !$a_as_copy)
992 {
993 // @todo: check whether st is NOT in tree
994
995 // "move" metadata to new lm
996 include_once("Services/MetaData/classes/class.ilMD.php");
997 $md = new ilMD($item_slm_id, $item->getId(), $item->getType());
998 $new_md = $md->cloneMD($a_target_slm->getId(), $item->getId(), $item->getType());
999
1000 // update lm object
1001 $item->setSLMId($a_target_slm->getId());
1002 $item->setSLMObject($a_target_slm);
1003 $item->update();
1004
1005 // delete old meta data set
1006 $md->deleteAll();
1007
1008 if ($item_type == "page")
1009 {
1010 $page = $item->getPageObject();
1011 $page->buildDom($a_from_clipboard);
1012 $page->setParentId($a_target_slm->getId());
1013 $page->update();
1014 }
1015 }
1016
1017 if ($a_as_copy)
1018 {
1019 if ($a_source_parent_type == "lm")
1020 {
1021 if ($item_type = "pg")
1022 {
1023 include_once("./Modules/Scorm2004/classes/class.ilSCORM2004PageNode.php");
1024 $target_item = ilSCORM2004PageNode::copyPageFromLM($a_target_slm, $item);
1025 }
1026 }
1027 else
1028 {
1029 $target_item = $item->copy($a_target_slm);
1030 }
1031 $a_copied_nodes[$item->getId()] = $target_item->getId();
1032 }
1033 else
1034 {
1035 $target_item = $item;
1036 }
1037
1038 $ilLog->write("Putting into tree type ".$target_item->getType().
1039 "Item ID: ".$target_item->getId().", Parent: ".$a_parent_id.", ".
1040 "Target: ".$a_target.", Item LM:".$target_item->getContentObject()->getId());
1041
1042 ilSCORM2004Node::putInTree($target_item, $a_parent_id, $a_target);
1043
1044 if ($a_from_clipboard)
1045 {
1046 $childs = $ilUser->getClipboardChilds($item->getId(), $a_insert_time);
1047 }
1048 else
1049 {
1050 // get childs of source tree
1051 $source_tree = $slm_obj->getTree();
1052 $childs = $source_tree->getChilds($a_item_id);
1053 }
1054
1055 foreach($childs as $child)
1056 {
1057 $child_id = ($a_from_clipboard)
1058 ? $child["id"]
1059 : $child["child"];
1060 ilSCORM2004Node::pasteTree($a_target_slm, $child_id, $target_item->getId(),
1061 IL_LAST_NODE, $a_insert_time, $a_copied_nodes, $a_as_copy, $a_from_clipboard, $a_source_parent_type);
1062 }
1063
1064 return $target_item->getId();
1065 }
1066
1067 //Methods for Sequencing
1068
1069 //objectives per node
1070 public function getObjectives()
1071 {
1072 include_once("./Modules/Scorm2004/classes/seq_editor/class.ilSCORM2004Objective.php");
1073 return ilSCORM2004Objective::fetchAllObjectives($this->slm_object,$this->getId());
1074 }
1075
1076 public function deleteSeqInfo()
1077 {
1078 include_once("./Modules/Scorm2004/classes/seq_editor/class.ilSCORM2004Item.php");
1079 $seq_item = new ilSCORM2004Item($this->getId());
1080 $seq_item -> delete();
1081 }
1082
1083 //function currently unused - shouldn't be removed if subchapter support may be added in the future
1084 public function parentHasSeqTemplate(){
1085 include_once("./Modules/Scorm2004/classes/seq_editor/class.ilSCORM2004Utilities.php");
1086 $seq_util = new ilSCORM2004Utilities($this->getId());
1087 return $seq_util -> parentHasSeqTemplate($this->slm_object);
1088 }
1089
1090
1091 public function exportAsScorm12() {
1092 //to implement
1093 return;
1094 }
1095
1096 public function exportAsScorm13() {
1097 //to implement
1098 return;
1099 }
1100
1101
1102
1103}
1104?>
const IL_LAST_NODE
Definition: class.ilTree.php:4
const IL_FIRST_NODE
Definition: class.ilTree.php:5
static getPostNodeId()
Get node ID of _POST input.
static getPostFirstChild()
Should node be inserted as first child of target node (true) or as successor (false)
static _lookupType($a_obj_id, $a_lm_id=0)
Lookup type.
Class ilLMPageObject.
Class ilObjLearningModule.
Class ilObjSCORM2004LearningModule.
_hasUntrashedReference($a_obj_id)
checks wether an object has at least one reference that is not in trash
Class ilSCORM2004Asset.
Class ilSCORM2004Chapter.
Class ilSCORM2004Condition.
static getInstance($a_slm_object, $a_id=0, $a_halt=true)
static uniqueTypesCheck($a_items)
Check for unique types (all pages or all chapters or all scos)
setSLMId($a_slm_id)
Set ID of parent Scorm Learning Module Object.
insertChapterClip($a_slm_obj, $a_as_sub=false)
Insert Chapter from clipboard.
setImportId($a_id)
Get Import ID.
getContentObject()
Get Scorm Learning Module Object.
read()
Read Data of Node.
setId($a_id)
Set Node ID.
setDescription($a_description)
Set description.
create($a_upload=false)
Create Node.
getImportId()
Set Import ID.
static pasteTree($a_target_slm, $a_item_id, $a_parent_id, $a_target, $a_insert_time, &$a_copied_nodes, $a_as_copy=false, $a_from_clipboard=true, $a_source_parent_type="")
Paste item (tree) from clipboard or other learning module to target scorm learning module.
setDataRecord($a_record)
this method should only be called by class ilSCORM2004NodeFactory
_lookupSLMID($a_id)
Lookup Scorm Learning Module ID for node id.
getSLMObject()
Get scorm learning module object.
clipboardCut($a_slm_obj_id, $a_ids)
Cut and copy a set of chapters/pages into the clipboard.
setSLMObject($a_slm_obj)
Set Scorm Learning Module Object.
ilSCORM2004Node($a_slm_object, $a_id=0)
static _lookupType($a_obj_id)
Lookup Type.
static insertAssetClip($a_slm_obj, $a_type="ass")
Insert assets from clipboard.
static putInTree($a_obj, $a_parent_id="", $a_target_node_id="")
put this object into content object tree
static clipboardCopy($a_slm_obj_id, $a_ids)
Copy a set of chapters/pages/scos into the clipboard.
_deleteAllSLMNodes($a_slm_object)
Delete all nodes of Scorm Learning Module.
static _writeImportId($a_id, $a_import_id)
Write import ID.
setTitle($a_title)
Set title.
deleteMetaData()
delete meta data entry
static insertPageClip($a_slm_obj)
Insert pages from clipboard.
MDUpdateListener($a_element)
Meta data update listener.
_exists($a_id)
Checks wether a node exists.
static insertScoClip($a_slm_obj)
Insert scos from clipboard.
getSLMId()
Get ID of parent Scorm Learning Module Object.
static getTree($a_slm_obj_id)
Get scorm module editing tree.
setType($a_type)
Set type.
static _lookupTitle($a_obj_id)
Lookup Title.
getDescription()
Get description.
createMetaData()
create meta data entry
_getIdForImportId($a_import_id)
Get Node ID for import ID (static)
updateMetaData()
update meta data entry
static _writeTitle($a_obj_id, $a_title)
Write Title.
static fetchAllObjectives($a_slm_object, $a_tree_node_id)
Class ilSCORM2004PageNode.
static copyPageFromLM($a_target_slm, $a_lm_page)
Copy page from learning module.
Class ilSCORM2004Sco.
SCORM 2004 Editing tree.
Class ilSCORM2004Utilities.
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
global $ilBench
Definition: ilias.php:18
global $ilCtrl
Definition: ilias.php:18
$path
Definition: index.php:22
global $ilDB
global $ilUser
Definition: imgupload.php:15