ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5
class.ilObjSAHSLearningModule.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2011 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
5 require_once "./Services/Object/classes/class.ilObject.php";
6 require_once "./Modules/ScormAicc/classes/class.ilObjSCORMValidator.php";
7 //require_once "Services/MetaData/classes/class.ilMDLanguageItem.php";
8 
21 {
23 // var $meta_data;
24 
31  function ilObjSAHSLearningModule($a_id = 0, $a_call_by_reference = true)
32  {
33  $this->type = "sahs";
34  parent::ilObject($a_id,$a_call_by_reference);
35  }
36 
40  function create($upload=false)
41  {
42  global $ilDB;
43 
44  parent::create();
45  if(!$upload)
46  $this->createMetaData();
47 
48  $this->createDataDirectory();
49 
50  $ilDB->manipulateF('
51  INSERT INTO sahs_lm (id, c_online, api_adapter, c_type, editable, seq_exp_mode,localization)
52  VALUES (%s,%s,%s,%s,%s,%s,%s)',
53  array('integer', 'text', 'text', 'text', 'integer','integer','text'),
54  array($this->getId(),'n','API', $this->getSubType(),(int)$this->getEditable(),
55  (int)$this->getSequencingExpertMode(), $this->getLocalization()
56  ));
57  }
58 
62  function read()
63  {
64  global $ilDB;
65 
66  parent::read();
67 
68  $lm_set = $ilDB->queryF('SELECT * FROM sahs_lm WHERE id = %s',
69  array('integer'),array($this->getId()));
70 
71  while($lm_rec = $ilDB->fetchAssoc($lm_set))
72  {
73  $this->setOnline(ilUtil::yn2tf($lm_rec["c_online"]));
74  $this->setAutoReviewChar($lm_rec["auto_review"]);
75  $this->setAPIAdapterName($lm_rec["api_adapter"]);
76  $this->setDefaultLessonMode($lm_rec["default_lesson_mode"]);
77  $this->setAPIFunctionsPrefix($lm_rec["api_func_prefix"]);
78  $this->setCreditMode($lm_rec["credit"]);
79  $this->setSubType($lm_rec["c_type"]);
80  $this->setEditable($lm_rec["editable"]);
81  $this->setStyleSheetId($lm_rec["stylesheet"]);
82  $this->setMaxAttempt($lm_rec["max_attempt"]);
83  $this->setModuleVersion($lm_rec["module_version"]);
84  $this->setAssignedGlossary($lm_rec["glossary"]);
85  $this->setTries($lm_rec["question_tries"]);
86  $this->setLocalization($lm_rec["localization"]);
87  $this->setSession(ilUtil::yn2tf($lm_rec["unlimited_session"]));
88  $this->setNoMenu(ilUtil::yn2tf($lm_rec["no_menu"]));
89  $this->setHideNavig(ilUtil::yn2tf($lm_rec["hide_navig"]));
90  $this->setFourth_edition(ilUtil::yn2tf($lm_rec["fourth_edition"]));
91  $this->setSequencing(ilUtil::yn2tf($lm_rec["sequencing"]));
92  $this->setInteractions(ilUtil::yn2tf($lm_rec["interactions"]));
93  $this->setObjectives(ilUtil::yn2tf($lm_rec["objectives"]));
94  $this->setComments(ilUtil::yn2tf($lm_rec["comments"]));
95  $this->setTime_from_lms(ilUtil::yn2tf($lm_rec["time_from_lms"]));
96  $this->setDebug(ilUtil::yn2tf($lm_rec["debug"]));
97  $this->setDebugPw($lm_rec["debugpw"]);
98  $this->setSequencingExpertMode($lm_rec["seq_exp_mode"]);
99  $this->setOpenMode($lm_rec["open_mode"]);
100  $this->setWidth($lm_rec["width"]);
101  $this->setHeight($lm_rec["height"]);
102  $this->setAutoContinue(ilUtil::yn2tf($lm_rec["auto_continue"]));
103  $this->setAuto_last_visited(ilUtil::yn2tf($lm_rec["auto_last_visited"]));
104  $this->setCheck_values(ilUtil::yn2tf($lm_rec["check_values"]));
105  $this->setOfflineMode(ilUtil::yn2tf($lm_rec["offline_mode"]));
106  $this->setAutoSuspend(ilUtil::yn2tf($lm_rec["auto_suspend"]));
107  $this->setIe_compatibility(ilUtil::yn2tf($lm_rec["ie_compatibility"]));
108  $this->setIe_force_render(ilUtil::yn2tf($lm_rec["ie_force_render"]));
109  $this->setMasteryScore($lm_rec["mastery_score"]);
110 
111  include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
112  if (ilObject::_lookupType($this->getStyleSheetId()) != "sty")
113  {
114  $this->setStyleSheetId(0);
115  }
116  }
117  }
118 
122  function _lookupOnline($a_id)
123  {
124  global $ilDB;
125 
126  $lm_set = $ilDB->queryF('SELECT c_online FROM sahs_lm WHERE id = %s',
127  array('integer'), array($a_id));
128  $lm_rec = $ilDB->fetchAssoc($lm_set);
129 
130  return ilUtil::yn2tf($lm_rec["c_online"]);
131  }
132 
138  function getAffectiveLocalization($a_id)
139  {
140  global $ilDB, $lng;
141 
142  $lm_set = $ilDB->queryF('SELECT localization FROM sahs_lm WHERE id = %s',
143  array('integer'), array($a_id));
144  $lm_rec = $ilDB->fetchAssoc($lm_set);
145  $inst_lang = $lng->getInstalledLanguages();
146  if ($lm_rec["localization"] != "" && in_array($lm_rec["localization"], $inst_lang))
147  {
148  return $lm_rec["localization"];
149  }
150  return $lng->getLangKey();
151  }
152 
158  function _lookupSubType($a_obj_id)
159  {
160  global $ilDB;
161 
162  $obj_set = $ilDB->queryF('SELECT c_type FROM sahs_lm WHERE id = %s',
163  array('integer'), array($a_obj_id));
164  $obj_rec = $ilDB->fetchAssoc($obj_set);
165 
166  return $obj_rec["c_type"];
167  }
168 
174  function setEditable($a_editable)
175  {
176  $this->editable = $a_editable;
177  }
178 
184  function getEditable()
185  {
186  return $this->editable;
187  }
188 
189 
195  function setTries($a_tries)
196  {
197  $this->tries = $a_tries;
198  }
199 
205  function getTries()
206  {
207  return $this->tries;
208  }
209 
215  function setLocalization($a_val)
216  {
217  $this->localization = $a_val;
218  }
219 
225  function getLocalization()
226  {
227  return $this->localization;
228  }
229 
230  static function _getTries($a_id)
231  {
232  global $ilDB;
233 
234  $lm_set = $ilDB->queryF('SELECT question_tries FROM sahs_lm WHERE id = %s',
235  array('integer'), array($a_id));
236  $lm_rec = $ilDB->fetchAssoc($lm_set);
237 
238  return $lm_rec['question_tries'];
239  }
246  function getDiskUsage()
247  {
248  require_once("./Modules/ScormAicc/classes/class.ilObjSAHSLearningModuleAccess.php");
250  }
251 
252 
258  {
259  $lm_data_dir = ilUtil::getWebspaceDir()."/lm_data";
260  ilUtil::makeDir($lm_data_dir);
262  }
263 
267  function getDataDirectory($mode = "filesystem")
268  {
269  $lm_data_dir = ilUtil::getWebspaceDir($mode)."/lm_data";
270  $lm_dir = $lm_data_dir."/lm_".$this->getId();
271 
272  return $lm_dir;
273  }
274 
278  function getAPIAdapterName()
279  {
280  return $this->api_adapter;
281  }
282 
286  function setAPIAdapterName($a_api)
287  {
288  $this->api_adapter = $a_api;
289  }
290 
295  {
296  return $this->api_func_prefix;
297  }
298 
302  function setAPIFunctionsPrefix($a_prefix)
303  {
304  $this->api_func_prefix = $a_prefix;
305  }
306 
310  function getCreditMode()
311  {
312  return $this->credit_mode;
313  }
314 
318  function setCreditMode($a_credit_mode)
319  {
320  $this->credit_mode = $a_credit_mode;
321  }
322 
326  function setDefaultLessonMode($a_lesson_mode)
327  {
328  $this->lesson_mode = $a_lesson_mode;
329  }
330 
335  {
336  return $this->lesson_mode;
337  }
341  function getStyleSheetId()
342  {
343  return $this->style_id;
344  }
345 
349  function setStyleSheetId($a_style_id)
350  {
351  $this->style_id = $a_style_id;
352  }
353 
354 
358  function setAutoReview($a_auto_review)
359  {
360  $this->auto_review = ilUtil::tf2yn($a_auto_review);
361  }
365  function getAutoReview()
366  {
367  return ilUtil::yn2tf($this->auto_review);
368  }
369 
373  function setAutoReviewChar($a_auto_review)
374  {
375  $this->auto_review = $a_auto_review;
376  }
380  function getAutoReviewChar()
381  {
382  return $this->auto_review;
383  }
384 
388  function getMaxAttempt()
389  {
390  return $this->max_attempt;
391  }
392 
393 
397  function setMaxAttempt($a_max_attempt)
398  {
399  $this->max_attempt = $a_max_attempt;
400  }
401 
405  function getModuleVersion()
406  {
407  return $this->module_version;
408  }
409 
414  {
415  return $this->assigned_glossary;
416  }
417 
421  function setAssignedGlossary($a_assigned_glossary)
422  {
423  $this->assigned_glossary = $a_assigned_glossary;
424  }
428  function setModuleVersion($a_module_version)
429  {
430  $this->module_version = $a_module_version;
431  }
432 
436  function getSession()
437  {
438  return $this->session;
439  }
440 
444  function setSession($a_session)
445  {
446  $this->session = $a_session;
447  }
448 
452  function getNoMenu()
453  {
454  return $this->no_menu;
455  }
456 
460  function setNoMenu($a_no_menu)
461  {
462  $this->no_menu = $a_no_menu;
463  }
464 
468  function getHideNavig()
469  {
470  return $this->hide_navig;
471  }
472 
476  function setHideNavig($a_hide_navig)
477  {
478  $this->hide_navig = $a_hide_navig;
479  }
480 
485  {
486  global $ilSetting;
487  $lm_set = new ilSetting("lm");
488  if ($lm_set->get("scormdebug_disable_cache") == "1") return true;
489  return false;
490  }
491 
496  {
497  global $ilSetting;
498  $lm_set = new ilSetting("lm");
499  if ($lm_set->get("scorm_without_session") == "1") return true;
500  return false;
501  }
502 
506  function getDebugActivated()
507  {
508  global $ilSetting;
509  $lm_set = new ilSetting("lm");
510  if ($lm_set->get("scormdebug_global_activate") == "1") return true;
511  return false;
512  }
513 
518  {
519  return $this->ie_compatibility;
520  }
521 
522  function setIe_compatibility($a_ie_compatibility)
523  {
524  $this->ie_compatibility = $a_ie_compatibility;
525  }
526 
531  {
532  return $this->ie_force_render;
533  }
534 
535  function setIe_force_render($a_ie_force_render)
536  {
537  $this->ie_force_render = $a_ie_force_render;
538  }
539 
543  function getFourth_Edition()
544  {
545  return $this->fourth_edition;
546  }
547 
548  function setFourth_edition($a_fourth_edition)
549  {
550  $this->fourth_edition = $a_fourth_edition;
551  }
552 
556  function getSequencing()
557  {
558  return $this->sequencing;
559  }
560 
561  function setSequencing($a_sequencing)
562  {
563  $this->sequencing = $a_sequencing;
564  }
565 
569  function getInteractions()
570  {
571  return $this->interactions;
572  }
573 
574  function setInteractions($a_interactions)
575  {
576  $this->interactions = $a_interactions;
577  }
578 
582  function getObjectives()
583  {
584  return $this->objectives;
585  }
586 
587  function setObjectives($a_objectives)
588  {
589  $this->objectives = $a_objectives;
590  }
591 
595  function getComments()
596  {
597  return $this->comments;
598  }
599 
600  function setComments($a_comments)
601  {
602  $this->comments = $a_comments;
603  }
604 
608  function getTime_from_lms()
609  {
610  return $this->time_from_lms;
611  }
612 
613  function setTime_from_lms($a_time_from_lms)
614  {
615  $this->time_from_lms = $a_time_from_lms;
616  }
617 
621  function getCheck_values()
622  {
623  return $this->check_values;
624  }
625 
626  function setCheck_values($a_check_values)
627  {
628  $this->check_values = $a_check_values;
629  }
630 
634  function getOfflineMode()
635  {
636  return $this->offline_mode;
637  }
638 
639  function setOfflineMode($a_offline_mode)
640  {
641  $this->offline_mode = $a_offline_mode;
642  }
643 
644 
648  function getDebug()
649  {
650  return $this->debug;
651  }
652 
656  function setDebug($a_debug)
657  {
658  $this->debug = $a_debug;
659  }
660 
664  function getDebugPw()
665  {
666  return $this->debug_pw;
667  }
668 
672  function setDebugPw($a_debug_pw)
673  {
674  $this->debug_pw = $a_debug_pw;
675  }
676 
680  function setAutoContinue($a_auto_continue)
681  {
682  $this->auto_continue = $a_auto_continue;
683  }
687  function getAutoContinue()
688  {
689  return $this->auto_continue;
690  }
691 
696  {
697  return $this->auto_last_visited;
698  }
699 
700  function setAuto_last_visited($a_auto_last_visited)
701  {
702  $this->auto_last_visited = $a_auto_last_visited;
703  }
704 
705 
711  function setSequencingExpertMode($a_val)
712  {
713  $this->seq_exp_mode = $a_val;
714  }
715 
722  {
723  return $this->seq_exp_mode;
724  }
725 
729  function setAutoSuspend($a_auto_suspend)
730  {
731  $this->auto_suspend = $a_auto_suspend;
732  }
736  function getAutoSuspend()
737  {
738  return $this->auto_suspend;
739  }
740 
741 
752  function getOpenMode()
753  {
754  return $this->open_mode;
755  }
756  function setOpenMode($a_open_mode)
757  {
758  $this->open_mode = $a_open_mode;
759  }
760 
764  function getWidth()
765  {
766  return $this->width;
767  }
768  function setWidth($a_width)
769  {
770  $this->width = $a_width;
771  }
772 
776  function getHeight()
777  {
778  return $this->height;
779  }
780  function setHeight($a_height)
781  {
782  $this->height = $a_height;
783  }
784 
785 
789  function getMasteryScore()
790  {
791  return $this->mastery_score;
792  }
793 
797  function setMasteryScore($a_mastery_score)
798  {
799  $this->mastery_score = $a_mastery_score;
800  }
801 
806  {
807  global $ilDB;
808  $s_result = "";
809  $a_result = array();
810  $type = $this->_lookupSubType( $this->getID() );
811 
812  if ($type == "scorm2004") {
813  $set = $ilDB->query("SELECT minnormalmeasure FROM cp_objective, cp_node".
814  " WHERE satisfiedbymeasure=1 AND minnormalmeasure is not null AND cp_objective.cp_node_id=cp_node.cp_node_id AND".
815  " slm_id = ".$ilDB->quote($this->getID(), "integer"));
816  while ($rec = $ilDB->fetchAssoc($set)) {
817  $tmpval = $rec["minnormalmeasure"]*100;
818  if (!in_array($tmpval,$a_result)) $a_result[] = $tmpval;
819  }
820  } else {
821  $set = $ilDB->query("SELECT masteryscore FROM sc_item,scorm_object".
822  " WHERE sc_item.masteryscore is not null AND sc_item.obj_id=scorm_object.obj_id AND".
823  " slm_id = ".$ilDB->quote($this->getID(), "integer"));
824  while ($rec = $ilDB->fetchAssoc($set)) {
825  if (!in_array($rec["masteryscore"],$a_result)) $a_result[] = $rec["masteryscore"];
826  }
827  }
828  $s_result = implode(", ",$a_result);
829  $this->mastery_score_values = $s_result;
830  }
831 
836  {
837  return $this->mastery_score_values;
838  }
839 
843  /*
844  function updateMasteryScoreValues()
845  {
846  global $ilDB;
847  $s_mastery_score = $this->getMasteryScore();
848  if ($s_mastery_score != "" && is_numeric($s_mastery_score)) {
849  $i_mastery_score = round(intval($s_mastery_score,10));
850  $type = $this->_lookupSubType( $this->getID() );
851 
852  if ($type == "scorm2004") {
853  if ($i_mastery_score > 100) $i_mastery_score = 100;
854  $i_mastery_score = $i_mastery_score/100;
855  $statement = $ilDB->manipulateF(
856  'UPDATE cp_objective,cp_node SET minnormalmeasure = %s
857  WHERE satisfiedbymeasure=1 AND minnormalmeasure is not null AND cp_objective.cp_node_id=cp_node.cp_node_id AND slm_id = %s',
858  array('text','integer'),
859  array($i_mastery_score,$this->getID())
860  );
861  } else {
862  if ($i_mastery_score > 127) $i_mastery_score = 127;
863  $statement = $ilDB->manipulateF(
864  'UPDATE sc_item,scorm_object SET sc_item.masteryscore = %s
865  WHERE sc_item.masteryscore is not null AND sc_item.obj_id=scorm_object.obj_id AND slm_id = %s',
866  array('integer','integer'),
867  array($i_mastery_score,$this->getID())
868  );
869  }
870  }
871  }
872  */
873 
877 /*
878  function updateMetaData()
879  {
880  $this->meta_data->update();
881  if ($this->meta_data->section != "General")
882  {
883  $meta = $this->meta_data->getElement("Title", "General");
884  $this->meta_data->setTitle($meta[0]["value"]);
885  $meta = $this->meta_data->getElement("Description", "General");
886  $this->meta_data->setDescription($meta[0]["value"]);
887  }
888  else
889  {
890  $this->setTitle($this->meta_data->getTitle());
891  $this->setDescription($this->meta_data->getDescription());
892  }
893  parent::update();
894 
895  }
896 */
897 
898 
905  function update()
906  {
907  global $ilDB;
908 
909  $this->updateMetaData();
910  parent::update();
911 
912  $s_mastery_score = $this->getMasteryScore();
913  if ($s_mastery_score == "") $s_mastery_score = null;
914 
915  $statement = $ilDB->manipulateF('
916  UPDATE sahs_lm
917  SET c_online = %s,
918  api_adapter = %s,
919  api_func_prefix = %s,
920  auto_review = %s,
921  default_lesson_mode = %s,
922  c_type = %s,
923  stylesheet = %s,
924  editable = %s,
925  max_attempt = %s,
926  module_version = %s,
927  credit = %s,
928  glossary = %s,
929  question_tries = %s,
930  unlimited_session = %s,
931  no_menu = %s,
932  hide_navig = %s,
933  fourth_edition =%s,
934  sequencing = %s,
935  interactions = %s,
936  objectives = %s,
937  comments = %s,
938  time_from_lms = %s,
939  debug = %s,
940  localization = %s,
941  seq_exp_mode = %s,
942  debugpw = %s,
943  open_mode = %s,
944  width = %s,
945  height = %s,
946  auto_continue = %s,
947  auto_last_visited = %s,
948  check_values = %s,
949  offline_mode = %s,
950  auto_suspend = %s,
951  ie_compatibility = %s,
952  ie_force_render = %s,
953  mastery_score = %s
954  WHERE id = %s',
955  array( 'text',
956  'text',
957  'text',
958  'text',
959  'text',
960  'text',
961  'integer',
962  'integer',
963  'integer',
964  'integer',
965  'text',
966  'integer',
967  'integer',
968  'text',
969  'text',
970  'text',
971  'text',
972  'text',
973  'text',
974  'text',
975  'text',
976  'text',
977  'text',
978  'text',
979  'integer',
980  'text',
981  'integer',
982  'integer',
983  'integer',
984  'text',
985  'text',
986  'text',
987  'text',
988  'text',
989  'text',
990  'text',
991  'integer',
992  'integer'
993  ),
994  array( ilUtil::tf2yn($this->getOnline()),
995  $this->getAPIAdapterName(),
996  $this->getAPIFunctionsPrefix(),
997  $this->getAutoReviewChar(),
998  $this->getDefaultLessonMode(),
999  $this->getSubType(),
1000  $this->getStyleSheetId(),
1001  $this->getEditable(),
1002  $this->getMaxAttempt(),
1003  $this->getModuleVersion(),
1004  $this->getCreditMode(),
1005  $this->getAssignedGlossary(),
1006  $this->getTries(),
1007  ilUtil::tf2yn($this->getSession()),
1008  ilUtil::tf2yn($this->getNoMenu()),
1009  ilUtil::tf2yn($this->getHideNavig()),
1010  ilUtil::tf2yn($this->getFourth_edition()),
1011  ilUtil::tf2yn($this->getSequencing()),
1012  ilUtil::tf2yn($this->getInteractions()),
1013  ilUtil::tf2yn($this->getObjectives()),
1014  ilUtil::tf2yn($this->getComments()),
1015  ilUtil::tf2yn($this->getTime_from_lms()),
1016  ilUtil::tf2yn($this->getDebug()),
1017  $this->getLocalization(),
1018  $this->getSequencingExpertMode(),
1019  $this->getDebugPw(),
1020  $this->getOpenMode(),
1021  $this->getWidth(),
1022  $this->getHeight(),
1023  ilUtil::tf2yn($this->getAutoContinue()),
1025  ilUtil::tf2yn($this->getCheck_values()),
1026  ilUtil::tf2yn($this->getOfflineMode()),
1027  ilUtil::tf2yn($this->getAutoSuspend()),
1030  $s_mastery_score,
1031  $this->getId())
1032  );
1033 
1034  return true;
1035  }
1036 
1043  static function getScormModulesForGlossary($a_glo_id)
1044  {
1045  global $ilDB;
1046 
1047  $set = $ilDB->query("SELECT DISTINCT id FROM sahs_lm WHERE ".
1048  " glossary = ".$ilDB->quote($a_glo_id, "integer"));
1049  $sms = array();
1050  while ($rec = $ilDB->fetchAssoc($set))
1051  {
1052  if (ilObject::_hasUntrashedReference($rec["id"]))
1053  {
1054  $sms[] = $rec["id"];
1055  }
1056  }
1057  return $sms;
1058  }
1059 
1066  static function lookupAssignedGlossary($a_slm_id)
1067  {
1068  global $ilDB;
1069 
1070  $set = $ilDB->query("SELECT DISTINCT glossary FROM sahs_lm WHERE ".
1071  " id = ".$ilDB->quote($a_slm_id, "integer"));
1072  $rec = $ilDB->fetchAssoc($set);
1073  $glo_id = $rec["glossary"];
1074  if (ilObject::_lookupType($glo_id) == "glo")
1075  {
1076  return $glo_id;
1077  }
1078  return 0;
1079  }
1080 
1084  function setOnline($a_online)
1085  {
1086  $this->online = $a_online;
1087  }
1088 
1092  function getOnline()
1093  {
1094  return $this->online;
1095  }
1096 
1100  function setSubType($a_sub_type)
1101  {
1102  $this->sub_type = $a_sub_type;
1103  }
1104 
1108  function getSubType()
1109  {
1110  return $this->sub_type;
1111  }
1112 
1124  function delete()
1125  {
1126  global $ilDB, $ilLog;
1127 
1128  // always call parent delete function first!!
1129  if (!parent::delete())
1130  {
1131  return false;
1132  }
1133 
1134  // delete meta data of scorm content object
1135 /*
1136  $nested = new ilNestedSetXML();
1137  $nested->init($this->getId(), $this->getType());
1138  $nested->deleteAllDBData();
1139 */
1140  $this->deleteMetaData();
1141 
1142  // delete data directory
1143  ilUtil::delDir($this->getDataDirectory());
1144 
1145  // delete scorm learning module record
1146  $ilDB->manipulateF('DELETE FROM sahs_lm WHERE id = %s',
1147  array('integer'), array($this->getId()));
1148 
1149  $ilLog->write("SAHS Delete(SAHSLM), Subtype: ".$this->getSubType());
1150 
1151  if ($this->getSubType() == "scorm")
1152  {
1153  // remove all scorm objects and scorm tree
1154  include_once("./Modules/ScormAicc/classes/SCORM/class.ilSCORMTree.php");
1155  include_once("./Modules/ScormAicc/classes/SCORM/class.ilSCORMObject.php");
1156  $sc_tree = new ilSCORMTree($this->getId());
1157  $r_id = $sc_tree->readRootId();
1158  if ($r_id > 0)
1159  {
1160  $items = $sc_tree->getSubTree($sc_tree->getNodeData($r_id));
1161  foreach($items as $item)
1162  {
1163  $sc_object =& ilSCORMObject::_getInstance($item["obj_id"], $this->getId());
1164  if (is_object($sc_object))
1165  {
1166  $sc_object->delete();
1167  }
1168  }
1169  $sc_tree->removeTree($sc_tree->getTreeId());
1170  }
1171  }
1172 
1173  if ($this->getSubType() != "scorm")
1174  {
1175  // delete aicc data
1176  $res = $ilDB->queryF('
1177  SELECT aicc_object.obj_id FROM aicc_object, aicc_units
1178  WHERE aicc_object.obj_id = aicc_units.obj_id
1179  AND aicc_object.slm_id = %s',
1180  array('integer'), array($this->getId()));
1181 
1182  while($row = $ilDB->fetchAssoc($res))
1183  {
1184  $obj_id = $row['obj_id'];
1185  $ilDB->manipulateF('
1186  DELETE FROM aicc_units WHERE obj_id = %s',
1187  array('integer'), array($obj_id));
1188  }
1189 
1190  $res = $ilDB->queryF('
1191  SELECT aicc_object.obj_id FROM aicc_object, aicc_course
1192  WHERE aicc_object.obj_id = aicc_course.obj_id
1193  AND aicc_object.slm_id = %s',
1194  array('integer'), array($this->getId()));
1195 
1196  while($row = $ilDB->fetchAssoc($res))
1197  {
1198  $obj_id = $row['obj_id'];
1199  $ilDB->manipulateF('
1200  DELETE FROM aicc_course WHERE obj_id = %s',
1201  array('integer'), array($obj_id));
1202  }
1203 
1204  $ilDB->manipulateF('
1205  DELETE FROM aicc_object WHERE slm_id = %s',
1206  array('integer'), array($this->getId()));
1207  }
1208 
1209  $q_log = "DELETE FROM scorm_tracking WHERE obj_id = ".$ilDB->quote($this->getId());
1210  $ilLog->write("SAHS Delete(SAHSLM): ".$q_log);
1211 
1212  $ilDB->manipulateF('DELETE FROM scorm_tracking WHERE obj_id = %s',
1213  array('integer'), array($this->getId()));
1214 
1215  $q_log = "DELETE FROM sahs_user WHERE obj_id = ".$ilDB->quote($this->getId());
1216  $ilLog->write("SAHS Delete(SAHSLM): ".$q_log);
1217 
1218  $ilDB->manipulateF('DELETE FROM sahs_user WHERE obj_id = %s',
1219  array('integer'), array($this->getId()));
1220 
1221  // always call parent delete function at the end!!
1222  return true;
1223  }
1224 
1235  function notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params = 0)
1236  {
1237  global $tree;
1238 
1239  switch ($a_event)
1240  {
1241  case "link":
1242 
1243  //var_dump("<pre>",$a_params,"</pre>");
1244  //echo "SCORMLearningModule ".$this->getRefId()." triggered by link event. Objects linked into target object ref_id: ".$a_ref_id;
1245  //exit;
1246  break;
1247 
1248  case "cut":
1249 
1250  //echo "SCORMLearningModule ".$this->getRefId()." triggered by cut event. Objects are removed from target object ref_id: ".$a_ref_id;
1251  //exit;
1252  break;
1253 
1254  case "copy":
1255 
1256  //var_dump("<pre>",$a_params,"</pre>");
1257  //echo "SCORMLearningModule ".$this->getRefId()." triggered by copy event. Objects are copied into target object ref_id: ".$a_ref_id;
1258  //exit;
1259  break;
1260 
1261  case "paste":
1262 
1263  //echo "SCORMLearningModule ".$this->getRefId()." triggered by paste (cut) event. Objects are pasted into target object ref_id: ".$a_ref_id;
1264  //exit;
1265  break;
1266 
1267  case "new":
1268 
1269  //echo "SCORMLearningModule ".$this->getRefId()." triggered by paste (new) event. Objects are applied to target object ref_id: ".$a_ref_id;
1270  //exit;
1271  break;
1272  }
1273 
1274  // At the beginning of the recursive process it avoids second call of the notify function with the same parameter
1275  if ($a_node_id==$_GET["ref_id"])
1276  {
1277  $parent_obj =& $this->ilias->obj_factory->getInstanceByRefId($a_node_id);
1278  $parent_type = $parent_obj->getType();
1279  if($parent_type == $this->getType())
1280  {
1281  $a_node_id = (int) $tree->getParentId($a_node_id);
1282  }
1283  }
1284 
1285  parent::notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params);
1286  }
1287 
1293  public function getPointsInPercent()
1294  {
1295  global $ilUser;
1296  if (strcmp($this->getSubType(), "scorm2004") == 0)
1297  {
1299  if (!is_null($res))
1300  {
1301  return $res * 100.0;
1302  }
1303  else
1304  {
1305  return $res;
1306  }
1307  }
1308  else
1309  {
1310  return null;
1311  }
1312  }
1313 
1324  public function getMaxPoints()
1325  {
1326  global $ilUser;
1327 
1328  if(strcmp($this->getSubType(), 'scorm2004') == 0)
1329  {
1330  $res = ilObjSCORM2004LearningModule::_getMaxScoreForUser($this->getId(), $ilUser->getId());
1331  return $res;
1332  }
1333  else
1334  {
1335  return null;
1336  }
1337  }
1338 
1348  function populateByDirectoy($a_dir, $a_filename = "")
1349  {
1350  /*preg_match("/.*sahs_([0-9]*)\.zip/", $a_filename, $match);
1351  if (is_dir($a_dir."/sahs_".$match[1]))
1352  {
1353  $a_dir = $a_dir."/sahs_".$match[1];
1354  }*/
1355  ilUtil::rCopy($a_dir, $this->getDataDirectory());
1357  }
1358 
1359 
1366  public function cloneObject($a_target_id,$a_copy_id = 0)
1367  {
1368  global $ilDB, $ilUser, $ilias;
1369 
1370  $new_obj = parent::cloneObject($a_target_id,$a_copy_id);
1371  $this->cloneMetaData($new_obj);
1372 
1373  //copy online status if object is not the root copy object
1374  $cp_options = ilCopyWizardOptions::_getInstance($a_copy_id);
1375 
1376  if(!$cp_options->isRootNode($this->getRefId()))
1377  {
1378  $new_obj->setOnline($this->getOnline());
1379  }
1380 
1381  // copy properties
1382  $new_obj->setTitle($this->getTitle());
1383  $new_obj->setDescription($this->getDescription());
1384  $new_obj->setSubType($this->getSubType());
1385  $new_obj->setAPIAdapterName($this->getAPIAdapterName());
1386  $new_obj->setAPIFunctionsPrefix($this->getAPIFunctionsPrefix());
1387  $new_obj->setAutoReviewChar($this->getAutoReviewChar());
1388  $new_obj->setDefaultLessonMode($this->getDefaultLessonMode());
1389  $new_obj->setEditable($this->getEditable());
1390  $new_obj->setMaxAttempt($this->getMaxAttempt());
1391  $new_obj->setModuleVersion($this->getModuleVersion());
1392  $new_obj->setModuleVersion(1);
1393  $new_obj->setCreditMode($this->getCreditMode());
1394  $new_obj->setAssignedGlossary($this->getAssignedGlossary());
1395  $new_obj->setTries($this->getTries());
1396  $new_obj->setSession($this->getSession());
1397  $new_obj->setNoMenu($this->getNoMenu());
1398  $new_obj->setHideNavig($this->getHideNavig());
1399  $new_obj->setFourth_edition($this->getFourth_edition());
1400  $new_obj->setSequencing($this->getSequencing());
1401  $new_obj->setInteractions($this->getInteractions());
1402  $new_obj->setObjectives($this->getObjectives());
1403  $new_obj->setComments($this->getComments());
1404  $new_obj->setTime_from_lms($this->getTime_from_lms());
1405  $new_obj->setDebug($this->getDebug());
1406  $new_obj->setLocalization($this->getLocalization());
1407  $new_obj->setSequencingExpertMode($this->getSequencingExpertMode());
1408  $new_obj->setDebugPw($this->getDebugPw());
1409  $new_obj->setOpenMode($this->getOpenMode());
1410  $new_obj->setWidth($this->getWidth());
1411  $new_obj->setHeight($this->getHeight());
1412  $new_obj->setAutoContinue($this->getAutoContinue());
1413  $new_obj->setAuto_last_visited($this->getAuto_last_visited());
1414  $new_obj->setCheck_values($this->getCheck_values());
1415  $new_obj->setOfflineMode($this->getOfflineMode());
1416  $new_obj->setAutoSuspend($this->getAutoSuspend());
1417  $new_obj->setIe_compatibility($this->getIe_compatibility());
1418  $new_obj->setIe_force_render($this->getIe_force_render());
1419  $new_obj->setStyleSheetId($this->getStyleSheetId());
1420  $new_obj->update();
1421 
1422 
1423  // set/copy stylesheet
1424 /* include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
1425  $style_id = $this->getStyleSheetId();
1426  if ($style_id > 0 && !ilObjStyleSheet::_lookupStandard($style_id))
1427  {
1428  $style_obj = $ilias->obj_factory->getInstanceByObjId($style_id);
1429  $new_id = $style_obj->ilClone();
1430  $new_obj->setStyleSheetId($new_id);
1431  $new_obj->update();
1432  }*/
1433 
1434  // up to this point $new_obj is of type ilobjsahslearning module
1435 
1436  // create instance of correct subtype and call forward it to
1437  // cloneIntoNewObject method
1438  switch ($this->getSubType())
1439  {
1440  case "scorm":
1441  include_once("./Modules/ScormAicc/classes/class.ilObjSCORMLearningModule.php");
1442  $source_obj = new ilObjSCORMLearningModule($this->getRefId());
1443  $new_obj = new ilObjSCORMLearningModule($new_obj->getRefId());
1444  break;
1445 
1446  case "scorm2004":
1447  include_once("./Modules/Scorm2004/classes/class.ilObjSCORM2004LearningModule.php");
1448  $source_obj = new ilObjSCORM2004LearningModule($this->getRefId());
1449  $new_obj = new ilObjSCORM2004LearningModule($new_obj->getRefId());
1450  break;
1451 
1452  case "aicc":
1453  include_once("./Modules/ScormAicc/classes/class.ilObjAICCLearningModule.php");
1454  $source_obj = new ilObjAICCLearningModule($this->getRefId());
1455  $new_obj = new ilObjAICCLearningModule($new_obj->getRefId());
1456  break;
1457 
1458  case "hacp":
1459  include_once("./Modules/ScormAicc/classes/class.ilObjHACPLearningModule.php");
1460  $source_obj = new ilObjHACPLearningModule($this->getRefId());
1461  $new_obj = new ilObjHACPLearningModule($new_obj->getRefId());
1462  break;
1463 
1464  }
1465 
1466  // copy data directory
1467  $new_obj->populateByDirectoy($source_obj->getDataDirectory());
1468 
1469  // copy authored content ...
1470  if ($new_obj->getEditable())
1471  {
1472  $source_obj->copyAuthoredContent($new_obj);
1473  }
1474  else
1475  {
1476  // ... or read manifest file
1477  $new_obj->readObject();
1478  }
1479 
1480  return $new_obj;
1481  }
1482 
1483  public function zipLmForOfflineMode()
1484  {
1485  $lmDir=ilUtil::getWebspaceDir("filesystem")."/lm_data/lm_".$this->getId();
1486  $zipFile=ilUtil::getDataDir()."/lm_data/lm_".$this->getId();
1487  return ilUtil::zip($lmDir, $zipFile, true);
1488  }
1489 
1490 }
1491 ?>
getSequencingExpertMode()
Get sequencing expert mode.
getStyleSheetId()
get ID of assigned style sheet object
_lookupOnline($a_id)
check wether scorm module is online
static tf2yn($a_tf)
convert true/false to "y"/"n"
ILIAS Setting Class.
getFourth_Edition()
SCORM 2004 4th edition features.
getIe_compatibility()
set compatibility mode for Internet Exlorer manually
static lookupAssignedGlossary($a_slm_id)
Get SCORM modules that assign a certain glossary.
getDiskUsage()
Gets the disk usage of the object in bytes.
static rCopy($a_sdir, $a_tdir, $preserveTimeAttributes=false)
Copies content of a directory $a_sdir recursively to a directory $a_tdir.
$_GET["client_id"]
getMaxPoints()
Returns score.max for the learning module, refered to the last sco where score.max is set...
updateMetaData()
update meta data entry
Class ilObjAICCLearningModule.
getSessionDeactivated()
sessionDisabled for SCORM 2004
Class ilObject Basic functions for all objects.
setCreditMode($a_credit_mode)
set credit mode
setAPIFunctionsPrefix($a_prefix)
set api functions prefix
setSubType($a_sub_type)
get sub type
Class ilObjAICCLearningModule.
getAutoReviewChar()
get auto review as Char for SCORM 2004
createMetaData()
create meta data entry
getAPIAdapterName()
get api adapter name
setAutoSuspend($a_auto_suspend)
get auto continue
getAssignedGlossary()
get assigned glossary
getAutoReview()
get auto review as true/false for SCORM 1.2, HACP, SAHS, AICC
checkMasteryScoreValues()
check mastery_score / min_normalized_measure of SCOs (SCORM 1.2) / objectives (SCORM 2004) ...
setTries($a_tries)
Set default tries for questions.
setAutoReviewChar($a_auto_review)
set auto review as Char for SCORM 2004
getAPIFunctionsPrefix()
get api functions prefix
createDataDirectory()
creates data directory for package files ("./data/lm_data/lm_<id>")
setAutoContinue($a_auto_continue)
get auto continue
create($upload=false)
create file based lm
populateByDirectoy($a_dir, $a_filename="")
Populate by directory.
setAutoReview($a_auto_review)
set auto review as true/false for SCORM 1.2, HACP, SAHS, AICC
notify($a_event, $a_ref_id, $a_parent_non_rbac_id, $a_node_id, $a_params=0)
notifys an object about an event occured Based on the event happend, each object may decide how it re...
getDataDirectory($mode="filesystem")
get data directory of lm
getMasteryScoreValues()
get mastery_score_values
getIe_force_render()
force Internet Explorer to render again after some Milliseconds - useful for learning Modules with a ...
setLocalization($a_val)
Set localization.
_lookupDiskUsage($a_id)
Returns the number of bytes used on the harddisk by the learning module with the specified object id...
static _getInstance($a_copy_id)
Get instance of copy wizard options.
setStyleSheetId($a_style_id)
set ID of assigned style sheet object
getId()
get object id public
getOpenMode()
open_mode 0: in Tab/new Window like in previous versions 1: in iFrame with width=100% and heigth=100%...
setAuto_last_visited($a_auto_last_visited)
ilObjSAHSLearningModule($a_id=0, $a_call_by_reference=true)
Constructor public.
_lookupSubType($a_obj_id)
lookup subtype id (scorm, aicc, hacp)
static _getUniqueScaledScoreForUser($a_id, $a_user)
Get the Unique Scaled Score of a course Conditions: Only one SCO may set cmi.score.scaled.
getTitle()
get object title public
getDescription()
get object description
redirection script todo: (a better solution should control the processing via a xml file) ...
cloneMetaData($target_obj)
Copy meta data.
setHideNavig($a_hide_navig)
disable menu
SCORM Object Tree.
setMasteryScore($a_mastery_score)
set mastery_score
static zip($a_dir, $a_file, $compress_content=false)
zips given directory/file into given zip.file
getType()
get object type public
static _lookupType($a_id, $a_reference=false)
lookup object type
setSession($a_session)
set session setting
static makeDir($a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...
setSequencingExpertMode($a_val)
Set sequencing expert mode.
static getScormModulesForGlossary($a_glo_id)
Get SCORM modules that assign a certain glossary.
_hasUntrashedReference($a_obj_id)
checks wether an object has at least one reference that is not in trash
update()
update values for mastery_score / min_normalized_measure in database - not requested ...
static getDataDir()
get data directory (outside webspace)
$lm_set
global $ilUser
Definition: imgupload.php:15
getPointsInPercent()
Returns the points in percent for the learning module This is called by the certificate generator if ...
getAffectiveLocalization($a_id)
Get affective localization.
static renameExecutables($a_dir)
Rename uploaded executables for security reasons.
setAPIAdapterName($a_api)
set api adapter name
global $ilSetting
Definition: privfeed.php:40
Class ilObjSCORM2004LearningModule.
global $ilDB
getRefId()
get reference id public
deleteMetaData()
delete meta data entry
static _getMaxScoreForUser($a_id, $a_user)
Returns score.max for the learning module, refered to the last sco where score.max is set...
setEditable($a_editable)
Set Editable.
getDefaultLessonMode()
get default lesson mode
static yn2tf($a_yn)
convert "y"/"n" to true/false
& _getInstance($a_id, $a_slm_id)
get instance of specialized GUI class
setDefaultLessonMode($a_lesson_mode)
set default lesson mode
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
static getWebspaceDir($mode="filesystem")
get webspace directory
setAssignedGlossary($a_assigned_glossary)
set assigned glossary
Class ilObjSCORMLearningModule.
setMaxAttempt($a_max_attempt)
set max attempt
setModuleVersion($a_module_version)
set max attempt
Class ilObjSCORMLearningModule.
getCacheDeactivated()
BrowserCacheDisabled for SCORM 2004 / ENABLE_JS_DEBUG.
cloneObject($a_target_id, $a_copy_id=0)
Clone scorm object.