ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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{
23 protected $db;
24
28 protected $user;
29
30 public $slm_id;
31 public $type;
32 public $id;
34
38 public function __construct($a_slm_object, $a_id = 0)
39 {
40 global $DIC;
41
42 $this->db = $DIC->database();
43 $this->user = $DIC->user();
44 $this->id = $a_id;
45 $this->setSLMObject($a_slm_object);
46 $this->setSLMId($a_slm_object->getId());
47
48 include_once("./Modules/Scorm2004/classes/class.ilSCORM2004Tree.php");
49 $this->tree = new ilSCORM2004Tree($a_slm_object->getId());
50 /*$this->tree = new ilTree($a_slm_object->getId());
51 $this->tree->setTableNames('sahs_sc13_tree', 'sahs_sc13_tree_node');
52 $this->tree->setTreeTablePK("slm_id");*/
53
54 if ($a_id != 0) {
55 $this->read();
56 }
57 }
58
64 public function setTitle($a_title)
65 {
66 $this->title = $a_title;
67 }
68
74 public function getTitle()
75 {
76 return $this->title;
77 }
78
84 public function setDescription($a_description)
85 {
86 $this->description = $a_description;
87 }
88
94 public function getDescription()
95 {
96 return $this->description;
97 }
98
104 public function setType($a_type)
105 {
106 $this->type = $a_type;
107 }
108
114 public function getType()
115 {
116 return $this->type;
117 }
118
124 public function setSLMId($a_slm_id)
125 {
126 $this->slm_id = $a_slm_id;
127 }
128
134 public function getSLMId()
135 {
136 return $this->slm_id;
137 }
138
144 public function setSLMObject($a_slm_obj)
145 {
146 $this->slm_object = $a_slm_obj;
147 }
148
154 public function getSLMObject()
155 {
156 return $this->slm_object;
157 }
158
164 public function getContentObject()
165 {
166 return $this->slm_object;
167 }
168
174 public function setId($a_id)
175 {
176 $this->id = $a_id;
177 }
178
184 public function getId()
185 {
186 return $this->id;
187 }
188
194 public function getImportId()
195 {
196 return $this->import_id;
197 }
198
204 public function setImportId($a_id)
205 {
206 $this->import_id = $a_id;
207 }
208
212 public function read()
213 {
215
216 if (!isset($this->data_record)) {
217 $query = "SELECT * FROM sahs_sc13_tree_node WHERE obj_id = " .
218 $ilDB->quote($this->id, "integer");
219 $obj_set = $ilDB->query($query);
220 $this->data_record = $ilDB->fetchAssoc($obj_set);
221 }
222
223 $this->type = $this->data_record["type"];
224 $this->setImportId($this->data_record["import_id"]);
225 $this->setTitle($this->data_record["title"]);
226 }
227
239 public function MDUpdateListener($a_element)
240 {
241 include_once 'Services/MetaData/classes/class.ilMD.php';
242
243 switch ($a_element) {
244 case 'General':
245
246 // Update Title and description
247 $md = new ilMD($this->getSLMId(), $this->getId(), $this->getType());
248 $md_gen = $md->getGeneral();
249
250 ilSCORM2004Node::_writeTitle($this->getId(), $md_gen->getTitle());
251
252 foreach ($md_gen->getDescriptionIds() as $id) {
253 $md_des = $md_gen->getDescription($id);
254 // ilLMObject::_writeDescription($this->getId(),$md_des->getDescription());
255 break;
256 }
257
258 break;
259
260 default:
261 }
262 return true;
263 }
264
265
269 public function createMetaData()
270 {
272
273 include_once 'Services/MetaData/classes/class.ilMDCreator.php';
274 $md_creator = new ilMDCreator($this->getSLMId(), $this->getId(), $this->getType());
275 $md_creator->setTitle($this->getTitle());
276 $md_creator->setTitleLanguage($ilUser->getPref('language'));
277 $md_creator->setDescription($this->getDescription());
278 $md_creator->setDescriptionLanguage($ilUser->getPref('language'));
279 $md_creator->setKeywordLanguage($ilUser->getPref('language'));
280 $md_creator->setLanguage($ilUser->getPref('language'));
281 $md_creator->create();
282
283 return true;
284 }
285
289 public function updateMetaData()
290 {
291 include_once("Services/MetaData/classes/class.ilMD.php");
292 include_once("Services/MetaData/classes/class.ilMDGeneral.php");
293 include_once("Services/MetaData/classes/class.ilMDDescription.php");
294
295 $md = new ilMD($this->getSLMId(), $this->getId(), $this->getType());
296 $md_gen = $md->getGeneral();
297 $md_gen->setTitle($this->getTitle());
298
299 // sets first description
300 $md_des_ids = $md_gen->getDescriptionIds();
301 if (count($md_des_ids) > 0) {
302 $md_des = $md_gen->getDescription($md_des_ids[0]);
303 // $md_des->setDescription($this->getDescription());
304 $md_des->update();
305 }
306 $md_gen->update();
307 }
308
309
313 public function deleteMetaData()
314 {
315 // Delete meta data
316 include_once('Services/MetaData/classes/class.ilMD.php');
317 $md = new ilMD($this->getSLMId(), $this->getId(), $this->getType());
318 $md->deleteAll();
319 }
320
324 public function setDataRecord($a_record)
325 {
326 $this->data_record = $a_record;
327 }
328
335 public static function _lookupTitle($a_obj_id)
336 {
337 global $DIC;
338
339 $ilDB = $DIC->database();
340
341 $query = "SELECT * FROM sahs_sc13_tree_node WHERE obj_id = " .
342 $ilDB->quote($a_obj_id, "integer");
343 $obj_set = $ilDB->query($query);
344 $obj_rec = $ilDB->fetchAssoc($obj_set);
345
346 return $obj_rec["title"];
347 }
348
355 public static function _lookupType($a_obj_id)
356 {
357 global $DIC;
358
359 $ilDB = $DIC->database();
360
361 $query = "SELECT * FROM sahs_sc13_tree_node WHERE obj_id = " .
362 $ilDB->quote($a_obj_id, "integer");
363 $obj_set = $ilDB->query($query);
364 $obj_rec = $ilDB->fetchAssoc($obj_set);
365
366 return $obj_rec["type"];
367 }
368
375 public static function _writeTitle($a_obj_id, $a_title)
376 {
377 global $DIC;
378
379 $ilDB = $DIC->database();
380
381 $query = "UPDATE sahs_sc13_tree_node SET " .
382 " title = " . $ilDB->quote($a_title, "text") .
383 " WHERE obj_id = " . $ilDB->quote($a_obj_id, "integer");
384 $ilDB->manipulate($query);
385 }
386
393 public static function _writeImportId($a_id, $a_import_id)
394 {
395 global $DIC;
396
397 $ilDB = $DIC->database();
398
399 $q = "UPDATE sahs_sc13_tree_node " .
400 "SET " .
401 "import_id = " . $ilDB->quote($a_import_id, "text") . "," .
402 "last_update = " . $ilDB->now() .
403 "WHERE obj_id = " . $ilDB->quote($a_id, "integer");
404
405 $ilDB->manipulate($q);
406 }
407
413 public function create($a_upload = false)
414 {
416
417 // insert object data
418 $id = $ilDB->nextId("sahs_sc13_tree_node");
419 $query = "INSERT INTO sahs_sc13_tree_node (obj_id, title, type, slm_id, import_id, create_date) " .
420 "VALUES (" .
421 $ilDB->quote($id, "integer") . "," .
422 $ilDB->quote($this->getTitle(), "text") . "," .
423 $ilDB->quote($this->getType(), "text") . ", " .
424 $ilDB->quote($this->getSLMId(), "integer") . "," .
425 $ilDB->quote($this->getImportId(), "text") .
426 ", " . $ilDB->now() . ")";
427 $ilDB->manipulate($query);
428 $this->setId($id);
429
430 if (!$a_upload) {
431 $this->createMetaData();
432 }
433 }
434
438 public function update()
439 {
441
442 $this->updateMetaData();
443
444 $query = "UPDATE sahs_sc13_tree_node SET " .
445 " slm_id = " . $ilDB->quote($this->getSLMId(), "integer") .
446 " ,title = " . $ilDB->quote($this->getTitle(), "text") .
447 " WHERE obj_id = " . $ilDB->quote($this->getId(), "integer");
448
449 $ilDB->manipulate($query);
450 }
451
455 public function delete()
456 {
458
459 $query = "DELETE FROM sahs_sc13_tree_node WHERE obj_id= " .
460 $ilDB->quote($this->getId(), "integer");
461 $ilDB->manipulate($query);
462
463 $this->deleteMetaData();
464 }
465
477 public static function _getIdForImportId($a_import_id)
478 {
479 global $DIC;
480
481 $ilDB = $DIC->database();
482
483 $ilDB->setLimit(1);
484 $q = "SELECT * FROM sahs_sc13_tree_node WHERE import_id = " .
485 $ilDB->quote($a_import_id, "text") . " " .
486 " ORDER BY create_date DESC";
487 $obj_set = $ilDB->query($q);
488 while ($obj_rec = $ilDB->fetchAssoc($obj_set)) {
489 $slm_id = ilSCORM2004Node::_lookupSLMID($obj_rec["obj_id"]);
490
491 // link only in learning module, that is not trashed
493 return $obj_rec["obj_id"];
494 }
495 }
496
497 return 0;
498 }
499
507 public static function _exists($a_id)
508 {
509 global $DIC;
510
511 $ilDB = $DIC->database();
512
513 include_once("./Services/Link/classes/class.ilInternalLink.php");
514 if (is_int(strpos($a_id, "_"))) {
516 }
517
518 $q = "SELECT * FROM sahs_sc13_tree_node WHERE obj_id = " .
519 $ilDB->quote($a_id, "integer");
520 $obj_set = $ilDB->query($q);
521 if ($obj_rec = $ilDB->fetchAssoc($obj_set)) {
522 return true;
523 } else {
524 return false;
525 }
526 }
527
528
534 public static function _deleteAllSLMNodes($a_slm_object)
535 {
536 global $DIC;
537
538 $ilDB = $DIC->database();
539
540 $query = "SELECT * FROM sahs_sc13_tree_node " .
541 "WHERE slm_id = " . $ilDB->quote($a_slm_object->getId(), "integer") . " ";
542 $obj_set = $ilDB->query($query);
543
544 require_once("./Modules/Scorm2004/classes/class.ilSCORM2004NodeFactory.php");
545 while ($obj_rec = $ilDB->fetchAssoc($obj_set)) {
546 $node_obj = ilSCORM2004NodeFactory::getInstance($a_slm_object, $obj_rec["obj_id"], false);
547
548 if (is_object($node_obj)) {
549 $node_obj->delete();
550 }
551 }
552
553 return true;
554 }
555
559 public static function _lookupSLMID($a_id)
560 {
561 global $DIC;
562
563 $ilDB = $DIC->database();
564
565 $query = "SELECT * FROM sahs_sc13_tree_node WHERE obj_id = " .
566 $ilDB->quote($a_id, "integer") . "";
567 $obj_set = $ilDB->query($query);
568 $obj_rec = $ilDB->fetchAssoc($obj_set);
569
570 return $obj_rec["slm_id"];
571 }
572
576 public static function putInTree($a_obj, $a_parent_id = "", $a_target_node_id = "")
577 {
578 $tree = new ilTree($a_obj->getSLMId());
579 $tree->setTreeTablePK("slm_id");
580 $tree->setTableNames('sahs_sc13_tree', 'sahs_sc13_tree_node');
581
582 // determine parent
583 $parent_id = ($a_parent_id != "")
584 ? $a_parent_id
585 : $tree->getRootId();
586
587 // determine target
588 if ($a_target_node_id != "") {
589 $target = $a_target_node_id;
590 } else {
591 // determine last child that serves as predecessor
592 $childs = $tree->getChilds($parent_id);
593
594 if (count($childs) == 0) {
596 } else {
597 $target = $childs[count($childs) - 1]["obj_id"];
598 }
599 }
600
601 if ($tree->isInTree($parent_id) && !$tree->isInTree($a_obj->getId())) {
602 $tree->insertNode($a_obj->getId(), $parent_id, $target);
603 }
604 }
605
613 public static function getTree($a_slm_obj_id)
614 {
615 $tree = new ilTree($a_slm_obj_id);
616 $tree->setTableNames('sahs_sc13_tree', 'sahs_sc13_tree_node');
617 $tree->setTreeTablePK("slm_id");
618 $tree->readRootId();
619
620 return $tree;
621 }
622
626 public static function clipboardCopy($a_slm_obj_id, $a_ids)
627 {
628 global $DIC;
629
630 $ilUser = $DIC->user();
631
632 $tree = ilSCORM2004Node::getTree($a_slm_obj_id);
633
634 $ilUser->clipboardDeleteObjectsOfType("page");
635 $ilUser->clipboardDeleteObjectsOfType("chap");
636 $ilUser->clipboardDeleteObjectsOfType("sco");
637 $ilUser->clipboardDeleteObjectsOfType("ass");
638
639 // put them into the clipboard
640 $time = date("Y-m-d H:i:s", time());
641 foreach ($a_ids as $id) {
642 $curnode = "";
643 if ($tree->isInTree($id)) {
644 $curnode = $tree->getNodeData($id);
645 $subnodes = $tree->getSubTree($curnode);
646 foreach ($subnodes as $subnode) {
647 if ($subnode["child"] != $id) {
648 $ilUser->addObjectToClipboard(
649 $subnode["child"],
650 $subnode["type"],
651 $subnode["title"],
652 $subnode["parent"],
653 $time,
654 $subnode["lft"]
655 );
656 }
657 }
658 }
659 $order = ($curnode["lft"] > 0)
660 ? $curnode["lft"]
661 : (int) ($order + 1);
662 $ilUser->addObjectToClipboard(
663 $id,
666 0,
667 $time,
668 $order
669 );
670 }
671 }
672
676 public static function clipboardCut($a_slm_obj_id, $a_ids)
677 {
678 $tree = ilSCORM2004Node::getTree($a_slm_obj_id);
679
680 if (!is_array($a_ids)) {
681 return false;
682 } else {
683 // get all "top" ids, i.e. remove ids, that have a selected parent
684 foreach ($a_ids as $id) {
685 $path = $tree->getPathId($id);
686 $take = true;
687 foreach ($path as $path_id) {
688 if ($path_id != $id && in_array($path_id, $a_ids)) {
689 $take = false;
690 }
691 }
692 if ($take) {
693 $cut_ids[] = $id;
694 }
695 }
696 }
697
698 ilSCORM2004Node::clipboardCopy($a_slm_obj_id, $cut_ids);
699
700 // remove the objects from the tree
701 // note: we are getting chapters, scos and pages which are *not* in the tree
702 // we do not delete any pages/chapters here
703 foreach ($cut_ids as $id) {
704 $curnode = $tree->getNodeData($id);
705 if ($tree->isInTree($id)) {
706 $tree->deleteTree($curnode);
707 }
708 }
709 }
710
714 public static function uniqueTypesCheck($a_items)
715 {
716 $types = array();
717 if (is_array($a_items)) {
718 foreach ($a_items as $item) {
720 $types[$type] = $type;
721 }
722 }
723
724 if (count($types) > 1) {
725 return false;
726 }
727 return true;
728 }
729
733 public static function insertPageClip($a_slm_obj)
734 {
735 global $DIC;
736
737 $ilUser = $DIC->user();
738
739 // @todo: move this to a service since it can be used here, too
740 include_once("./Modules/LearningModule/classes/class.ilEditClipboard.php");
741
742 include_once("./Modules/Scorm2004/classes/class.ilSCORM2004OrganizationHFormGUI.php");
745
746 $tree = ilSCORM2004Node::getTree($a_slm_obj->getId());
747
748 if (!$first_child) { // insert after node id
749 $parent_id = $tree->getParentId($node_id);
750 $target = $node_id;
751 } else { // insert as first child
752 $parent_id = $node_id;
754 }
755
756 // cut and paste
757 $source_parent_type = "";
758 if ($ilUser->getClipboardObjects("page")) {
759 $pages = $ilUser->getClipboardObjects("page");
760 } elseif ($ilUser->getClipboardObjects("pg")) {
761 $source_parent_type = "lm";
762 $pages = $ilUser->getClipboardObjects("pg");
763 }
764 $copied_nodes = array();
765
766 foreach ($pages as $pg) {
768 $a_slm_obj,
769 $pg["id"],
770 $parent_id,
771 $target,
772 $pg["insert_time"],
773 $copied_nodes,
774 (ilEditClipboard::getAction() == "copy"),
775 true,
776 $source_parent_type
777 );
778 $target = $cid;
779 }
780 //ilLMObject::updateInternalLinks($copied_nodes);
781
782 if (ilEditClipboard::getAction() == "cut") {
783 $ilUser->clipboardDeleteObjectsOfType("page");
784 $ilUser->clipboardDeleteObjectsOfType("chap");
785 $ilUser->clipboardDeleteObjectsOfType("sco");
786 $ilUser->clipboardDeleteObjectsOfType("ass");
787 $ilUser->clipboardDeleteObjectsOfType("pg");
789 }
790 }
791
795 public static function insertAssetClip($a_slm_obj, $a_type = "ass")
796 {
797 global $DIC;
798
799 $ilCtrl = $DIC->ctrl();
800 $ilUser = $DIC->user();
801
802 // @todo: move this to a service since it can be used here, too
803 include_once("./Modules/LearningModule/classes/class.ilEditClipboard.php");
804
805 include_once("./Modules/Scorm2004/classes/class.ilSCORM2004OrganizationHFormGUI.php");
808
809 $tree = ilSCORM2004Node::getTree($a_slm_obj->getId());
810
811 if (!$first_child) { // insert after node id
812 $parent_id = $tree->getParentId($node_id);
813 $target = $node_id;
814 } else { // insert as first child
815 $parent_id = $node_id;
817 }
818
819 // cut and paste
820 $scos = $ilUser->getClipboardObjects($a_type);
821 $copied_nodes = array();
822 foreach ($scos as $sco) {
824 $a_slm_obj,
825 $sco["id"],
826 $parent_id,
827 $target,
828 $sco["insert_time"],
829 $copied_nodes,
830 (ilEditClipboard::getAction() == "copy")
831 );
832 $target = $cid;
833 }
834 //ilLMObject::updateInternalLinks($copied_nodes);
835
836 if (ilEditClipboard::getAction() == "cut") {
837 $ilUser->clipboardDeleteObjectsOfType("page");
838 $ilUser->clipboardDeleteObjectsOfType("chap");
839 $ilUser->clipboardDeleteObjectsOfType("sco");
840 $ilUser->clipboardDeleteObjectsOfType("ass");
842 }
843 }
844
848 public static function insertScoClip($a_slm_obj)
849 {
850 self::insertAssetClip($a_slm_obj, "sco");
851 }
852
853
857 public static function insertChapterClip($a_slm_obj, $a_as_sub = false)
858 {
859 global $DIC;
860
861 $ilUser = $DIC->user();
862 $ilCtrl = $DIC->ctrl();
863 $ilLog = $DIC["ilLog"];
864
865 // @todo: move this to a service since it can be used here, too
866 include_once("./Modules/LearningModule/classes/class.ilEditClipboard.php");
867
868 include_once("./Modules/Scorm2004/classes/class.ilSCORM2004OrganizationHFormGUI.php");
871
872 $tree = ilSCORM2004Node::getTree($a_slm_obj->getId());
873
874 if ($a_as_sub) { // as subchapter
875 if (!$first_child) { // insert under parent
876 $parent_id = $node_id;
877 $target = "";
878 } else { // we shouldnt end up here
879 return;
880 }
881 } else { // as chapter
882 if (!$first_child) { // insert after node id
883 $parent_id = $tree->getParentId($node_id);
884 $target = $node_id;
885 } else { // insert as first child
886 $parent_id = $node_id;
888
889 // do not move a chapter in front of a sco (maybe never needed)
890 $childs = $tree->getChildsByType($parent_id, "sco");
891 if (count($childs) != 0) {
892 $target = $childs[count($childs) - 1]["obj_id"];
893 }
894 }
895 }
896
897 // copy and paste
898 $chapters = $ilUser->getClipboardObjects("chap", true);
899 $copied_nodes = array();
900 foreach ($chapters as $chap) {
902 $a_slm_obj,
903 $chap["id"],
904 $parent_id,
905 $target,
906 $chap["insert_time"],
907 $copied_nodes,
908 (ilEditClipboard::getAction() == "copy")
909 );
910 $target = $cid;
911 }
912 //ilLMObject::updateInternalLinks($copied_nodes);
913
914 if (ilEditClipboard::getAction() == "cut") {
915 $ilUser->clipboardDeleteObjectsOfType("page");
916 $ilUser->clipboardDeleteObjectsOfType("chap");
917 $ilUser->clipboardDeleteObjectsOfType("sco");
918 $ilUser->clipboardDeleteObjectsOfType("ass");
920 }
921 }
922
935 public static function pasteTree(
936 $a_target_slm,
937 $a_item_id,
938 $a_parent_id,
939 $a_target,
940 $a_insert_time,
941 &$a_copied_nodes,
942 $a_as_copy = false,
943 $a_from_clipboard = true,
944 $a_source_parent_type = ""
945 ) {
946 global $DIC;
947
948 $ilUser = $DIC->user();
949 $ilLog = $DIC["ilLog"];
950
951 $item_type = "";
952
953 if (in_array($a_source_parent_type, array("", "sahs"))) {
954 // source lm id, item type and lm object
955 $item_slm_id = ilSCORM2004Node::_lookupSLMID($a_item_id);
956 $item_type = ilSCORM2004Node::_lookupType($a_item_id);
957
958 include_once("./Modules/Scorm2004/classes/class.ilObjSCORM2004LearningModule.php");
959 $slm_obj = new ilObjSCORM2004LearningModule($item_slm_id, false);
960
961 $ilLog->write("Getting from clipboard type " . $item_type . ", " .
962 "Item ID: " . $a_item_id . ", of original SLM: " . $item_slm_id);
963 } elseif (in_array($a_source_parent_type, array("lm"))) {
964 include_once("./Modules/LearningModule/classes/class.ilLMObject.php");
965 $item_lm_id = ilLMObject::_lookupContObjId($a_item_id);
966 $item_type = ilLMObject::_lookupType($a_item_id, $item_lm_id);
967
968 include_once("./Modules/LearningModule/classes/class.ilObjLearningModule.php");
969 $lm_obj = new ilObjLearningModule($item_lm_id, false);
970
971 $ilLog->write("Getting from clipboard type " . $item_type . ", " .
972 "Item ID: " . $a_item_id . ", of original SLM: " . $item_lm_id);
973 }
974
975
976
977 if ($item_type == "chap") {
978 include_once("./Modules/Scorm2004/classes/class.ilSCORM2004Chapter.php");
979 $item = new ilSCORM2004Chapter($slm_obj, $a_item_id);
980 } elseif ($item_type == "page") {
981 include_once("./Modules/Scorm2004/classes/class.ilSCORM2004PageNode.php");
982 $item = new ilSCORM2004PageNode($slm_obj, $a_item_id);
983 } elseif ($item_type == "sco") {
984 include_once("./Modules/Scorm2004/classes/class.ilSCORM2004Sco.php");
985 $item = new ilSCORM2004Sco($slm_obj, $a_item_id);
986 } elseif ($item_type == "ass") {
987 include_once("./Modules/Scorm2004/classes/class.ilSCORM2004Asset.php");
988 $item = new ilSCORM2004Asset($slm_obj, $a_item_id);
989 } elseif ($item_type == "pg") {
990 include_once("./Modules/LearningModule/classes/class.ilLMPageObject.php");
991 $item = new ilLMPageObject($lm_obj, $a_item_id);
992 }
993
994
995 if ($item_slm_id != $a_target_slm->getId() && !$a_as_copy) {
996 // @todo: check whether st is NOT in tree
997
998 // "move" metadata to new lm
999 include_once("Services/MetaData/classes/class.ilMD.php");
1000 $md = new ilMD($item_slm_id, $item->getId(), $item->getType());
1001 $new_md = $md->cloneMD($a_target_slm->getId(), $item->getId(), $item->getType());
1002
1003 // update lm object
1004 $item->setSLMId($a_target_slm->getId());
1005 $item->setSLMObject($a_target_slm);
1006 $item->update();
1007
1008 // delete old meta data set
1009 $md->deleteAll();
1010
1011 if ($item_type == "page") {
1012 $page = $item->getPageObject();
1013 $page->buildDom($a_from_clipboard);
1014 $page->setParentId($a_target_slm->getId());
1015 $page->update();
1016 }
1017 }
1018
1019 if ($a_as_copy) {
1020 if ($a_source_parent_type == "lm") {
1021 if ($item_type = "pg") {
1022 include_once("./Modules/Scorm2004/classes/class.ilSCORM2004PageNode.php");
1023 $target_item = ilSCORM2004PageNode::copyPageFromLM($a_target_slm, $item);
1024 }
1025 } else {
1026 $target_item = $item->copy($a_target_slm);
1027 }
1028 $a_copied_nodes[$item->getId()] = $target_item->getId();
1029 } else {
1030 $target_item = $item;
1031 }
1032
1033 $ilLog->write("Putting into tree type " . $target_item->getType() .
1034 "Item ID: " . $target_item->getId() . ", Parent: " . $a_parent_id . ", " .
1035 "Target: " . $a_target . ", Item LM:" . $target_item->getContentObject()->getId());
1036
1037 ilSCORM2004Node::putInTree($target_item, $a_parent_id, $a_target);
1038
1039 if ($a_from_clipboard) {
1040 $childs = $ilUser->getClipboardChilds($item->getId(), $a_insert_time);
1041 } else {
1042 // get childs of source tree
1043 $source_tree = $slm_obj->getTree();
1044 $childs = $source_tree->getChilds($a_item_id);
1045 }
1046
1047 foreach ($childs as $child) {
1048 $child_id = ($a_from_clipboard)
1049 ? $child["id"]
1050 : $child["child"];
1052 $a_target_slm,
1053 $child_id,
1054 $target_item->getId(),
1056 $a_insert_time,
1057 $a_copied_nodes,
1058 $a_as_copy,
1059 $a_from_clipboard,
1060 $a_source_parent_type
1061 );
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 {
1086 include_once("./Modules/Scorm2004/classes/seq_editor/class.ilSCORM2004Utilities.php");
1087 $seq_util = new ilSCORM2004Utilities($this->getId());
1088 return $seq_util -> parentHasSeqTemplate($this->slm_object);
1089 }
1090
1091
1092 public function exportAsScorm12()
1093 {
1094 //to implement
1095 return;
1096 }
1097
1098 public function exportAsScorm13()
1099 {
1100 //to implement
1101 return;
1102 }
1103}
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
user()
Definition: user.php:4
An exception for terminatinating execution or to throw for unit testing.
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.
static _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.
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.
setDataRecord($a_record)
this method should only be called by class ilSCORM2004NodeFactory
getSLMObject()
Get scorm learning module object.
static _exists($a_id)
Checks wether a node exists.
static insertChapterClip($a_slm_obj, $a_as_sub=false)
Insert Chapter from clipboard.
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.
static _getIdForImportId($a_import_id)
Get Node ID for import ID (static)
static _deleteAllSLMNodes($a_slm_object)
Delete all nodes of Scorm Learning Module.
setSLMObject($a_slm_obj)
Set Scorm Learning Module Object.
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.
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.
static _lookupSLMID($a_id)
Lookup Scorm Learning Module ID for node id.
static insertScoClip($a_slm_obj)
Insert scos from clipboard.
getSLMId()
Get ID of parent Scorm Learning Module Object.
__construct($a_slm_object, $a_id=0)
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
updateMetaData()
update meta data entry
static _writeTitle($a_obj_id, $a_title)
Write Title.
static clipboardCut($a_slm_obj_id, $a_ids)
Cut and copy a set of chapters/pages into the clipboard.
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 $ilCtrl
Definition: ilias.php:18
$time
Definition: cron.php:21
$query
global $DIC
Definition: saml.php:7
global $ilDB
$ilUser
Definition: imgupload.php:18
$a_type
Definition: workflow.php:92