ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
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 
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 
110  include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
111  if (ilObject::_lookupType($this->getStyleSheetId()) != "sty")
112  {
113  $this->setStyleSheetId(0);
114  }
115  }
116  }
117 
121  function _lookupOnline($a_id)
122  {
123  global $ilDB;
124 
125  $lm_set = $ilDB->queryF('SELECT c_online FROM sahs_lm WHERE id = %s',
126  array('integer'), array($a_id));
127  $lm_rec = $ilDB->fetchAssoc($lm_set);
128 
129  return ilUtil::yn2tf($lm_rec["c_online"]);
130  }
131 
137  function getAffectiveLocalization($a_id)
138  {
139  global $ilDB, $lng;
140 
141  $lm_set = $ilDB->queryF('SELECT localization FROM sahs_lm WHERE id = %s',
142  array('integer'), array($a_id));
143  $lm_rec = $ilDB->fetchAssoc($lm_set);
144  $inst_lang = $lng->getInstalledLanguages();
145  if ($lm_rec["localization"] != "" && in_array($lm_rec["localization"], $inst_lang))
146  {
147  return $lm_rec["localization"];
148  }
149  return $lng->getLangKey();
150  }
151 
157  function _lookupSubType($a_obj_id)
158  {
159  global $ilDB;
160 
161  $obj_set = $ilDB->queryF('SELECT c_type FROM sahs_lm WHERE id = %s',
162  array('integer'), array($a_obj_id));
163  $obj_rec = $ilDB->fetchAssoc($obj_set);
164 
165  return $obj_rec["c_type"];
166  }
167 
173  function setEditable($a_editable)
174  {
175  $this->editable = $a_editable;
176  }
177 
183  function getEditable()
184  {
185  return $this->editable;
186  }
187 
188 
194  function setTries($a_tries)
195  {
196  $this->tries = $a_tries;
197  }
198 
204  function getTries()
205  {
206  return $this->tries;
207  }
208 
214  function setLocalization($a_val)
215  {
216  $this->localization = $a_val;
217  }
218 
224  function getLocalization()
225  {
226  return $this->localization;
227  }
228 
229  static function _getTries($a_id)
230  {
231  global $ilDB;
232 
233  $lm_set = $ilDB->queryF('SELECT question_tries FROM sahs_lm WHERE id = %s',
234  array('integer'), array($a_id));
235  $lm_rec = $ilDB->fetchAssoc($lm_set);
236 
237  return $lm_rec['question_tries'];
238  }
245  function getDiskUsage()
246  {
247  require_once("./Modules/ScormAicc/classes/class.ilObjSAHSLearningModuleAccess.php");
249  }
250 
251 
257  {
258  $lm_data_dir = ilUtil::getWebspaceDir()."/lm_data";
259  ilUtil::makeDir($lm_data_dir);
261  }
262 
266  function getDataDirectory($mode = "filesystem")
267  {
268  $lm_data_dir = ilUtil::getWebspaceDir($mode)."/lm_data";
269  $lm_dir = $lm_data_dir."/lm_".$this->getId();
270 
271  return $lm_dir;
272  }
273 
277  function getAPIAdapterName()
278  {
279  return $this->api_adapter;
280  }
281 
285  function setAPIAdapterName($a_api)
286  {
287  $this->api_adapter = $a_api;
288  }
289 
294  {
295  return $this->api_func_prefix;
296  }
297 
301  function setAPIFunctionsPrefix($a_prefix)
302  {
303  $this->api_func_prefix = $a_prefix;
304  }
305 
309  function getCreditMode()
310  {
311  return $this->credit_mode;
312  }
313 
317  function setCreditMode($a_credit_mode)
318  {
319  $this->credit_mode = $a_credit_mode;
320  }
321 
325  function setDefaultLessonMode($a_lesson_mode)
326  {
327  $this->lesson_mode = $a_lesson_mode;
328  }
329 
334  {
335  return $this->lesson_mode;
336  }
340  function getStyleSheetId()
341  {
342  return $this->style_id;
343  }
344 
348  function setStyleSheetId($a_style_id)
349  {
350  $this->style_id = $a_style_id;
351  }
352 
353 
357  function setAutoReview($a_auto_review)
358  {
359  $this->auto_review = ilUtil::tf2yn($a_auto_review);
360  }
364  function getAutoReview()
365  {
366  return ilUtil::yn2tf($this->auto_review);
367  }
368 
372  function setAutoReviewChar($a_auto_review)
373  {
374  $this->auto_review = $a_auto_review;
375  }
379  function getAutoReviewChar()
380  {
381  return $this->auto_review;
382  }
383 
387  function getMaxAttempt()
388  {
389  return $this->max_attempt;
390  }
391 
392 
396  function setMaxAttempt($a_max_attempt)
397  {
398  $this->max_attempt = $a_max_attempt;
399  }
400 
404  function getModuleVersion()
405  {
406  return $this->module_version;
407  }
408 
413  {
414  return $this->assigned_glossary;
415  }
416 
420  function setAssignedGlossary($a_assigned_glossary)
421  {
422  $this->assigned_glossary = $a_assigned_glossary;
423  }
427  function setModuleVersion($a_module_version)
428  {
429  $this->module_version = $a_module_version;
430  }
431 
435  function getSession()
436  {
437  return $this->session;
438  }
439 
443  function setSession($a_session)
444  {
445  $this->session = $a_session;
446  }
447 
451  function getNoMenu()
452  {
453  return $this->no_menu;
454  }
455 
459  function setNoMenu($a_no_menu)
460  {
461  $this->no_menu = $a_no_menu;
462  }
463 
467  function getHideNavig()
468  {
469  return $this->hide_navig;
470  }
471 
475  function setHideNavig($a_hide_navig)
476  {
477  $this->hide_navig = $a_hide_navig;
478  }
479 
484  {
485  global $ilSetting;
486  $lm_set = new ilSetting("lm");
487  if ($lm_set->get("scormdebug_disable_cache") == "1") return true;
488  return false;
489  }
490 
495  {
496  global $ilSetting;
497  $lm_set = new ilSetting("lm");
498  if ($lm_set->get("scorm_without_session") == "1") return true;
499  return false;
500  }
501 
505  function getDebugActivated()
506  {
507  global $ilSetting;
508  $lm_set = new ilSetting("lm");
509  if ($lm_set->get("scormdebug_global_activate") == "1") return true;
510  return false;
511  }
512 
517  {
518  return $this->ie_compatibility;
519  }
520 
521  function setIe_compatibility($a_ie_compatibility)
522  {
523  $this->ie_compatibility = $a_ie_compatibility;
524  }
525 
530  {
531  return $this->ie_force_render;
532  }
533 
534  function setIe_force_render($a_ie_force_render)
535  {
536  $this->ie_force_render = $a_ie_force_render;
537  }
538 
542  function getFourth_Edition()
543  {
544  return $this->fourth_edition;
545  }
546 
547  function setFourth_edition($a_fourth_edition)
548  {
549  $this->fourth_edition = $a_fourth_edition;
550  }
551 
555  function getSequencing()
556  {
557  return $this->sequencing;
558  }
559 
560  function setSequencing($a_sequencing)
561  {
562  $this->sequencing = $a_sequencing;
563  }
564 
568  function getInteractions()
569  {
570  return $this->interactions;
571  }
572 
573  function setInteractions($a_interactions)
574  {
575  $this->interactions = $a_interactions;
576  }
577 
581  function getObjectives()
582  {
583  return $this->objectives;
584  }
585 
586  function setObjectives($a_objectives)
587  {
588  $this->objectives = $a_objectives;
589  }
590 
594  function getComments()
595  {
596  return $this->comments;
597  }
598 
599  function setComments($a_comments)
600  {
601  $this->comments = $a_comments;
602  }
603 
607  function getTime_from_lms()
608  {
609  return $this->time_from_lms;
610  }
611 
612  function setTime_from_lms($a_time_from_lms)
613  {
614  $this->time_from_lms = $a_time_from_lms;
615  }
616 
620  function getCheck_values()
621  {
622  return $this->check_values;
623  }
624 
625  function setCheck_values($a_check_values)
626  {
627  $this->check_values = $a_check_values;
628  }
629 
633  function getOfflineMode()
634  {
635  return $this->offline_mode;
636  }
637 
638  function setOfflineMode($a_offline_mode)
639  {
640  $this->offline_mode = $a_offline_mode;
641  }
642 
643 
647  function getDebug()
648  {
649  return $this->debug;
650  }
651 
655  function setDebug($a_debug)
656  {
657  $this->debug = $a_debug;
658  }
659 
663  function getDebugPw()
664  {
665  return $this->debug_pw;
666  }
667 
671  function setDebugPw($a_debug_pw)
672  {
673  $this->debug_pw = $a_debug_pw;
674  }
675 
679  function setAutoContinue($a_auto_continue)
680  {
681  $this->auto_continue = $a_auto_continue;
682  }
686  function getAutoContinue()
687  {
688  return $this->auto_continue;
689  }
690 
695  {
696  return $this->auto_last_visited;
697  }
698 
699  function setAuto_last_visited($a_auto_last_visited)
700  {
701  $this->auto_last_visited = $a_auto_last_visited;
702  }
703 
704 
710  function setSequencingExpertMode($a_val)
711  {
712  $this->seq_exp_mode = $a_val;
713  }
714 
721  {
722  return $this->seq_exp_mode;
723  }
724 
728  function setAutoSuspend($a_auto_suspend)
729  {
730  $this->auto_suspend = $a_auto_suspend;
731  }
735  function getAutoSuspend()
736  {
737  return $this->auto_suspend;
738  }
739 
740 
751  function getOpenMode()
752  {
753  return $this->open_mode;
754  }
755  function setOpenMode($a_open_mode)
756  {
757  $this->open_mode = $a_open_mode;
758  }
759 
763  function getWidth()
764  {
765  return $this->width;
766  }
767  function setWidth($a_width)
768  {
769  $this->width = $a_width;
770  }
771 
775  function getHeight()
776  {
777  return $this->height;
778  }
779  function setHeight($a_height)
780  {
781  $this->height = $a_height;
782  }
783 
784 
788 /*
789  function updateMetaData()
790  {
791  $this->meta_data->update();
792  if ($this->meta_data->section != "General")
793  {
794  $meta = $this->meta_data->getElement("Title", "General");
795  $this->meta_data->setTitle($meta[0]["value"]);
796  $meta = $this->meta_data->getElement("Description", "General");
797  $this->meta_data->setDescription($meta[0]["value"]);
798  }
799  else
800  {
801  $this->setTitle($this->meta_data->getTitle());
802  $this->setDescription($this->meta_data->getDescription());
803  }
804  parent::update();
805 
806  }
807 */
808 
809 
816  function update()
817  {
818  global $ilDB;
819 
820  $this->updateMetaData();
821  parent::update();
822  //Workaround for fields where Null is not allowed!
823  $uStyleSheetId = $this->getStyleSheetId();
824  if ($uStyleSheetId == null) $uStyleSheetId=0;
825  $uOpenMode = $this->getOpenMode();
826  if ($uOpenMode == null) $uOpenMode=0;
827  $uWidth = $this->getWidth();
828  if ($uWidth == null) $uWidth=950;
829  $uHeight = $this->getHeight();
830  if ($uHeight == null) $uHeight=650;
831 
832  $statement = $ilDB->manipulateF('
833  UPDATE sahs_lm
834  SET c_online = %s,
835  api_adapter = %s,
836  api_func_prefix = %s,
837  auto_review = %s,
838  default_lesson_mode = %s,
839  c_type = %s,
840  stylesheet = %s,
841  editable = %s,
842  max_attempt = %s,
843  module_version = %s,
844  credit = %s,
845  glossary = %s,
846  question_tries = %s,
847  unlimited_session = %s,
848  no_menu = %s,
849  hide_navig = %s,
850  fourth_edition =%s,
851  sequencing = %s,
852  interactions = %s,
853  objectives = %s,
854  comments = %s,
855  time_from_lms = %s,
856  debug = %s,
857  localization = %s,
858  seq_exp_mode = %s,
859  debugpw = %s,
860  open_mode = %s,
861  width = %s,
862  height = %s,
863  auto_continue = %s,
864  auto_last_visited = %s,
865  check_values = %s,
866  offline_mode = %s,
867  auto_suspend = %s,
868  ie_compatibility = %s,
869  ie_force_render = %s
870  WHERE id = %s',
871  array( 'text',
872  'text',
873  'text',
874  'text',
875  'text',
876  'text',
877  'integer',
878  'integer',
879  'integer',
880  'integer',
881  'text',
882  'integer',
883  'integer',
884  'text',
885  'text',
886  'text',
887  'text',
888  'text',
889  'text',
890  'text',
891  'text',
892  'text',
893  'text',
894  'text',
895  'integer',
896  'text',
897  'integer',
898  'integer',
899  'integer',
900  'text',
901  'text',
902  'text',
903  'text',
904  'text',
905  'text',
906  'text',
907  'integer'
908  ),
909  array( ilUtil::tf2yn($this->getOnline()),
910  $this->getAPIAdapterName(),
911  $this->getAPIFunctionsPrefix(),
912  $this->getAutoReviewChar(),
913  $this->getDefaultLessonMode(),
914  $this->getSubType(),
915  $uStyleSheetId,
916  $this->getEditable(),
917  $this->getMaxAttempt(),
918  $this->getModuleVersion(),
919  $this->getCreditMode(),
920  $this->getAssignedGlossary(),
921  $this->getTries(),
922  ilUtil::tf2yn($this->getSession()),
923  ilUtil::tf2yn($this->getNoMenu()),
924  ilUtil::tf2yn($this->getHideNavig()),
925  ilUtil::tf2yn($this->getFourth_edition()),
926  ilUtil::tf2yn($this->getSequencing()),
927  ilUtil::tf2yn($this->getInteractions()),
928  ilUtil::tf2yn($this->getObjectives()),
929  ilUtil::tf2yn($this->getComments()),
931  ilUtil::tf2yn($this->getDebug()),
932  $this->getLocalization(),
933  $this->getSequencingExpertMode(),
934  $this->getDebugPw(),
935  $uOpenMode,
936  $uWidth,
937  $uHeight,
938  ilUtil::tf2yn($this->getAutoContinue()),
940  ilUtil::tf2yn($this->getCheck_values()),
941  ilUtil::tf2yn($this->getOfflineMode()),
942  ilUtil::tf2yn($this->getAutoSuspend()),
945  $this->getId())
946  );
947 
948  return true;
949  }
950 
957  static function getScormModulesForGlossary($a_glo_id)
958  {
959  global $ilDB;
960 
961  $set = $ilDB->query("SELECT DISTINCT id FROM sahs_lm WHERE ".
962  " glossary = ".$ilDB->quote($a_glo_id, "integer"));
963  $sms = array();
964  while ($rec = $ilDB->fetchAssoc($set))
965  {
966  if (ilObject::_hasUntrashedReference($rec["id"]))
967  {
968  $sms[] = $rec["id"];
969  }
970  }
971  return $sms;
972  }
973 
980  static function lookupAssignedGlossary($a_slm_id)
981  {
982  global $ilDB;
983 
984  $set = $ilDB->query("SELECT DISTINCT glossary FROM sahs_lm WHERE ".
985  " id = ".$ilDB->quote($a_slm_id, "integer"));
986  $rec = $ilDB->fetchAssoc($set);
987  $glo_id = $rec["glossary"];
988  if (ilObject::_lookupType($glo_id) == "glo")
989  {
990  return $glo_id;
991  }
992  return 0;
993  }
994 
998  function setOnline($a_online)
999  {
1000  $this->online = $a_online;
1001  }
1002 
1006  function getOnline()
1007  {
1008  return $this->online;
1009  }
1010 
1014  function setSubType($a_sub_type)
1015  {
1016  $this->sub_type = $a_sub_type;
1017  }
1018 
1022  function getSubType()
1023  {
1024  return $this->sub_type;
1025  }
1026 
1038  function delete()
1039  {
1040  global $ilDB, $ilLog;
1041 
1042  // always call parent delete function first!!
1043  if (!parent::delete())
1044  {
1045  return false;
1046  }
1047 
1048  // delete meta data of scorm content object
1049 /*
1050  $nested = new ilNestedSetXML();
1051  $nested->init($this->getId(), $this->getType());
1052  $nested->deleteAllDBData();
1053 */
1054  $this->deleteMetaData();
1055 
1056  // delete data directory
1057  ilUtil::delDir($this->getDataDirectory());
1058 
1059  // delete scorm learning module record
1060  $ilDB->manipulateF('DELETE FROM sahs_lm WHERE id = %s',
1061  array('integer'), array($this->getId()));
1062 
1063  $ilLog->write("SAHS Delete(SAHSLM), Subtype: ".$this->getSubType());
1064 
1065  if ($this->getSubType() == "scorm")
1066  {
1067  // remove all scorm objects and scorm tree
1068  include_once("./Modules/ScormAicc/classes/SCORM/class.ilSCORMTree.php");
1069  include_once("./Modules/ScormAicc/classes/SCORM/class.ilSCORMObject.php");
1070  $sc_tree = new ilSCORMTree($this->getId());
1071  $r_id = $sc_tree->readRootId();
1072  if ($r_id > 0)
1073  {
1074  $items = $sc_tree->getSubTree($sc_tree->getNodeData($r_id));
1075  foreach($items as $item)
1076  {
1077  $sc_object =& ilSCORMObject::_getInstance($item["obj_id"], $this->getId());
1078  if (is_object($sc_object))
1079  {
1080  $sc_object->delete();
1081  }
1082  }
1083  $sc_tree->removeTree($sc_tree->getTreeId());
1084  }
1085  }
1086 
1087  if ($this->getSubType() != "scorm")
1088  {
1089  // delete aicc data
1090  $res = $ilDB->queryF('
1091  SELECT aicc_object.obj_id FROM aicc_object, aicc_units
1092  WHERE aicc_object.obj_id = aicc_units.obj_id
1093  AND aicc_object.slm_id = %s',
1094  array('integer'), array($this->getId()));
1095 
1096  while($row = $ilDB->fetchAssoc($res))
1097  {
1098  $obj_id = $row['obj_id'];
1099  $ilDB->manipulateF('
1100  DELETE FROM aicc_units WHERE obj_id = %s',
1101  array('integer'), array($obj_id));
1102  }
1103 
1104  $res = $ilDB->queryF('
1105  SELECT aicc_object.obj_id FROM aicc_object, aicc_course
1106  WHERE aicc_object.obj_id = aicc_course.obj_id
1107  AND aicc_object.slm_id = %s',
1108  array('integer'), array($this->getId()));
1109 
1110  while($row = $ilDB->fetchAssoc($res))
1111  {
1112  $obj_id = $row['obj_id'];
1113  $ilDB->manipulateF('
1114  DELETE FROM aicc_course WHERE obj_id = %s',
1115  array('integer'), array($obj_id));
1116  }
1117 
1118  $ilDB->manipulateF('
1119  DELETE FROM aicc_object WHERE slm_id = %s',
1120  array('integer'), array($this->getId()));
1121  }
1122 
1123  $q_log = "DELETE FROM scorm_tracking WHERE obj_id = ".$ilDB->quote($this->getId());
1124  $ilLog->write("SAHS Delete(SAHSLM): ".$q_log);
1125 
1126  $ilDB->manipulateF('DELETE FROM scorm_tracking WHERE obj_id = %s',
1127  array('integer'), array($this->getId()));
1128 
1129  $q_log = "DELETE FROM sahs_user WHERE obj_id = ".$ilDB->quote($this->getId());
1130  $ilLog->write("SAHS Delete(SAHSLM): ".$q_log);
1131 
1132  $ilDB->manipulateF('DELETE FROM sahs_user WHERE obj_id = %s',
1133  array('integer'), array($this->getId()));
1134 
1135  // always call parent delete function at the end!!
1136  return true;
1137  }
1138 
1149  function notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params = 0)
1150  {
1151  global $tree;
1152 
1153  switch ($a_event)
1154  {
1155  case "link":
1156 
1157  //var_dump("<pre>",$a_params,"</pre>");
1158  //echo "SCORMLearningModule ".$this->getRefId()." triggered by link event. Objects linked into target object ref_id: ".$a_ref_id;
1159  //exit;
1160  break;
1161 
1162  case "cut":
1163 
1164  //echo "SCORMLearningModule ".$this->getRefId()." triggered by cut event. Objects are removed from target object ref_id: ".$a_ref_id;
1165  //exit;
1166  break;
1167 
1168  case "copy":
1169 
1170  //var_dump("<pre>",$a_params,"</pre>");
1171  //echo "SCORMLearningModule ".$this->getRefId()." triggered by copy event. Objects are copied into target object ref_id: ".$a_ref_id;
1172  //exit;
1173  break;
1174 
1175  case "paste":
1176 
1177  //echo "SCORMLearningModule ".$this->getRefId()." triggered by paste (cut) event. Objects are pasted into target object ref_id: ".$a_ref_id;
1178  //exit;
1179  break;
1180 
1181  case "new":
1182 
1183  //echo "SCORMLearningModule ".$this->getRefId()." triggered by paste (new) event. Objects are applied to target object ref_id: ".$a_ref_id;
1184  //exit;
1185  break;
1186  }
1187 
1188  // At the beginning of the recursive process it avoids second call of the notify function with the same parameter
1189  if ($a_node_id==$_GET["ref_id"])
1190  {
1191  $parent_obj =& $this->ilias->obj_factory->getInstanceByRefId($a_node_id);
1192  $parent_type = $parent_obj->getType();
1193  if($parent_type == $this->getType())
1194  {
1195  $a_node_id = (int) $tree->getParentId($a_node_id);
1196  }
1197  }
1198 
1199  parent::notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params);
1200  }
1201 
1207  public function getPointsInPercent()
1208  {
1209  global $ilUser;
1210  if (strcmp($this->getSubType(), "scorm2004") == 0)
1211  {
1213  if (!is_null($res))
1214  {
1215  return $res * 100.0;
1216  }
1217  else
1218  {
1219  return $res;
1220  }
1221  }
1222  else
1223  {
1224  return null;
1225  }
1226  }
1227 
1238  public function getMaxPoints()
1239  {
1240  global $ilUser;
1241 
1242  if(strcmp($this->getSubType(), 'scorm2004') == 0)
1243  {
1244  $res = ilObjSCORM2004LearningModule::_getMaxScoreForUser($this->getId(), $ilUser->getId());
1245  return $res;
1246  }
1247  else
1248  {
1249  return null;
1250  }
1251  }
1252 
1262  function populateByDirectoy($a_dir, $a_filename = "")
1263  {
1264  /*preg_match("/.*sahs_([0-9]*)\.zip/", $a_filename, $match);
1265  if (is_dir($a_dir."/sahs_".$match[1]))
1266  {
1267  $a_dir = $a_dir."/sahs_".$match[1];
1268  }*/
1269  ilUtil::rCopy($a_dir, $this->getDataDirectory());
1271  }
1272 
1273 
1280  public function cloneObject($a_target_id,$a_copy_id = 0)
1281  {
1282  global $ilDB, $ilUser, $ilias;
1283 
1284  $new_obj = parent::cloneObject($a_target_id,$a_copy_id);
1285  $this->cloneMetaData($new_obj);
1286 
1287  // copy properties
1288  $new_obj->setTitle($this->getTitle());
1289  $new_obj->setDescription($this->getDescription());
1290  $new_obj->setSubType($this->getSubType());
1291  $new_obj->setAPIAdapterName($this->getAPIAdapterName());
1292  $new_obj->setAPIFunctionsPrefix($this->getAPIFunctionsPrefix());
1293  $new_obj->setAutoReviewChar($this->getAutoReviewChar());
1294  $new_obj->setDefaultLessonMode($this->getDefaultLessonMode());
1295  $new_obj->setEditable($this->getEditable());
1296  $new_obj->setMaxAttempt($this->getMaxAttempt());
1297  $new_obj->setModuleVersion($this->getModuleVersion());
1298  $new_obj->setModuleVersion(1);
1299  $new_obj->setCreditMode($this->getCreditMode());
1300  $new_obj->setAssignedGlossary($this->getAssignedGlossary());
1301  $new_obj->setTries($this->getTries());
1302  $new_obj->setSession($this->getSession());
1303  $new_obj->setNoMenu($this->getNoMenu());
1304  $new_obj->setHideNavig($this->getHideNavig());
1305  $new_obj->setFourth_edition($this->getFourth_edition());
1306  $new_obj->setSequencing($this->getSequencing());
1307  $new_obj->setInteractions($this->getInteractions());
1308  $new_obj->setObjectives($this->getObjectives());
1309  $new_obj->setComments($this->getComments());
1310  $new_obj->setTime_from_lms($this->getTime_from_lms());
1311  $new_obj->setDebug($this->getDebug());
1312  $new_obj->setLocalization($this->getLocalization());
1313  $new_obj->setSequencingExpertMode($this->getSequencingExpertMode());
1314  $new_obj->setDebugPw($this->getDebugPw());
1315  $new_obj->setOpenMode($this->getOpenMode());
1316  $new_obj->setWidth($this->getWidth());
1317  $new_obj->setHeight($this->getHeight());
1318  $new_obj->setAutoContinue($this->getAutoContinue());
1319  $new_obj->setAuto_last_visited($this->getAuto_last_visited());
1320  $new_obj->setCheck_values($this->getCheck_values());
1321  $new_obj->setOfflineMode($this->getOfflineMode());
1322  $new_obj->setAutoSuspend($this->getAutoSuspend());
1323  $new_obj->setIe_compatibility($this->getIe_compatibility());
1324  $new_obj->setIe_force_render($this->getIe_force_render());
1325  $new_obj->setStyleSheetId($this->getStyleSheetId());
1326  $new_obj->update();
1327 
1328 
1329  // set/copy stylesheet
1330 /* include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
1331  $style_id = $this->getStyleSheetId();
1332  if ($style_id > 0 && !ilObjStyleSheet::_lookupStandard($style_id))
1333  {
1334  $style_obj = $ilias->obj_factory->getInstanceByObjId($style_id);
1335  $new_id = $style_obj->ilClone();
1336  $new_obj->setStyleSheetId($new_id);
1337  $new_obj->update();
1338  }*/
1339 
1340  // up to this point $new_obj is of type ilobjsahslearning module
1341 
1342  // create instance of correct subtype and call forward it to
1343  // cloneIntoNewObject method
1344  switch ($this->getSubType())
1345  {
1346  case "scorm":
1347  include_once("./Modules/ScormAicc/classes/class.ilObjSCORMLearningModule.php");
1348  $source_obj = new ilObjSCORMLearningModule($this->getRefId());
1349  $new_obj = new ilObjSCORMLearningModule($new_obj->getRefId());
1350  break;
1351 
1352  case "scorm2004":
1353  include_once("./Modules/Scorm2004/classes/class.ilObjSCORM2004LearningModule.php");
1354  $source_obj = new ilObjSCORM2004LearningModule($this->getRefId());
1355  $new_obj = new ilObjSCORM2004LearningModule($new_obj->getRefId());
1356  break;
1357 
1358  case "aicc":
1359  include_once("./Modules/ScormAicc/classes/class.ilObjAICCLearningModule.php");
1360  $source_obj = new ilObjAICCLearningModule($this->getRefId());
1361  $new_obj = new ilObjAICCLearningModule($new_obj->getRefId());
1362  break;
1363 
1364  case "hacp":
1365  include_once("./Modules/ScormAicc/classes/class.ilObjHACPLearningModule.php");
1366  $source_obj = new ilObjHACPLearningModule($this->getRefId());
1367  $new_obj = new ilObjHACPLearningModule($new_obj->getRefId());
1368  break;
1369 
1370  }
1371 
1372  // copy data directory
1373  $new_obj->populateByDirectoy($source_obj->getDataDirectory());
1374 
1375  // copy authored content ...
1376  if ($new_obj->getEditable())
1377  {
1378  $source_obj->copyAuthoredContent($new_obj);
1379  }
1380  else
1381  {
1382  // ... or read manifest file
1383  $new_obj->readObject();
1384  }
1385 
1386  return $new_obj;
1387  }
1388 
1389  public function zipLmForOfflineMode()
1390  {
1391  $lmDir=ilUtil::getWebspaceDir("filesystem")."/lm_data/lm_".$this->getId();
1392  $zipFile=ilUtil::getDataDir()."/lm_data/lm_".$this->getId();
1393  return ilUtil::zip($lmDir, $zipFile, true);
1394  }
1395 
1396 }
1397 ?>