ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 {
22  public $validator;
23  // var $meta_data;
24 
31  public function __construct($a_id = 0, $a_call_by_reference = true)
32  {
33  $this->type = "sahs";
34  parent::__construct($a_id, $a_call_by_reference);
35  }
36 
40  public function create($upload=false)
41  {
42  global $ilDB;
43 
44  parent::create();
45  if (!$upload) {
46  $this->createMetaData();
47  }
48 
49  $this->createDataDirectory();
50 
51  $ilDB->manipulateF(
52  '
53  INSERT INTO sahs_lm (id, c_online, api_adapter, c_type, editable, seq_exp_mode,localization)
54  VALUES (%s,%s,%s,%s,%s,%s,%s)',
55  array('integer', 'text', 'text', 'text', 'integer','integer','text'),
56  array($this->getId(),'n','API', $this->getSubType(),(int) $this->getEditable(),
57  (int) $this->getSequencingExpertMode(), $this->getLocalization()
58  )
59  );
60  }
61 
65  public function read()
66  {
67  global $ilDB;
68 
69  parent::read();
70 
71  $lm_set = $ilDB->queryF(
72  'SELECT * FROM sahs_lm WHERE id = %s',
73  array('integer'),
74  array($this->getId())
75  );
76 
77  while ($lm_rec = $ilDB->fetchAssoc($lm_set)) {
78  $this->setOnline(ilUtil::yn2tf($lm_rec["c_online"]));
79  $this->setAutoReviewChar($lm_rec["auto_review"]);
80  $this->setAPIAdapterName($lm_rec["api_adapter"]);
81  $this->setDefaultLessonMode($lm_rec["default_lesson_mode"]);
82  $this->setAPIFunctionsPrefix($lm_rec["api_func_prefix"]);
83  $this->setCreditMode($lm_rec["credit"]);
84  $this->setSubType($lm_rec["c_type"]);
85  $this->setEditable($lm_rec["editable"]);
86  $this->setStyleSheetId($lm_rec["stylesheet"]);
87  $this->setMaxAttempt($lm_rec["max_attempt"]);
88  $this->setModuleVersion($lm_rec["module_version"]);
89  $this->setAssignedGlossary($lm_rec["glossary"]);
90  $this->setTries($lm_rec["question_tries"]);
91  $this->setLocalization($lm_rec["localization"]);
92  $this->setSession(ilUtil::yn2tf($lm_rec["unlimited_session"]));
93  $this->setNoMenu(ilUtil::yn2tf($lm_rec["no_menu"]));
94  $this->setHideNavig(ilUtil::yn2tf($lm_rec["hide_navig"]));
95  $this->setFourth_edition(ilUtil::yn2tf($lm_rec["fourth_edition"]));
96  $this->setSequencing(ilUtil::yn2tf($lm_rec["sequencing"]));
97  $this->setInteractions(ilUtil::yn2tf($lm_rec["interactions"]));
98  $this->setObjectives(ilUtil::yn2tf($lm_rec["objectives"]));
99  $this->setComments(ilUtil::yn2tf($lm_rec["comments"]));
100  $this->setTime_from_lms(ilUtil::yn2tf($lm_rec["time_from_lms"]));
101  $this->setDebug(ilUtil::yn2tf($lm_rec["debug"]));
102  $this->setDebugPw($lm_rec["debugpw"]);
103  $this->setSequencingExpertMode($lm_rec["seq_exp_mode"]);
104  $this->setOpenMode($lm_rec["open_mode"]);
105  $this->setWidth($lm_rec["width"]);
106  $this->setHeight($lm_rec["height"]);
107  $this->setAutoContinue(ilUtil::yn2tf($lm_rec["auto_continue"]));
108  $this->setAuto_last_visited(ilUtil::yn2tf($lm_rec["auto_last_visited"]));
109  $this->setCheck_values(ilUtil::yn2tf($lm_rec["check_values"]));
110  $this->setOfflineMode(ilUtil::yn2tf($lm_rec["offline_mode"]));
111  $this->setAutoSuspend(ilUtil::yn2tf($lm_rec["auto_suspend"]));
112  $this->setIe_force_render(ilUtil::yn2tf($lm_rec["ie_force_render"]));
113  $this->setMasteryScore($lm_rec["mastery_score"]);
114  $this->setIdSetting($lm_rec["id_setting"]);
115  $this->setNameSetting($lm_rec["name_setting"]);
116 
117  include_once("./Services/Style/Content/classes/class.ilObjStyleSheet.php");
118  if (ilObject::_lookupType($this->getStyleSheetId()) != "sty") {
119  $this->setStyleSheetId(0);
120  }
121  }
122  }
123 
127  public static function _lookupOnline($a_id)
128  {
129  global $ilDB;
130 
131  $lm_set = $ilDB->queryF(
132  'SELECT c_online FROM sahs_lm WHERE id = %s',
133  array('integer'),
134  array($a_id)
135  );
136  $lm_rec = $ilDB->fetchAssoc($lm_set);
137 
138  return ilUtil::yn2tf($lm_rec["c_online"]);
139  }
140 
146  public static function getAffectiveLocalization($a_id)
147  {
148  global $ilDB, $lng;
149 
150  $lm_set = $ilDB->queryF(
151  'SELECT localization FROM sahs_lm WHERE id = %s',
152  array('integer'),
153  array($a_id)
154  );
155  $lm_rec = $ilDB->fetchAssoc($lm_set);
156  $inst_lang = $lng->getInstalledLanguages();
157  if ($lm_rec["localization"] != "" && in_array($lm_rec["localization"], $inst_lang)) {
158  return $lm_rec["localization"];
159  }
160  return $lng->getLangKey();
161  }
162 
168  public static function _lookupSubType($a_obj_id)
169  {
170  global $ilDB;
171 
172  $obj_set = $ilDB->queryF(
173  'SELECT c_type FROM sahs_lm WHERE id = %s',
174  array('integer'),
175  array($a_obj_id)
176  );
177  $obj_rec = $ilDB->fetchAssoc($obj_set);
178 
179  return $obj_rec["c_type"];
180  }
181 
187  public function setEditable($a_editable)
188  {
189  $this->editable = $a_editable;
190  }
191 
197  public function getEditable()
198  {
199  return $this->editable;
200  }
201 
202 
208  public function setTries($a_tries)
209  {
210  $this->tries = $a_tries;
211  }
212 
218  public function getTries()
219  {
220  return $this->tries;
221  }
222 
228  public function setLocalization($a_val)
229  {
230  $this->localization = $a_val;
231  }
232 
238  public function getLocalization()
239  {
240  return $this->localization;
241  }
242 
243  public static function _getTries($a_id)
244  {
245  global $ilDB;
246 
247  $lm_set = $ilDB->queryF(
248  'SELECT question_tries FROM sahs_lm WHERE id = %s',
249  array('integer'),
250  array($a_id)
251  );
252  $lm_rec = $ilDB->fetchAssoc($lm_set);
253 
254  return $lm_rec['question_tries'];
255  }
262  public function getDiskUsage()
263  {
264  require_once("./Modules/ScormAicc/classes/class.ilObjSAHSLearningModuleAccess.php");
266  }
267 
268 
273  public function createDataDirectory()
274  {
275  $lm_data_dir = ilUtil::getWebspaceDir() . "/lm_data";
276  ilUtil::makeDir($lm_data_dir);
278  }
279 
283  public function getDataDirectory($mode = "filesystem")
284  {
285  $lm_data_dir = ilUtil::getWebspaceDir($mode) . "/lm_data";
286  $lm_dir = $lm_data_dir . "/lm_" . $this->getId();
287 
288  return $lm_dir;
289  }
290 
294  public function getAPIAdapterName()
295  {
296  return $this->api_adapter;
297  }
298 
302  public function setAPIAdapterName($a_api)
303  {
304  $this->api_adapter = $a_api;
305  }
306 
310  public function getAPIFunctionsPrefix()
311  {
312  return $this->api_func_prefix;
313  }
314 
318  public function setAPIFunctionsPrefix($a_prefix)
319  {
320  $this->api_func_prefix = $a_prefix;
321  }
322 
326  public function getCreditMode()
327  {
328  return $this->credit_mode;
329  }
330 
334  public function setCreditMode($a_credit_mode)
335  {
336  $this->credit_mode = $a_credit_mode;
337  }
338 
342  public function setDefaultLessonMode($a_lesson_mode)
343  {
344  $this->lesson_mode = $a_lesson_mode;
345  }
346 
350  public function getDefaultLessonMode()
351  {
352  global $ilUser;
353  if ($ilUser->getId() == 13) {
354  return "browse";
355  }
356  return $this->lesson_mode;
357  }
361  public function getStyleSheetId()
362  {
363  return $this->style_id;
364  }
365 
369  public function setStyleSheetId($a_style_id)
370  {
371  $this->style_id = $a_style_id;
372  }
373 
374 
378  public function setAutoReview($a_auto_review)
379  {
380  $this->auto_review = ilUtil::tf2yn($a_auto_review);
381  }
385  public function getAutoReview()
386  {
387  return ilUtil::yn2tf($this->auto_review);
388  }
389 
393  public function setAutoReviewChar($a_auto_review)
394  {
395  $this->auto_review = $a_auto_review;
396  }
400  public function getAutoReviewChar()
401  {
402  return $this->auto_review;
403  }
404 
408  public function getMaxAttempt()
409  {
410  return $this->max_attempt;
411  }
412 
413 
417  public function setMaxAttempt($a_max_attempt)
418  {
419  $this->max_attempt = $a_max_attempt;
420  }
421 
425  public function getModuleVersion()
426  {
427  return $this->module_version;
428  }
429 
433  public function getAssignedGlossary()
434  {
435  return $this->assigned_glossary;
436  }
437 
441  public function setAssignedGlossary($a_assigned_glossary)
442  {
443  $this->assigned_glossary = $a_assigned_glossary;
444  }
448  public function setModuleVersion($a_module_version)
449  {
450  $this->module_version = $a_module_version;
451  }
452 
456  public function getSession()
457  {
458  return $this->session;
459  }
460 
464  public function setSession($a_session)
465  {
466  $this->session = $a_session;
467  }
468 
472  public function getNoMenu()
473  {
474  return $this->no_menu;
475  }
476 
480  public function setNoMenu($a_no_menu)
481  {
482  $this->no_menu = $a_no_menu;
483  }
484 
488  public function getHideNavig()
489  {
490  return $this->hide_navig;
491  }
492 
496  public function setHideNavig($a_hide_navig)
497  {
498  $this->hide_navig = $a_hide_navig;
499  }
500 
504  public function getCacheDeactivated()
505  {
506  global $ilSetting;
507  $lm_set = new ilSetting("lm");
508  if ($lm_set->get("scormdebug_disable_cache") == "1") {
509  return true;
510  }
511  return false;
512  }
513 
517  public function getSessionDeactivated()
518  {
519  global $ilSetting;
520  $lm_set = new ilSetting("lm");
521  if ($lm_set->get("scorm_without_session") == "1") {
522  return true;
523  }
524  return false;
525  }
526 
530  public function getDebugActivated()
531  {
532  global $ilSetting;
533  $lm_set = new ilSetting("lm");
534  if ($lm_set->get("scormdebug_global_activate") == "1") {
535  return true;
536  }
537  return false;
538  }
539 
543  public function getIe_force_render()
544  {
545  return $this->ie_force_render;
546  }
547 
548  public function setIe_force_render($a_ie_force_render)
549  {
550  $this->ie_force_render = $a_ie_force_render;
551  }
552 
556  public function getFourth_Edition()
557  {
558  return $this->fourth_edition;
559  }
560 
561  public function setFourth_edition($a_fourth_edition)
562  {
563  $this->fourth_edition = $a_fourth_edition;
564  }
565 
569  public function getSequencing()
570  {
571  return $this->sequencing;
572  }
573 
574  public function setSequencing($a_sequencing)
575  {
576  $this->sequencing = $a_sequencing;
577  }
578 
582  public function getInteractions()
583  {
584  return $this->interactions;
585  }
586 
587  public function setInteractions($a_interactions)
588  {
589  $this->interactions = $a_interactions;
590  }
591 
595  public function getObjectives()
596  {
597  return $this->objectives;
598  }
599 
600  public function setObjectives($a_objectives)
601  {
602  $this->objectives = $a_objectives;
603  }
604 
608  public function getComments()
609  {
610  return $this->comments;
611  }
612 
613  public function setComments($a_comments)
614  {
615  $this->comments = $a_comments;
616  }
617 
621  public function getTime_from_lms()
622  {
623  return $this->time_from_lms;
624  }
625 
626  public function setTime_from_lms($a_time_from_lms)
627  {
628  $this->time_from_lms = $a_time_from_lms;
629  }
630 
634  public function getCheck_values()
635  {
636  return $this->check_values;
637  }
638 
639  public function setCheck_values($a_check_values)
640  {
641  $this->check_values = $a_check_values;
642  }
643 
647  public function getOfflineMode()
648  {
649  return $this->offline_mode;
650  }
651 
652  public function setOfflineMode($a_offline_mode)
653  {
654  $this->offline_mode = $a_offline_mode;
655  }
656 
657 
661  public function getDebug()
662  {
663  return $this->debug;
664  }
665 
669  public function setDebug($a_debug)
670  {
671  $this->debug = $a_debug;
672  }
673 
677  public function getDebugPw()
678  {
679  return $this->debug_pw;
680  }
681 
685  public function setDebugPw($a_debug_pw)
686  {
687  $this->debug_pw = $a_debug_pw;
688  }
689 
693  public function setAutoContinue($a_auto_continue)
694  {
695  $this->auto_continue = $a_auto_continue;
696  }
700  public function getAutoContinue()
701  {
702  return $this->auto_continue;
703  }
704 
708  public function getAuto_last_visited()
709  {
710  return $this->auto_last_visited;
711  }
712 
713  public function setAuto_last_visited($a_auto_last_visited)
714  {
715  $this->auto_last_visited = $a_auto_last_visited;
716  }
717 
718 
724  public function setSequencingExpertMode($a_val)
725  {
726  $this->seq_exp_mode = $a_val;
727  }
728 
734  public function getSequencingExpertMode()
735  {
736  return $this->seq_exp_mode;
737  }
738 
742  public function setAutoSuspend($a_auto_suspend)
743  {
744  $this->auto_suspend = $a_auto_suspend;
745  }
749  public function getAutoSuspend()
750  {
751  return $this->auto_suspend;
752  }
753 
754 
765  public function getOpenMode()
766  {
767  return $this->open_mode;
768  }
769  public function setOpenMode($a_open_mode)
770  {
771  $this->open_mode = $a_open_mode;
772  }
773 
777  public function getWidth()
778  {
779  return $this->width;
780  }
781  public function setWidth($a_width)
782  {
783  $this->width = $a_width;
784  }
785 
789  public function getHeight()
790  {
791  return $this->height;
792  }
793  public function setHeight($a_height)
794  {
795  $this->height = $a_height;
796  }
797 
798 
802  public function getMasteryScore()
803  {
804  return $this->mastery_score;
805  }
806 
810  public function setMasteryScore($a_mastery_score)
811  {
812  $this->mastery_score = $a_mastery_score;
813  }
814 
818  public function checkMasteryScoreValues()
819  {
820  global $ilDB;
821  $s_result = "";
822  $a_result = array();
823  $type = $this->_lookupSubType($this->getID());
824 
825  if ($type == "scorm2004") {
826  $set = $ilDB->query("SELECT minnormalmeasure FROM cp_objective, cp_node" .
827  " WHERE satisfiedbymeasure=1 AND minnormalmeasure is not null AND cp_objective.cp_node_id=cp_node.cp_node_id AND" .
828  " slm_id = " . $ilDB->quote($this->getID(), "integer"));
829  while ($rec = $ilDB->fetchAssoc($set)) {
830  $tmpval = $rec["minnormalmeasure"]*100;
831  if (!in_array($tmpval, $a_result)) {
832  $a_result[] = $tmpval;
833  }
834  }
835  } else {
836  $set = $ilDB->query("SELECT masteryscore FROM sc_item,scorm_object" .
837  " WHERE sc_item.masteryscore is not null AND sc_item.obj_id=scorm_object.obj_id AND" .
838  " slm_id = " . $ilDB->quote($this->getID(), "integer"));
839  while ($rec = $ilDB->fetchAssoc($set)) {
840  if (!in_array($rec["masteryscore"], $a_result)) {
841  $a_result[] = $rec["masteryscore"];
842  }
843  }
844  }
845  $s_result = implode(", ", $a_result);
846  $this->mastery_score_values = $s_result;
847  }
848 
852  public function getMasteryScoreValues()
853  {
854  return $this->mastery_score_values;
855  }
856 
860  /*
861  function updateMasteryScoreValues()
862  {
863  global $ilDB;
864  $s_mastery_score = $this->getMasteryScore();
865  if ($s_mastery_score != "" && is_numeric($s_mastery_score)) {
866  $i_mastery_score = round(intval($s_mastery_score,10));
867  $type = $this->_lookupSubType( $this->getID() );
868 
869  if ($type == "scorm2004") {
870  if ($i_mastery_score > 100) $i_mastery_score = 100;
871  $i_mastery_score = $i_mastery_score/100;
872  $statement = $ilDB->manipulateF(
873  'UPDATE cp_objective,cp_node SET minnormalmeasure = %s
874  WHERE satisfiedbymeasure=1 AND minnormalmeasure is not null AND cp_objective.cp_node_id=cp_node.cp_node_id AND slm_id = %s',
875  array('text','integer'),
876  array($i_mastery_score,$this->getID())
877  );
878  } else {
879  if ($i_mastery_score > 127) $i_mastery_score = 127;
880  $statement = $ilDB->manipulateF(
881  'UPDATE sc_item,scorm_object SET sc_item.masteryscore = %s
882  WHERE sc_item.masteryscore is not null AND sc_item.obj_id=scorm_object.obj_id AND slm_id = %s',
883  array('integer','integer'),
884  array($i_mastery_score,$this->getID())
885  );
886  }
887  }
888  }
889  */
890 
894  /*
895  function updateMetaData()
896  {
897  $this->meta_data->update();
898  if ($this->meta_data->section != "General")
899  {
900  $meta = $this->meta_data->getElement("Title", "General");
901  $this->meta_data->setTitle($meta[0]["value"]);
902  $meta = $this->meta_data->getElement("Description", "General");
903  $this->meta_data->setDescription($meta[0]["value"]);
904  }
905  else
906  {
907  $this->setTitle($this->meta_data->getTitle());
908  $this->setDescription($this->meta_data->getDescription());
909  }
910  parent::update();
911 
912  }
913  */
914 
918  public function getIdSetting()
919  {
920  return $this->id_setting;
921  }
922 
926  public function setIdSetting($a_id_setting)
927  {
928  $this->id_setting = $a_id_setting;
929  }
930 
934  public function getNameSetting()
935  {
936  return $this->name_setting;
937  }
938 
942  public function setNameSetting($a_name_setting)
943  {
944  $this->name_setting = $a_name_setting;
945  }
946 
947 
948 
949 
956  public function update()
957  {
958  global $ilDB;
959 
960  $this->updateMetaData();
961  parent::update();
962 
963  $s_mastery_score = $this->getMasteryScore();
964  if ($s_mastery_score == "") {
965  $s_mastery_score = null;
966  }
967 
968  $statement = $ilDB->manipulateF(
969  '
970  UPDATE sahs_lm
971  SET c_online = %s,
972  api_adapter = %s,
973  api_func_prefix = %s,
974  auto_review = %s,
975  default_lesson_mode = %s,
976  c_type = %s,
977  stylesheet = %s,
978  editable = %s,
979  max_attempt = %s,
980  module_version = %s,
981  credit = %s,
982  glossary = %s,
983  question_tries = %s,
984  unlimited_session = %s,
985  no_menu = %s,
986  hide_navig = %s,
987  fourth_edition =%s,
988  sequencing = %s,
989  interactions = %s,
990  objectives = %s,
991  comments = %s,
992  time_from_lms = %s,
993  debug = %s,
994  localization = %s,
995  seq_exp_mode = %s,
996  debugpw = %s,
997  open_mode = %s,
998  width = %s,
999  height = %s,
1000  auto_continue = %s,
1001  auto_last_visited = %s,
1002  check_values = %s,
1003  offline_mode = %s,
1004  auto_suspend = %s,
1005  ie_force_render = %s,
1006  mastery_score = %s,
1007  id_setting = %s,
1008  name_setting = %s
1009  WHERE id = %s',
1010  array( 'text',
1011  'text',
1012  'text',
1013  'text',
1014  'text',
1015  'text',
1016  'integer',
1017  'integer',
1018  'integer',
1019  'integer',
1020  'text',
1021  'integer',
1022  'integer',
1023  'text',
1024  'text',
1025  'text',
1026  'text',
1027  'text',
1028  'text',
1029  'text',
1030  'text',
1031  'text',
1032  'text',
1033  'text',
1034  'integer',
1035  'text',
1036  'integer',
1037  'integer',
1038  'integer',
1039  'text',
1040  'text',
1041  'text',
1042  'text',
1043  'text',
1044  'text',
1045  'integer',
1046  'integer',
1047  'integer',
1048  'integer'
1049  ),
1050  array( ilUtil::tf2yn($this->getOnline()),
1051  $this->getAPIAdapterName(),
1052  $this->getAPIFunctionsPrefix(),
1053  $this->getAutoReviewChar(),
1054  $this->getDefaultLessonMode(),
1055  $this->getSubType(),
1056  $this->getStyleSheetId(),
1057  $this->getEditable(),
1058  $this->getMaxAttempt(),
1059  $this->getModuleVersion(),
1060  $this->getCreditMode(),
1061  $this->getAssignedGlossary(),
1062  $this->getTries(),
1063  ilUtil::tf2yn($this->getSession()),
1064  ilUtil::tf2yn($this->getNoMenu()),
1065  ilUtil::tf2yn($this->getHideNavig()),
1066  ilUtil::tf2yn($this->getFourth_edition()),
1067  ilUtil::tf2yn($this->getSequencing()),
1068  ilUtil::tf2yn($this->getInteractions()),
1069  ilUtil::tf2yn($this->getObjectives()),
1070  ilUtil::tf2yn($this->getComments()),
1071  ilUtil::tf2yn($this->getTime_from_lms()),
1072  ilUtil::tf2yn($this->getDebug()),
1073  $this->getLocalization(),
1074  $this->getSequencingExpertMode(),
1075  $this->getDebugPw(),
1076  $this->getOpenMode(),
1077  $this->getWidth(),
1078  $this->getHeight(),
1079  ilUtil::tf2yn($this->getAutoContinue()),
1081  ilUtil::tf2yn($this->getCheck_values()),
1082  ilUtil::tf2yn($this->getOfflineMode()),
1083  ilUtil::tf2yn($this->getAutoSuspend()),
1085  $s_mastery_score,
1086  $this->getIdSetting(),
1087  $this->getNameSetting(),
1088  $this->getId())
1089  );
1090 
1091  return true;
1092  }
1093 
1100  public static function getScormModulesForGlossary($a_glo_id)
1101  {
1102  global $ilDB;
1103 
1104  $set = $ilDB->query("SELECT DISTINCT id FROM sahs_lm WHERE " .
1105  " glossary = " . $ilDB->quote($a_glo_id, "integer"));
1106  $sms = array();
1107  while ($rec = $ilDB->fetchAssoc($set)) {
1108  if (ilObject::_hasUntrashedReference($rec["id"])) {
1109  $sms[] = $rec["id"];
1110  }
1111  }
1112  return $sms;
1113  }
1114 
1121  public static function lookupAssignedGlossary($a_slm_id)
1122  {
1123  global $ilDB;
1124 
1125  $set = $ilDB->query("SELECT DISTINCT glossary FROM sahs_lm WHERE " .
1126  " id = " . $ilDB->quote($a_slm_id, "integer"));
1127  $rec = $ilDB->fetchAssoc($set);
1128  $glo_id = $rec["glossary"];
1129  if (ilObject::_lookupType($glo_id) == "glo") {
1130  return $glo_id;
1131  }
1132  return 0;
1133  }
1134 
1138  public function setOnline($a_online)
1139  {
1140  $this->online = $a_online;
1141  }
1142 
1146  public function getOnline()
1147  {
1148  return $this->online;
1149  }
1150 
1154  public function setSubType($a_sub_type)
1155  {
1156  $this->sub_type = $a_sub_type;
1157  }
1158 
1162  public function getSubType()
1163  {
1164  return $this->sub_type;
1165  }
1166 
1178  public function delete()
1179  {
1180  global $ilDB, $ilLog;
1181 
1182  // always call parent delete function first!!
1183  if (!parent::delete()) {
1184  return false;
1185  }
1186 
1187  // delete meta data of scorm content object
1188  $this->deleteMetaData();
1189 
1190  // delete data directory
1191  ilUtil::delDir($this->getDataDirectory());
1192 
1193  // delete scorm learning module record
1194  $ilDB->manipulateF(
1195  'DELETE FROM sahs_lm WHERE id = %s',
1196  array('integer'),
1197  array($this->getId())
1198  );
1199 
1200  $ilLog->write("SAHS Delete(SAHSLM), Subtype: " . $this->getSubType());
1201 
1202  if ($this->getSubType() == "scorm") {
1203  // remove all scorm objects and scorm tree
1204  include_once("./Modules/ScormAicc/classes/SCORM/class.ilSCORMTree.php");
1205  include_once("./Modules/ScormAicc/classes/SCORM/class.ilSCORMObject.php");
1206  $sc_tree = new ilSCORMTree($this->getId());
1207  $r_id = $sc_tree->readRootId();
1208  if ($r_id > 0) {
1209  $items = $sc_tree->getSubTree($sc_tree->getNodeData($r_id));
1210  foreach ($items as $item) {
1211  $sc_object = ilSCORMObject::_getInstance($item["obj_id"], $this->getId());
1212  if (is_object($sc_object)) {
1213  $sc_object->delete();
1214  }
1215  }
1216  $sc_tree->removeTree($sc_tree->getTreeId());
1217  }
1218  }
1219 
1220  if ($this->getSubType() != "scorm") {
1221  // delete aicc data
1222  $res = $ilDB->queryF(
1223  '
1224  SELECT aicc_object.obj_id FROM aicc_object, aicc_units
1225  WHERE aicc_object.obj_id = aicc_units.obj_id
1226  AND aicc_object.slm_id = %s',
1227  array('integer'),
1228  array($this->getId())
1229  );
1230 
1231  while ($row = $ilDB->fetchAssoc($res)) {
1232  $obj_id = $row['obj_id'];
1233  $ilDB->manipulateF(
1234  '
1235  DELETE FROM aicc_units WHERE obj_id = %s',
1236  array('integer'),
1237  array($obj_id)
1238  );
1239  }
1240 
1241  $res = $ilDB->queryF(
1242  '
1243  SELECT aicc_object.obj_id FROM aicc_object, aicc_course
1244  WHERE aicc_object.obj_id = aicc_course.obj_id
1245  AND aicc_object.slm_id = %s',
1246  array('integer'),
1247  array($this->getId())
1248  );
1249 
1250  while ($row = $ilDB->fetchAssoc($res)) {
1251  $obj_id = $row['obj_id'];
1252  $ilDB->manipulateF(
1253  '
1254  DELETE FROM aicc_course WHERE obj_id = %s',
1255  array('integer'),
1256  array($obj_id)
1257  );
1258  }
1259 
1260  $ilDB->manipulateF(
1261  '
1262  DELETE FROM aicc_object WHERE slm_id = %s',
1263  array('integer'),
1264  array($this->getId())
1265  );
1266  }
1267 
1268  $q_log = "DELETE FROM scorm_tracking WHERE obj_id = " . $ilDB->quote($this->getId());
1269  $ilLog->write("SAHS Delete(SAHSLM): " . $q_log);
1270 
1271  $ilDB->manipulateF(
1272  'DELETE FROM scorm_tracking WHERE obj_id = %s',
1273  array('integer'),
1274  array($this->getId())
1275  );
1276 
1277  $q_log = "DELETE FROM sahs_user WHERE obj_id = " . $ilDB->quote($this->getId());
1278  $ilLog->write("SAHS Delete(SAHSLM): " . $q_log);
1279 
1280  $ilDB->manipulateF(
1281  'DELETE FROM sahs_user WHERE obj_id = %s',
1282  array('integer'),
1283  array($this->getId())
1284  );
1285 
1286  // always call parent delete function at the end!!
1287  return true;
1288  }
1289 
1295  public function getPointsInPercent()
1296  {
1297  global $ilUser;
1298  if (strcmp($this->getSubType(), "scorm2004") == 0) {
1300  if (!is_null($res)) {
1301  return $res * 100.0;
1302  } else {
1303  return $res;
1304  }
1305  } else {
1306  return null;
1307  }
1308  }
1309 
1320  public function getMaxPoints()
1321  {
1322  global $ilUser;
1323 
1324  if (strcmp($this->getSubType(), 'scorm2004') == 0) {
1325  $res = ilObjSCORM2004LearningModule::_getMaxScoreForUser($this->getId(), $ilUser->getId());
1326  return $res;
1327  } else {
1328  return null;
1329  }
1330  }
1331 
1341  public function populateByDirectoy($a_dir, $a_filename = "")
1342  {
1343  /*preg_match("/.*sahs_([0-9]*)\.zip/", $a_filename, $match);
1344  if (is_dir($a_dir."/sahs_".$match[1]))
1345  {
1346  $a_dir = $a_dir."/sahs_".$match[1];
1347  }*/
1348  ilUtil::rCopy($a_dir, $this->getDataDirectory());
1350  }
1351 
1352 
1359  public function cloneObject($a_target_id, $a_copy_id = 0, $a_omit_tree = false)
1360  {
1361  global $ilDB, $ilUser, $ilias, $lng;
1362 
1363  $new_obj = parent::cloneObject($a_target_id, $a_copy_id, $a_omit_tree);
1364  $this->cloneMetaData($new_obj);
1365 
1366  //copy online status if object is not the root copy object
1367  $cp_options = ilCopyWizardOptions::_getInstance($a_copy_id);
1368 
1369  if (!$cp_options->isRootNode($this->getRefId())) {
1370  $new_obj->setOnline($this->getOnline());
1371  }
1372 
1373  // copy properties
1374  // $new_obj->setTitle($this->getTitle() . ' ' . $lng->txt('copy_of_suffix'));
1375  $new_obj->setDescription($this->getDescription());
1376  $new_obj->setSubType($this->getSubType());
1377  $new_obj->setAPIAdapterName($this->getAPIAdapterName());
1378  $new_obj->setAPIFunctionsPrefix($this->getAPIFunctionsPrefix());
1379  $new_obj->setAutoReviewChar($this->getAutoReviewChar());
1380  $new_obj->setDefaultLessonMode($this->getDefaultLessonMode());
1381  $new_obj->setEditable($this->getEditable());
1382  $new_obj->setMaxAttempt($this->getMaxAttempt());
1383  $new_obj->setModuleVersion($this->getModuleVersion());
1384  $new_obj->setModuleVersion(1);
1385  $new_obj->setCreditMode($this->getCreditMode());
1386  $new_obj->setAssignedGlossary($this->getAssignedGlossary());
1387  $new_obj->setTries($this->getTries());
1388  $new_obj->setSession($this->getSession());
1389  $new_obj->setNoMenu($this->getNoMenu());
1390  $new_obj->setHideNavig($this->getHideNavig());
1391  $new_obj->setFourth_edition($this->getFourth_edition());
1392  $new_obj->setSequencing($this->getSequencing());
1393  $new_obj->setInteractions($this->getInteractions());
1394  $new_obj->setObjectives($this->getObjectives());
1395  $new_obj->setComments($this->getComments());
1396  $new_obj->setTime_from_lms($this->getTime_from_lms());
1397  $new_obj->setDebug($this->getDebug());
1398  $new_obj->setLocalization($this->getLocalization());
1399  $new_obj->setSequencingExpertMode($this->getSequencingExpertMode());
1400  $new_obj->setDebugPw($this->getDebugPw());
1401  $new_obj->setOpenMode($this->getOpenMode());
1402  $new_obj->setWidth($this->getWidth());
1403  $new_obj->setHeight($this->getHeight());
1404  $new_obj->setAutoContinue($this->getAutoContinue());
1405  $new_obj->setAuto_last_visited($this->getAuto_last_visited());
1406  $new_obj->setCheck_values($this->getCheck_values());
1407  $new_obj->setOfflineMode($this->getOfflineMode());
1408  $new_obj->setAutoSuspend($this->getAutoSuspend());
1409  $new_obj->setIe_force_render($this->getIe_force_render());
1410  $new_obj->setStyleSheetId($this->getStyleSheetId());
1411  $new_obj->update();
1412 
1413 
1414  // set/copy stylesheet
1415  /* include_once("./Services/Style/Content/classes/class.ilObjStyleSheet.php");
1416  $style_id = $this->getStyleSheetId();
1417  if ($style_id > 0 && !ilObjStyleSheet::_lookupStandard($style_id))
1418  {
1419  $style_obj = $ilias->obj_factory->getInstanceByObjId($style_id);
1420  $new_id = $style_obj->ilClone();
1421  $new_obj->setStyleSheetId($new_id);
1422  $new_obj->update();
1423  }*/
1424 
1425  // up to this point $new_obj is of type ilobjsahslearning module
1426 
1427  // create instance of correct subtype and call forward it to
1428  // cloneIntoNewObject method
1429  switch ($this->getSubType()) {
1430  case "scorm":
1431  include_once("./Modules/ScormAicc/classes/class.ilObjSCORMLearningModule.php");
1432  $source_obj = new ilObjSCORMLearningModule($this->getRefId());
1433  $new_obj = new ilObjSCORMLearningModule($new_obj->getRefId());
1434  break;
1435 
1436  case "scorm2004":
1437  include_once("./Modules/Scorm2004/classes/class.ilObjSCORM2004LearningModule.php");
1438  $source_obj = new ilObjSCORM2004LearningModule($this->getRefId());
1439  $new_obj = new ilObjSCORM2004LearningModule($new_obj->getRefId());
1440  break;
1441  }
1442 
1443  // copy data directory
1444  $new_obj->populateByDirectoy($source_obj->getDataDirectory());
1445 
1446  // copy authored content ...
1447  if ($new_obj->getEditable()) {
1448  $source_obj->copyAuthoredContent($new_obj);
1449  } else {
1450  // ... or read manifest file
1451  $new_obj->readObject();
1452  }
1453 
1454  // Copy learning progress settings (Mantis #0022964)
1455  include_once('Services/Tracking/classes/class.ilLPObjSettings.php');
1456  $obj_settings = new ilLPObjSettings($this->getId());
1457  $obj_settings->cloneSettings($new_obj->getId());
1458 
1459  include_once('Services/Object/classes/class.ilObjectLP.php');
1461  $olp = ilObjectLP::getInstance($this->getId());
1462  $collection = $olp->getCollectionInstance();
1463  if ($collection) {
1464  $collection->cloneCollection($new_obj->getRefId(), $cp_options->getCopyId());
1465  }
1466  return $new_obj;
1467  }
1468 
1469  public function zipLmForOfflineMode()
1470  {
1471  $lmDir=ilUtil::getWebspaceDir("filesystem") . "/lm_data/lm_" . $this->getId();
1472  $zipFile=ilUtil::getDataDir() . "/lm_data/lm_" . $this->getId();
1473  return ilUtil::zip($lmDir, $zipFile, true);
1474  }
1475 
1479  public function getApiStudentId()
1480  {
1481  global $ilias;
1482  $idSetting = $this->getIdSetting();
1483  $studentId = $ilias->account->getId();
1484  if ($idSetting%2 == 1) {
1485  $studentId = $ilias->account->getLogin();
1486  }
1487  if ($idSetting > 3) {
1488  $studentId .= '_o_' . $this->getId();
1489  } elseif ($idSetting > 1) {
1490  $studentId .= '_r_' . $_GET["ref_id"];
1491  }
1492  return $studentId;
1493  }
1494 
1499  public function getApiStudentName()
1500  {
1501  global $ilias, $lng;
1502  $studentName = " ";
1503  switch ($this->getNameSetting()) {
1504  case 0:
1505  $studentName = $ilias->account->getLastname() . ', ' . $ilias->account->getFirstname();
1506  break;
1507  case 1:
1508  $studentName = $ilias->account->getFirstname() . ' ' . $ilias->account->getLastname();
1509  break;
1510  case 2:
1511  $studentName = $ilias->account->getFullname();
1512  break;
1513  case 3:
1514  switch ($ilias->account->getGender()) {
1515  case 'f':
1516  $studentName = $lng->txt('salutation_f');
1517  break;
1518 
1519  case 'm':
1520  $studentName = $lng->txt('salutation_m');
1521  break;
1522 
1523  case 'n':
1524  $studentName = $lng->txt('salutation_n');
1525  break;
1526 
1527  default:
1528  $studentName = $lng->txt('salutation');
1529  }
1530  $studentName .= ' ' . $ilias->account->getLastname();
1531  break;
1532  case 4:
1533  $studentName = $ilias->account->getFirstname();
1534  break;
1535  }
1536  return $studentName;
1537  }
1538 
1542  public function getViewButton()
1543  {
1544  $setUrl = "ilias.php?baseClass=ilSAHSPresentationGUI&amp;ref_id=" . $this->getRefID();
1545  // $setUrl = $this->getLinkTargetByClass("ilsahspresentationgui", "")."&amp;ref_id=".$this->getRefID();
1546  $setTarget = "ilContObj" . $this->getId();
1547  $om = $this->getOpenMode();
1548  $width = $this->getWidth();
1549  $height = $this->getHeight();
1550  if (($om == 5 || $om == 1) && $width > 0 && $height > 0) {
1551  $om++;
1552  }
1553  if ($om != 0) {
1554  $setUrl = "javascript:void(0); onclick=startSAHS('" . $setUrl . "','ilContObj" . $this->getId() . "'," . $om . "," . $width . "," . $height . ");";
1555  $setTarget = "";
1556  }
1557  include_once "Services/UIComponent/Button/classes/class.ilLinkButton.php";
1558  $button = ilLinkButton::getInstance();
1559  $button->setCaption("view");
1560  $button->setPrimary(true);
1561  $button->setUrl($setUrl);
1562  $button->setTarget($setTarget);
1563  return $button;
1564  }
1565 }
getSequencingExpertMode()
Get sequencing expert mode.
getStyleSheetId()
get ID of assigned style sheet object
static tf2yn($a_tf)
convert true/false to "y"/"n"
getFourth_Edition()
SCORM 2004 4th edition features.
static lookupAssignedGlossary($a_slm_id)
Get SCORM modules that assign a certain glossary.
static _hasUntrashedReference($a_obj_id)
checks wether an object has at least one reference that is not in trash
getDiskUsage()
Gets the disk usage of the object in bytes.
static _lookupOnline($a_id)
check wether scorm module is online
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
getSessionDeactivated()
sessionDisabled for SCORM 2004
setCreditMode($a_credit_mode)
set credit mode
setAPIFunctionsPrefix($a_prefix)
set api functions prefix
$session
setSubType($a_sub_type)
get sub type
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
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
static _lookupDiskUsage($a_id)
Returns the number of bytes used on the harddisk by the learning module with the specified object id...
createDataDirectory()
creates data directory for package files ("./data/lm_data/lm_<id>")
setAutoContinue($a_auto_continue)
get auto continue
setIdSetting($a_id_setting)
set id_setting
create($upload=false)
create file based lm
populateByDirectoy($a_dir, $a_filename="")
Populate by directory.
static _lookupSubType($a_obj_id)
lookup subtype id (scorm, )
setAutoReview($a_auto_review)
set auto review as true/false for SCORM 1.2
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.
static _getInstance($a_copy_id)
Get instance of copy wizard options.
foreach($_POST as $key=> $value) $res
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)
static _getUniqueScaledScoreForUser($a_id, $a_user)
Get the Unique Scaled Score of a course Conditions: Only one SCO may set cmi.score.scaled.
getDescription()
get object description
getApiStudentId()
Get cmi.core.student_id / cmi.learner_id for API.
$ilUser
Definition: imgupload.php:18
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
Create styles array
The data for the language used.
static _lookupType($a_id, $a_reference=false)
lookup object type
setSession($a_session)
set session setting
getApiStudentName()
Get cmi.core.student_name / cmi.learner_name for API note: &#39;lastname, firstname&#39; is required for SCOR...
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.
setNameSetting($a_name_setting)
set name_setting
update($pash, $contents, Config $config)
$debug
Definition: loganalyzer.php:16
static getScormModulesForGlossary($a_glo_id)
Get SCORM modules that assign a certain glossary.
static getDataDir()
get data directory (outside webspace)
$lm_set
getPointsInPercent()
Returns the points in percent for the learning module This is called by the certificate generator if ...
static renameExecutables($a_dir)
Rename uploaded executables for security reasons.
setAPIAdapterName($a_api)
set api adapter name
global $ilSetting
Definition: privfeed.php:17
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
static getAffectiveLocalization($a_id)
Get affective localization.
setDefaultLessonMode($a_lesson_mode)
set default lesson mode
static getInstance($a_obj_id)
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
Add comments
setAssignedGlossary($a_assigned_glossary)
set assigned glossary
Class ilObjSCORMLearningModule.
static & _getInstance($a_id, $a_slm_id)
get instance of specialized GUI class
setMaxAttempt($a_max_attempt)
set max attempt
setModuleVersion($a_module_version)
set max attempt
Class ilObjSCORMLearningModule.
getCacheDeactivated()
BrowserCacheDisabled for SCORM 2004 / ENABLE_JS_DEBUG.
getIdSetting()
update values for mastery_score / min_normalized_measure in database - not requested ...
__construct($a_id=0, $a_call_by_reference=true)
Constructor public.