ILIAS  release_8 Revision v8.24
class.ilObjSAHSLearningModule.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
21//require_once "Services/MetaData/classes/class.ilMDLanguageItem.php";
33{
34 private string $api_func_prefix = 'LMS';
35 private string $credit_mode = 'credit';
36 private string $lesson_mode ='normal';
37 private int $style_id = 0;
38 private string $auto_review = 'n';
39 private int $max_attempt = 0;
40 private int $module_version = 1;
41 private int $assigned_glossary = 0;
42 private bool $session = false;
43 private bool $no_menu = false;
44 private bool $hide_navig = false;
45 private bool $ie_force_render = false;
46 private bool $fourth_edition = false;
47 private bool $interactions = true;
48 private bool $objectives = true;
49 private bool $comments = true;
50 private bool $time_from_lms = false;
51 private bool $check_values = true;
52 private bool $debug = false;
53 private bool $auto_continue = false;
54 private bool $auto_last_visited = true;
55 private bool $auto_suspend = false;
56 private int $open_mode = 0;
57 private int $width = 950;
58 private int $height = 650;
59 private ?int $mastery_score = null;
60 private int $id_setting = 0;
61 private int $name_setting = 0;
62 private string $sub_type = 'scorm';
63 protected bool $sequencing = false;
64
65 protected string $localization = "";
66
67 protected string $mastery_score_values = "";
68
69 protected int $tries = 0;
70
71 protected string $api_adapter = 'API';
72
78 public function __construct(int $a_id = 0, bool $a_call_by_reference = true)
79 {
80 $this->type = "sahs";
81 parent::__construct($a_id, $a_call_by_reference);
82 }
83
87 public function create(bool $upload = false): int
88 {
89 global $DIC;
90 $ilDB = $DIC->database();
91
92 $id = parent::create();
93 if (!$upload) {
94 $this->createMetaData();
95 }
96
97 $this->createDataDirectory();
98 $ilDB->manipulateF(
99 '
100 INSERT INTO sahs_lm (id, api_adapter, c_type, editable, seq_exp_mode,localization)
101 VALUES (%s,%s,%s,%s,%s,%s)',
102 array('integer', 'text', 'text', 'integer','integer','text'),
103 array($this->getId(),'API', $this->getSubType(),(int) $this->getEditable(),
104 0, $this->getLocalization()
105 )
106 );
107 return $id;
108 }
109
116 public function read(): void
117 {
118 global $DIC;
119 $ilDB = $DIC->database();
120
121 parent::read();
122
123 $lm_set = $ilDB->queryF(
124 'SELECT * FROM sahs_lm WHERE id = %s',
125 array('integer'),
126 array($this->getId())
127 );
128
129 while ($lm_rec = $ilDB->fetchAssoc($lm_set)) {
130 $this->setAutoReviewChar((string) $lm_rec["auto_review"]);
131 $this->setAPIAdapterName((string) $lm_rec["api_adapter"]);
132 $this->setDefaultLessonMode((string) $lm_rec["default_lesson_mode"]);
133 $this->setAPIFunctionsPrefix((string) $lm_rec["api_func_prefix"]);
134 $this->setCreditMode((string) $lm_rec["credit"]);
135 $this->setSubType((string) $lm_rec["c_type"]);
136 // $this->setEditable(false);
137 $this->setStyleSheetId((int) $lm_rec["stylesheet"]);
138 $this->setMaxAttempt((int) $lm_rec["max_attempt"]);
139 $this->setModuleVersion((int) $lm_rec["module_version"]);
140 $this->setAssignedGlossary((int) $lm_rec["glossary"]);
141 $this->setTries((int) $lm_rec["question_tries"]);
142 $this->setLocalization((string) $lm_rec["localization"]);
143 $this->setSession(ilUtil::yn2tf($lm_rec["unlimited_session"]));
144 $this->setNoMenu(ilUtil::yn2tf($lm_rec["no_menu"]));
145 $this->setHideNavig(ilUtil::yn2tf($lm_rec["hide_navig"]));
146 $this->setFourth_edition(ilUtil::yn2tf($lm_rec["fourth_edition"]));
147 $this->setSequencing(ilUtil::yn2tf($lm_rec["sequencing"]));
148 $this->setInteractions(ilUtil::yn2tf($lm_rec["interactions"]));
149 $this->setObjectives(ilUtil::yn2tf($lm_rec["objectives"]));
150 $this->setComments(ilUtil::yn2tf($lm_rec["comments"]));
151 $this->setTime_from_lms(ilUtil::yn2tf($lm_rec["time_from_lms"]));
152 $this->setDebug(ilUtil::yn2tf($lm_rec["debug"]));
153 // $this->setDebugPw($lm_rec["debugpw"]);
154 // $this->setSequencingExpertMode(bool $lm_rec["seq_exp_mode"]);
155 $this->setOpenMode((int) $lm_rec["open_mode"]);
156 $this->setWidth((int) $lm_rec["width"]);
157 $this->setHeight((int) $lm_rec["height"]);
158 $this->setAutoContinue(ilUtil::yn2tf($lm_rec["auto_continue"]));
159 $this->setAuto_last_visited(ilUtil::yn2tf($lm_rec["auto_last_visited"]));
160 $this->setCheck_values(ilUtil::yn2tf($lm_rec["check_values"]));
161 // $this->setOfflineMode(ilUtil::yn2tf($lm_rec["offline_mode"]));
162 $this->setAutoSuspend(ilUtil::yn2tf($lm_rec["auto_suspend"]));
163 $this->setIe_force_render(ilUtil::yn2tf($lm_rec["ie_force_render"]));
164 if ($lm_rec["mastery_score"] != null) {
165 $this->setMasteryScore((int) $lm_rec["mastery_score"]);
166 }
167 $this->setIdSetting((int) $lm_rec["id_setting"]);
168 $this->setNameSetting((int) $lm_rec["name_setting"]);
169 if (ilObject::_lookupType($this->getStyleSheetId()) !== "sty") {
170 $this->setStyleSheetId(0);
171 }
172 }
173 }
174
178 public static function getAffectiveLocalization(int $a_id): string
179 {
180 global $DIC;
181 $ilDB = $DIC->database();
182 $lng = $DIC->language();
183
184 $lm_set = $ilDB->queryF(
185 'SELECT localization FROM sahs_lm WHERE id = %s',
186 array('integer'),
187 array($a_id)
188 );
189 $lm_rec = $ilDB->fetchAssoc($lm_set);
190 $inst_lang = $lng->getInstalledLanguages();
191 if ($lm_rec["localization"] != "" && in_array($lm_rec["localization"], $inst_lang)) {
192 return $lm_rec["localization"];
193 }
194 return $lng->getLangKey();
195 }
196
200 public static function _lookupSubType(int $a_obj_id): string
201 {
202 global $DIC;
203 $ilDB = $DIC->database();
204
205 $obj_set = $ilDB->queryF(
206 'SELECT c_type FROM sahs_lm WHERE id = %s',
207 array('integer'),
208 array($a_obj_id)
209 );
210 $obj_rec = $ilDB->fetchAssoc($obj_set);
211
212 return $obj_rec["c_type"];
213 }
214
215 // /**
216 // * Set Editable.
217 // *
218 // * @param boolean $a_editable Editable
219 // */
220 // public function setEditable(bool $a_editable) : void
221 // {
222 // $this->editable = $a_editable;
223 // }
224
225 public function getEditable(): bool
226 {
227 return false;
228 }
229
233 public function setTries(int $a_tries): void
234 {
235 $this->tries = $a_tries;
236 }
237
238 public function getTries(): int
239 {
240 return $this->tries;
241 }
242
243 public function setLocalization(string $a_val): void
244 {
245 $this->localization = $a_val;
246 }
247
248 public function getLocalization(): string
249 {
250 return $this->localization;
251 }
252
256 public static function _getTries(int $a_id): int
257 {
258 global $DIC;
259 $ilDB = $DIC->database();
260
261 $lm_set = $ilDB->queryF(
262 'SELECT question_tries FROM sahs_lm WHERE id = %s',
263 array('integer'),
264 array($a_id)
265 );
266 $lm_rec = $ilDB->fetchAssoc($lm_set);
267
268 return (int) $lm_rec['question_tries'];
269 }
270
276 public function getDiskUsage(): int
277 {
279 }
280
281
286 public function createDataDirectory(): void
287 {
288 $lm_data_dir = ilFileUtils::getWebspaceDir() . "/lm_data";
289 ilFileUtils::makeDir($lm_data_dir);
291 }
292
296 public function getDataDirectory(?string $mode = "filesystem"): string
297 {
298 $lm_data_dir = ilFileUtils::getWebspaceDir($mode) . "/lm_data";
299 return $lm_data_dir . "/lm_" . $this->getId();
300 }
301
305 public function getAPIAdapterName(): string
306 {
307 return $this->api_adapter;
308 }
309
313 public function setAPIAdapterName(string $a_api): void
314 {
315 $this->api_adapter = $a_api;
316 }
317
322 public function getAPIFunctionsPrefix(): string
323 {
325 }
326
330 public function setAPIFunctionsPrefix(string $a_prefix): void
331 {
332 $this->api_func_prefix = $a_prefix;
333 }
334
338 public function getCreditMode(): string
339 {
340 return $this->credit_mode;
341 }
342
346 public function setCreditMode(string $a_credit_mode): void
347 {
348 $this->credit_mode = $a_credit_mode;
349 }
350
354 public function setDefaultLessonMode(string $a_lesson_mode): void
355 {
356 $this->lesson_mode = $a_lesson_mode;
357 }
358
362 public function getDefaultLessonMode(): string
363 {
364 global $DIC;
365 if ($DIC->user()->getId() == 13) {
366 return "browse";
367 }
368 return $this->lesson_mode;
369 }
370
374 public function getStyleSheetId(): int
375 {
376 return $this->style_id;
377 }
378
382 public function setStyleSheetId(int $a_style_id): void
383 {
384 $this->style_id = $a_style_id;
385 }
386
390 public function setAutoReview(bool $a_auto_review): void
391 {
392 $this->auto_review = ilUtil::tf2yn($a_auto_review);
393 }
394
398 public function getAutoReview(): bool
399 {
400 return ilUtil::yn2tf($this->auto_review);
401 }
402
406 public function setAutoReviewChar(?string $a_auto_review): void
407 {
408 if ($a_auto_review == null) {
409 $this->auto_review = 'n';
410 } else {
411 $this->auto_review = $a_auto_review;
412 }
413 }
414
418 public function getAutoReviewChar(): string
419 {
420 return $this->auto_review;
421 }
422
423 public function getMaxAttempt(): int
424 {
425 return $this->max_attempt;
426 }
427
428 public function setMaxAttempt(int $a_max_attempt): void
429 {
430 $this->max_attempt = $a_max_attempt;
431 }
432
433 public function getModuleVersion(): int
434 {
436 }
437
438 public function getAssignedGlossary(): int
439 {
441 }
442
443 public function setAssignedGlossary(int $a_assigned_glossary): void
444 {
445 $this->assigned_glossary = $a_assigned_glossary;
446 }
447
448 public function setModuleVersion(int $a_module_version): void
449 {
450 $this->module_version = $a_module_version;
451 }
452
453 public function getSession(): bool
454 {
455 return $this->session;
456 }
457
458 public function setSession(bool $a_session): void
459 {
460 $this->session = $a_session;
461 }
462
466 public function getNoMenu(): bool
467 {
468 return $this->no_menu;
469 }
470
474 public function setNoMenu(bool $a_no_menu): void
475 {
476 $this->no_menu = $a_no_menu;
477 }
478
482 public function getHideNavig(): bool
483 {
484 return $this->hide_navig;
485 }
486
490 public function setHideNavig(bool $a_hide_navig): void
491 {
492 $this->hide_navig = $a_hide_navig;
493 }
494
498 public function getCacheDeactivated(): bool
499 {
500 global $DIC;
501 $ilSetting = $DIC->settings();
502 $lm_set = new ilSetting("lm");
503 return $lm_set->get("scormdebug_disable_cache") == "1";
504 }
505
509 public function getSessionDeactivated(): bool
510 {
511 global $DIC;
512 $ilSetting = $DIC->settings();
513 $lm_set = new ilSetting("lm");
514 return $lm_set->get("scorm_without_session") == "1";
515 }
516
520 public function getDebugActivated(): bool
521 {
522 global $DIC;
523 $ilSetting = $DIC->settings();
524 $lm_set = new ilSetting("lm");
525 return $lm_set->get("scormdebug_global_activate") === "1";
526 }
527
531 public function getIe_force_render(): bool
532 {
534 }
535
536 public function setIe_force_render(bool $a_ie_force_render): void
537 {
538 $this->ie_force_render = $a_ie_force_render;
539 }
540
544 public function getFourth_Edition(): bool
545 {
547 }
548
549 public function setFourth_edition(bool $a_fourth_edition): void
550 {
551 $this->fourth_edition = $a_fourth_edition;
552 }
553
554 public function getSequencing(): bool
555 {
556 return $this->sequencing;
557 }
558
559 public function setSequencing(bool $a_sequencing): void
560 {
561 $this->sequencing = $a_sequencing;
562 }
563
564 public function getInteractions(): bool
565 {
566 return $this->interactions;
567 }
568
569 public function setInteractions(bool $a_interactions): void
570 {
571 $this->interactions = $a_interactions;
572 }
573
574 public function getObjectives(): bool
575 {
576 return $this->objectives;
577 }
578
579 public function setObjectives(bool $a_objectives): void
580 {
581 $this->objectives = $a_objectives;
582 }
583
584 public function getComments(): bool
585 {
586 return $this->comments;
587 }
588
589 public function setComments(bool $a_comments): void
590 {
591 $this->comments = $a_comments;
592 }
593
594 public function getTime_from_lms(): bool
595 {
597 }
598
599 public function setTime_from_lms(bool $a_time_from_lms): void
600 {
601 $this->time_from_lms = $a_time_from_lms;
602 }
603
604 public function getCheck_values(): bool
605 {
606 return $this->check_values;
607 }
608
609 public function setCheck_values(bool $a_check_values): void
610 {
611 $this->check_values = $a_check_values;
612 }
613
614 // /**
615 // * offlineMode
616 // */
617 // public function getOfflineMode()
618 // {
619 // return $this->offline_mode;
620 // }
621 //
622 // public function setOfflineMode($a_offline_mode)
623 // {
624 // $this->offline_mode = $a_offline_mode;
625 // }
626
627 public function getDebug(): bool
628 {
629 return $this->debug;
630 }
631
632 public function setDebug(bool $a_debug): void
633 {
634 $this->debug = $a_debug;
635 }
636
637 // /**
638 // * debug pw
639 // */
640 // public function getDebugPw()
641 // {
642 // return $this->debug_pw;
643 // }
644 //
645 // /**
646 // * debug pw
647 // */
648 // public function setDebugPw($a_debug_pw)
649 // {
650 // $this->debug_pw = $a_debug_pw;
651 // }
652
653 public function setAutoContinue(bool $a_auto_continue): void
654 {
655 $this->auto_continue = $a_auto_continue;
656 }
657
658 public function getAutoContinue(): bool
659 {
661 }
662
663 public function getAuto_last_visited(): bool
664 {
666 }
667
668 public function setAuto_last_visited(bool $a_auto_last_visited): void
669 {
670 $this->auto_last_visited = $a_auto_last_visited;
671 }
672
673
674 // /**
675 // * Set sequencing expert mode
676 // *
677 // * @param boolean $a_val sequencing expert mode
678 // */
679 // public function setSequencingExpertMode(bool $a_val)
680 // {
681 // $this->seq_exp_mode = $a_val;
682 // }
683 //
684 // /**
685 // * Get sequencing expert mode
686 // *
687 // * @return boolean sequencing expert mode
688 // */
689 // public function getSequencingExpertMode()
690 // {
691 // return $this->seq_exp_mode;
692 // }
693
694 public function setAutoSuspend(bool $a_auto_suspend): void
695 {
696 $this->auto_suspend = $a_auto_suspend;
697 }
698
699 public function getAutoSuspend(): bool
700 {
701 return $this->auto_suspend;
702 }
703
714 public function getOpenMode(): int
715 {
716 return $this->open_mode;
717 }
718
719 public function setOpenMode(int $a_open_mode): void
720 {
721 $this->open_mode = $a_open_mode;
722 }
723
724 public function getWidth(): int
725 {
726 return $this->width;
727 }
728
729 public function setWidth(int $a_width): void
730 {
731 $this->width = $a_width;
732 }
733
734 public function getHeight(): int
735 {
736 return $this->height;
737 }
738
739 public function setHeight(int $a_height): void
740 {
741 $this->height = $a_height;
742 }
743
744 public function getMasteryScore(): ?int
745 {
747 }
748
749 public function setMasteryScore(?int $a_mastery_score): void
750 {
751 $this->mastery_score = $a_mastery_score;
752 }
753
757 public function checkMasteryScoreValues(): void
758 {
759 global $DIC;
760 $ilDB = $DIC->database();
761 $s_result = "";
762 $a_result = array();
763 $type = self::_lookupSubType($this->getID());
764
765 if ($type === "scorm2004") {
766 $set = $ilDB->query("SELECT minnormalmeasure FROM cp_objective, cp_node" .
767 " WHERE satisfiedbymeasure=1 AND minnormalmeasure is not null AND cp_objective.cp_node_id=cp_node.cp_node_id AND" .
768 " slm_id = " . $ilDB->quote($this->getID(), "integer"));
769 while ($rec = $ilDB->fetchAssoc($set)) {
770 $tmpval = $rec["minnormalmeasure"] * 100;
771 if (!in_array($tmpval, $a_result)) {
772 $a_result[] = $tmpval;
773 }
774 }
775 } else {
776 $set = $ilDB->query("SELECT masteryscore FROM sc_item,scorm_object" .
777 " WHERE sc_item.masteryscore is not null AND sc_item.obj_id=scorm_object.obj_id AND" .
778 " slm_id = " . $ilDB->quote($this->getID(), "integer"));
779 while ($rec = $ilDB->fetchAssoc($set)) {
780 if (!in_array($rec["masteryscore"], $a_result)) {
781 $a_result[] = $rec["masteryscore"];
782 }
783 }
784 }
785 $s_result = implode(", ", $a_result);
786 $this->mastery_score_values = $s_result;
787 }
788
789 public function getMasteryScoreValues(): string
790 {
792 }
793
794 public function getIdSetting(): int
795 {
796 return $this->id_setting;
797 }
798
799 public function setIdSetting(int $a_id_setting): void
800 {
801 $this->id_setting = $a_id_setting;
802 }
803
804 public function getNameSetting(): int
805 {
806 return $this->name_setting;
807 }
808
809 public function setNameSetting(int $a_name_setting): void
810 {
811 $this->name_setting = $a_name_setting;
812 }
813
814 public function update(): bool
815 {
816 global $DIC;
817 $ilDB = $DIC->database();
818
819 $this->updateMetaData();
820 parent::update();
821
822 $statement = $ilDB->manipulateF(
823 '
824 UPDATE sahs_lm
825 SET api_adapter = %s,
826 api_func_prefix = %s,
827 auto_review = %s,
828 default_lesson_mode = %s,
829 c_type = %s,
830 stylesheet = %s,
831 editable = %s,
832 max_attempt = %s,
833 module_version = %s,
834 credit = %s,
835 glossary = %s,
836 question_tries = %s,
837 unlimited_session = %s,
838 no_menu = %s,
839 hide_navig = %s,
840 fourth_edition =%s,
841 sequencing = %s,
842 interactions = %s,
843 objectives = %s,
844 comments = %s,
845 time_from_lms = %s,
846 debug = %s,
847 localization = %s,
848 seq_exp_mode = %s,
849 open_mode = %s,
850 width = %s,
851 height = %s,
852 auto_continue = %s,
853 auto_last_visited = %s,
854 check_values = %s,
855 auto_suspend = %s,
856 ie_force_render = %s,
857 mastery_score = %s,
858 id_setting = %s,
859 name_setting = %s
860 WHERE id = %s',
861 array( 'text',
862 'text',
863 'text',
864 'text',
865 'text',
866 'integer',
867 'integer',
868 'integer',
869 'integer',
870 'text',
871 'integer',
872 'integer',
873 'text',
874 'text',
875 'text',
876 'text',
877 'text',
878 'text',
879 'text',
880 'text',
881 'text',
882 'text',
883 'text',
884 'integer',
885 'integer',
886 'integer',
887 'integer',
888 'text',
889 'text',
890 'text',
891 'text',
892 'text',
893 'integer',
894 'integer',
895 'integer',
896 'integer'
897 ),
898 array( $this->getAPIAdapterName(),
899 $this->getAPIFunctionsPrefix(),
900 $this->getAutoReviewChar(),
901 $this->getDefaultLessonMode(),
902 $this->getSubType(),
903 $this->getStyleSheetId(),
904 $this->getEditable(),
905 $this->getMaxAttempt(),
906 $this->getModuleVersion(),
907 $this->getCreditMode(),
908 $this->getAssignedGlossary(),
909 $this->getTries(),
910 ilUtil::tf2yn($this->getSession()),
911 ilUtil::tf2yn($this->getNoMenu()),
912 ilUtil::tf2yn($this->getHideNavig()),
913 ilUtil::tf2yn($this->getFourth_edition()),
917 ilUtil::tf2yn($this->getComments()),
919 ilUtil::tf2yn($this->getDebug()),
920 $this->getLocalization(),
921 0,//$this->getSequencingExpertMode(),
922 $this->getOpenMode(),
923 $this->getWidth(),
924 $this->getHeight(),
930 $this->getMasteryScore(),
931 $this->getIdSetting(),
932 $this->getNameSetting(),
933 $this->getId())
934 );
935
936 return true;
937 }
938
942 public static function getScormModulesForGlossary(int $a_glo_id): array
943 {
944 global $DIC;
945 $ilDB = $DIC->database();
946
947 $set = $ilDB->query("SELECT DISTINCT id FROM sahs_lm WHERE " .
948 " glossary = " . $ilDB->quote($a_glo_id, "integer"));
949 $sms = array();
950 while ($rec = $ilDB->fetchAssoc($set)) {
951 if (ilObject::_hasUntrashedReference((int) $rec["id"])) {
952 $sms[] = $rec["id"];
953 }
954 }
955 return $sms;
956 }
957
961 public static function lookupAssignedGlossary(int $a_slm_id): int
962 {
963 global $DIC;
964 $ilDB = $DIC->database();
965
966 $set = $ilDB->query("SELECT DISTINCT glossary FROM sahs_lm WHERE " .
967 " id = " . $ilDB->quote($a_slm_id, "integer"));
968 $rec = $ilDB->fetchAssoc($set);
969 $glo_id = $rec["glossary"];
970 if (ilObject::_lookupType($glo_id) === "glo") {
971 return $glo_id;
972 }
973 return 0;
974 }
975
976 public function setSubType(string $a_sub_type): void
977 {
978 $this->sub_type = $a_sub_type;
979 }
980
981 public function getSubType(): string
982 {
983 return $this->sub_type;
984 }
985
996 public function delete(): bool
997 {
998 global $DIC;
999 $ilDB = $DIC->database();
1000 $ilLog = ilLoggerFactory::getLogger('sahs');
1001
1002 // always call parent delete function first!!
1003 if (!parent::delete()) {
1004 return false;
1005 }
1006
1007 // delete meta data of scorm content object
1008 $this->deleteMetaData();
1009
1010 // delete data directory
1012
1013 // delete scorm learning module record
1014 $ilDB->manipulateF(
1015 'DELETE FROM sahs_lm WHERE id = %s',
1016 array('integer'),
1017 array($this->getId())
1018 );
1019
1020 $ilLog->debug("SAHS Delete(SAHSLM), Subtype: " . $this->getSubType());
1021
1022 if ($this->getSubType() === "scorm") {
1023 $sc_tree = new ilSCORMTree($this->getId());
1024 $r_id = $sc_tree->readRootId();
1025 if ($r_id > 0) {
1026 $items = $sc_tree->getSubTree($sc_tree->getNodeData($r_id));
1027 foreach ($items as $item) {
1028 $sc_object = ilSCORMObject::_getInstance((int) $item["obj_id"], $this->getId());
1029 if (is_object($sc_object)) {
1030 $sc_object->delete();
1031 }
1032 }
1033 $sc_tree->removeTree($sc_tree->getTreeId());
1034 }
1035 }
1036
1037 if ($this->getSubType() !== "scorm") {
1038 // delete aicc data
1039 $res = $ilDB->queryF(
1040 '
1041 SELECT aicc_object.obj_id FROM aicc_object, aicc_units
1042 WHERE aicc_object.obj_id = aicc_units.obj_id
1043 AND aicc_object.slm_id = %s',
1044 array('integer'),
1045 array($this->getId())
1046 );
1047
1048 while ($row = $ilDB->fetchAssoc($res)) {
1049 $obj_id = $row['obj_id'];
1050 $ilDB->manipulateF(
1051 '
1052 DELETE FROM aicc_units WHERE obj_id = %s',
1053 array('integer'),
1054 array($obj_id)
1055 );
1056 }
1057
1058 $res = $ilDB->queryF(
1059 '
1060 SELECT aicc_object.obj_id FROM aicc_object, aicc_course
1061 WHERE aicc_object.obj_id = aicc_course.obj_id
1062 AND aicc_object.slm_id = %s',
1063 array('integer'),
1064 array($this->getId())
1065 );
1066
1067 while ($row = $ilDB->fetchAssoc($res)) {
1068 $obj_id = $row['obj_id'];
1069 $ilDB->manipulateF(
1070 '
1071 DELETE FROM aicc_course WHERE obj_id = %s',
1072 array('integer'),
1073 array($obj_id)
1074 );
1075 }
1076
1077 $ilDB->manipulateF(
1078 '
1079 DELETE FROM aicc_object WHERE slm_id = %s',
1080 array('integer'),
1081 array($this->getId())
1082 );
1083 }
1084
1085 $q_log = "DELETE FROM scorm_tracking WHERE obj_id = " . $ilDB->quote($this->getId());
1086 $ilLog->write("SAHS Delete(SAHSLM): " . $q_log);
1087
1088 $ilDB->manipulateF(
1089 'DELETE FROM scorm_tracking WHERE obj_id = %s',
1090 array('integer'),
1091 array($this->getId())
1092 );
1093
1094 $q_log = "DELETE FROM sahs_user WHERE obj_id = " . $ilDB->quote($this->getId());
1095 $ilLog->write("SAHS Delete(SAHSLM): " . $q_log);
1096
1097 $ilDB->manipulateF(
1098 'DELETE FROM sahs_user WHERE obj_id = %s',
1099 array('integer'),
1100 array($this->getId())
1101 );
1102
1103 // always call parent delete function at the end!!
1104 return true;
1105 }
1106
1112 public function getPointsInPercent(): ?float
1113 {
1114 global $DIC;
1115 $ilUser = $DIC->user();
1116 if (strcmp($this->getSubType(), "scorm2004") == 0) {
1118 if (!is_null($res)) {
1119 return $res * 100.0;
1120 }
1121
1122 return $res;
1123 }
1124
1125 return null;
1126 }
1127
1133 public function getMaxPoints(): ?float
1134 {
1135 global $DIC;
1136 $ilUser = $DIC->user();
1137
1138 if (strcmp($this->getSubType(), 'scorm2004') == 0) {
1140 return $res;
1141 }
1142
1143 return null;
1144 }
1145
1155 public function populateByDirectoy(string $a_dir, string $a_filename = ""): void
1156 {
1157 /*preg_match("/.*sahs_([0-9]*)\.zip/", $a_filename, $match);
1158 if (is_dir($a_dir."/sahs_".$match[1]))
1159 {
1160 $a_dir = $a_dir."/sahs_".$match[1];
1161 }*/
1162 ilFileUtils::rCopy($a_dir, $this->getDataDirectory());
1164 }
1165
1173 public function cloneObject(int $a_target_id, int $a_copy_id = 0, bool $a_omit_tree = false): ?ilObject
1174 {
1175 global $DIC;
1176 $ilDB = $DIC->database();
1177 $ilUser = $DIC->user();
1178 $lng = $DIC->language();
1179
1180 $new_obj = parent::cloneObject($a_target_id, $a_copy_id, $a_omit_tree);
1181 if ($new_obj !== null) {
1182 $this->cloneMetaData($new_obj);
1183
1184 $new_obj->setOfflineStatus($this->getOfflineStatus());
1185 //copy online status if object is not the root copy object
1186 $cp_options = ilCopyWizardOptions::_getInstance($a_copy_id);
1187 if ($cp_options->isRootNode($this->getRefId())) {
1188 $new_obj->setOfflineStatus(true);
1189 }
1190
1191 // copy properties
1192 // $new_obj->setTitle($this->getTitle() . ' ' . $lng->txt('copy_of_suffix'));
1193 $new_obj->setDescription($this->getDescription());
1194 $new_obj->setSubType($this->getSubType());
1195 $new_obj->setAPIAdapterName($this->getAPIAdapterName());
1196 $new_obj->setAPIFunctionsPrefix($this->getAPIFunctionsPrefix());
1197 $new_obj->setAutoReviewChar($this->getAutoReviewChar());
1198 $new_obj->setDefaultLessonMode($this->getDefaultLessonMode());
1199 // $new_obj->setEditable($this->getEditable());
1200 $new_obj->setMaxAttempt($this->getMaxAttempt());
1201 $new_obj->setModuleVersion($this->getModuleVersion());
1202 $new_obj->setModuleVersion(1);
1203 $new_obj->setCreditMode($this->getCreditMode());
1204 $new_obj->setAssignedGlossary($this->getAssignedGlossary());
1205 $new_obj->setTries($this->getTries());
1206 $new_obj->setSession($this->getSession());
1207 $new_obj->setNoMenu($this->getNoMenu());
1208 $new_obj->setHideNavig($this->getHideNavig());
1209 $new_obj->setFourth_edition($this->getFourth_edition());
1210 $new_obj->setSequencing($this->getSequencing());
1211 $new_obj->setInteractions($this->getInteractions());
1212 $new_obj->setObjectives($this->getObjectives());
1213 $new_obj->setComments($this->getComments());
1214 $new_obj->setTime_from_lms($this->getTime_from_lms());
1215 $new_obj->setDebug($this->getDebug());
1216 $new_obj->setLocalization($this->getLocalization());
1217 // $new_obj->setSequencingExpertMode(0); //$this->getSequencingExpertMode()
1218 // $new_obj->setDebugPw($this->getDebugPw());
1219 $new_obj->setOpenMode($this->getOpenMode());
1220 $new_obj->setWidth($this->getWidth());
1221 $new_obj->setHeight($this->getHeight());
1222 $new_obj->setAutoContinue($this->getAutoContinue());
1223 $new_obj->setAuto_last_visited($this->getAuto_last_visited());
1224 $new_obj->setCheck_values($this->getCheck_values());
1225 // $new_obj->setOfflineMode($this->getOfflineMode());
1226 $new_obj->setAutoSuspend($this->getAutoSuspend());
1227 $new_obj->setIe_force_render($this->getIe_force_render());
1228 $new_obj->setStyleSheetId($this->getStyleSheetId());
1229 $new_obj->update();
1230
1231
1232 // set/copy stylesheet
1233 /* include_once("./Services/Style/Content/classes/class.ilObjStyleSheet.php");
1234 $style_id = $this->getStyleSheetId();
1235 if ($style_id > 0 && !ilObjStyleSheet::_lookupStandard($style_id))
1236 {
1237 $style_obj = $ilias->obj_factory->getInstanceByObjId($style_id);
1238 $new_id = $style_obj->ilClone();
1239 $new_obj->setStyleSheetId($new_id);
1240 $new_obj->update();
1241 }*/
1242
1243 // up to this point $new_obj is of type ilobjsahslearning module
1244
1245 // create instance of correct subtype and call forward it to
1246 // cloneIntoNewObject method
1247 switch ($this->getSubType()) {
1248 case "scorm":
1249 $source_obj = new ilObjSCORMLearningModule($this->getRefId());
1250 $new_obj = new ilObjSCORMLearningModule($new_obj->getRefId());
1251 break;
1252
1253 case "scorm2004":
1254 $source_obj = new ilObjSCORM2004LearningModule($this->getRefId());
1255 $new_obj = new ilObjSCORM2004LearningModule($new_obj->getRefId());
1256 break;
1257 }
1258
1259 // copy data directory
1260 $new_obj->populateByDirectoy($source_obj->getDataDirectory());
1261
1262 // // copy authored content ...
1263 // if ($new_obj->getEditable()) {
1264 // $source_obj->copyAuthoredContent($new_obj);
1265 // } else {
1266 // ... or read manifest file
1267 $new_obj->readObject();
1268 // }
1269 $obj_settings = new ilLPObjSettings($this->getId());
1270 $obj_settings->cloneSettings($new_obj->getId());
1272 $olp = ilObjectLP::getInstance($this->getId());
1273 $collection = $olp->getCollectionInstance();
1274 if ($collection) {
1275 $collection->cloneCollection($new_obj->getRefId(), $cp_options->getCopyId());
1276 }
1277 }
1278 return $new_obj;
1279 }
1280
1281
1285 public function getApiStudentId(): string
1286 {
1287 global $DIC;
1288 $usr = $DIC->user();
1289 $idSetting = $this->getIdSetting();
1290 $studentId = (string) $usr->getId();
1291 if ($idSetting % 2 == 1) {
1292 $studentId = $usr->getLogin();
1293 }
1294 if ($idSetting > 3) {
1295 $studentId .= '_o_' . $this->getId();
1296 } elseif ($idSetting > 1) {
1297 $studentId .= '_r_' . $this->getRefId();
1298 }
1299 return $studentId;
1300 }
1301
1306 public function getApiStudentName(): string
1307 {
1308 global $DIC;
1309 $lng = $DIC->language();
1310 $usr = $DIC->user();
1311 $studentName = " ";
1312 switch ($this->getNameSetting()) {
1313 case 0:
1314 $studentName = $usr->getLastname() . ', ' . $usr->getFirstname();
1315 break;
1316 case 1:
1317 $studentName = $usr->getFirstname() . ' ' . $usr->getLastname();
1318 break;
1319 case 2:
1320 $studentName = $usr->getFullname();
1321 break;
1322 case 3:
1323 switch ($usr->getGender()) {
1324 case 'f':
1325 $studentName = $lng->txt('salutation_f') . ' ';
1326 break;
1327
1328 case 'm':
1329 $studentName = $lng->txt('salutation_m') . ' ';
1330 break;
1331
1332 case 'n':
1333 $studentName = '';//$lng->txt('salutation_n');
1334 break;
1335
1336 default:
1337 $studentName = $lng->txt('salutation') . ' ';
1338 }
1339 $studentName .= $usr->getLastname();
1340 break;
1341 case 4:
1342 $studentName = $usr->getFirstname();
1343 break;
1344 }
1345 return $studentName;
1346 }
1347
1348 //todo : replace LinkButton
1349
1353 public function getViewButton(): ilLinkButton
1354 {
1355 $setUrl = "ilias.php?baseClass=ilSAHSPresentationGUI&amp;ref_id=" . $this->getRefID();
1356 // $setUrl = $this->getLinkTargetByClass("ilsahspresentationgui", "")."&amp;ref_id=".$this->getRefID();
1357 $setTarget = "ilContObj" . $this->getId();
1358 $om = $this->getOpenMode();
1359 $width = $this->getWidth();
1360 $height = $this->getHeight();
1361 if (($om == 5 || $om == 1) && $width > 0 && $height > 0) {
1362 $om++;
1363 }
1364 if ($om != 0) {
1365 $setUrl = "javascript:void(0); onclick=startSAHS('" . $setUrl . "','ilContObj" . $this->getId() . "'," . $om . "," . $width . "," . $height . ");";
1366 $setTarget = "";
1367 }
1368 $button = ilLinkButton::getInstance();
1369 $button->setCaption("view");
1370 $button->setPrimary(true);
1371 $button->setUrl($setUrl);
1372 $button->setTarget($setTarget);
1373 return $button;
1374 }
1375}
static _getInstance(int $a_copy_id)
static getWebspaceDir(string $mode="filesystem")
get webspace directory
static makeDir(string $a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...
static delDir(string $a_dir, bool $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
static renameExecutables(string $a_dir)
static rCopy(string $a_sdir, string $a_tdir, bool $preserveTimeAttributes=false)
Copies content of a directory $a_sdir recursively to a directory $a_tdir.
getLangKey()
Return lang key.
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
getInstalledLanguages()
Get installed languages.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getLogger(string $a_component_id)
Get component logger.
static _lookupDiskUsage(int $a_id)
Returns the number of bytes used on the harddisk by the learning module with the specified object id.
Class ilObjSCORMLearningModule.
getAPIFunctionsPrefix()
get api functions prefix
getDefaultLessonMode()
get default lesson mode
getMaxPoints()
Returns score.max for the learning module, refered to the last sco where score.max is set.
setDefaultLessonMode(string $a_lesson_mode)
set default lesson mode
setAssignedGlossary(int $a_assigned_glossary)
getApiStudentId()
Get cmi.core.student_id / cmi.learner_id for API.
createDataDirectory()
creates data directory for package files ("./data/lm_data/lm_<id>")
setTries(int $a_tries)
Set default tries for questions.
getApiStudentName()
Get cmi.core.student_name / cmi.learner_name for API note: 'lastname, firstname' is required for SCOR...
getDiskUsage()
Gets the disk usage of the object in bytes.
static getScormModulesForGlossary(int $a_glo_id)
Get SCORM modules that assign a certain glossary.
setNoMenu(bool $a_no_menu)
disable menu
getFourth_Edition()
SCORM 2004 4th edition features.
getIe_force_render()
force Internet Explorer to render again after some Milliseconds - useful for learning Modules with a ...
getDataDirectory(?string $mode="filesystem")
get data directory of lm
setAutoReview(bool $a_auto_review)
set auto review as true/false for SCORM 1.2
setStyleSheetId(int $a_style_id)
set ID of assigned style sheet object
setFourth_edition(bool $a_fourth_edition)
getAutoReviewChar()
get auto review as Char for SCORM 2004
getPointsInPercent()
Returns the points in percent for the learning module This is called by the certificate generator if ...
getOpenMode()
open_mode 0: in Tab/new Window like in previous versions 1: in iFrame with width=100% and heigth=100%...
setIe_force_render(bool $a_ie_force_render)
static lookupAssignedGlossary(int $a_slm_id)
Get SCORM modules that assign a certain glossary.
setAPIAdapterName(string $a_api)
set api adapter name
setHideNavig(bool $a_hide_navig)
disable menu
getCacheDeactivated()
BrowserCacheDisabled for SCORM 2004 / ENABLE_JS_DEBUG.
create(bool $upload=false)
create file based lm
setAPIFunctionsPrefix(string $a_prefix)
set api functions prefix
__construct(int $a_id=0, bool $a_call_by_reference=true)
Constructor.
getAutoReview()
get auto review as true/false for SCORM 1.2
checkMasteryScoreValues()
check mastery_score / min_normalized_measure of SCOs (SCORM 1.2) / objectives (SCORM 2004)
populateByDirectoy(string $a_dir, string $a_filename="")
Populate by directory.
getStyleSheetId()
get ID of assigned style sheet object
getSessionDeactivated()
sessionDisabled for SCORM 2004
setCreditMode(string $a_credit_mode)
set credit mode
setAutoReviewChar(?string $a_auto_review)
set auto review as Char for SCORM 2004
setAuto_last_visited(bool $a_auto_last_visited)
static getAffectiveLocalization(int $a_id)
Get affective localization.
static _lookupSubType(int $a_obj_id)
lookup subtype id (scorm, )
static _getTries(int $a_id)
obsolet?
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _getUniqueScaledScoreForUser(int $a_id, int $a_user)
Get the Unique Scaled Score of a course Conditions: Only one SCO may set cmi.score....
static _getMaxScoreForUser(int $a_id, int $a_user)
Returns score.max for the learning module, refered to the last sco where score.max is set.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getInstance(int $obj_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _lookupType(int $id, bool $reference=false)
cloneMetaData(ilObject $target_obj)
Copy meta data.
static _hasUntrashedReference(int $obj_id)
checks whether an object has at least one reference that is not in trash
ilLanguage $lng
string $type
static & _getInstance(int $a_id, int $a_slm_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static tf2yn(bool $a_tf)
static yn2tf(string $a_yn)
global $DIC
Definition: feed.php:28
$ilUser
Definition: imgupload.php:34
$res
Definition: ltiservices.php:69
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $ilSetting
Definition: privfeed.php:17
$lm_set