Go to the documentation of this file.00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 require_once "classes/class.ilObject.php";
00026 require_once "./Modules/ScormAicc/classes/class.ilObjSCORMValidator.php";
00027
00028
00040 class ilObjSAHSLearningModule extends ilObject
00041 {
00042 var $validator;
00043
00044
00051 function ilObjSAHSLearningModule($a_id = 0, $a_call_by_reference = true)
00052 {
00053 $this->type = "sahs";
00054 parent::ilObject($a_id,$a_call_by_reference);
00055
00056 }
00057
00061 function create()
00062 {
00063 global $ilDB;
00064
00065 parent::create();
00066 $this->createMetaData();
00067
00068 $this->createDataDirectory();
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082 $q = "INSERT INTO sahs_lm (id, online, api_adapter, type) VALUES ".
00083 " (".$ilDB->quote($this->getID()).",".$ilDB->quote("n").",".
00084 $ilDB->quote("API").",".$ilDB->quote($this->getSubType()).")";
00085 $ilDB->query($q);
00086 }
00087
00091 function read()
00092 {
00093 global $ilDB;
00094
00095 parent::read();
00096 $q = "SELECT * FROM sahs_lm WHERE id = ".$ilDB->quote($this->getId());
00097 $lm_set = $this->ilias->db->query($q);
00098 $lm_rec = $lm_set->fetchRow(DB_FETCHMODE_ASSOC);
00099 $this->setOnline(ilUtil::yn2tf($lm_rec["online"]));
00100 $this->setAutoReview(ilUtil::yn2tf($lm_rec["auto_review"]));
00101 $this->setAPIAdapterName($lm_rec["api_adapter"]);
00102 $this->setDefaultLessonMode($lm_rec["default_lesson_mode"]);
00103 $this->setAPIFunctionsPrefix($lm_rec["api_func_prefix"]);
00104 $this->setCreditMode($lm_rec["credit"]);
00105 $this->setSubType($lm_rec["type"]);
00106 }
00107
00111 function _lookupOnline($a_id)
00112 {
00113 global $ilDB;
00114
00115 $q = "SELECT * FROM sahs_lm WHERE id = ".$ilDB->quote($a_id);
00116 $lm_set = $this->ilias->db->query($q);
00117 $lm_rec = $lm_set->fetchRow(DB_FETCHMODE_ASSOC);
00118
00119 return ilUtil::yn2tf($lm_rec["online"]);
00120 }
00121
00127 function _lookupSubType($a_obj_id)
00128 {
00129 global $ilDB;
00130
00131 $q = "SELECT * FROM sahs_lm WHERE id = ".$ilDB->quote($a_obj_id);
00132 $obj_set = $ilDB->query($q);
00133 $obj_rec = $obj_set->fetchRow(DB_FETCHMODE_ASSOC);
00134
00135 return $obj_rec["type"];
00136 }
00137
00143
00144
00145
00146
00147
00148
00149
00155
00156
00157
00158
00159
00160
00161
00162
00168
00169
00170
00171
00172
00173
00174
00180
00181
00182
00183
00184
00185
00186
00192
00193
00194
00195
00196
00197
00198
00204
00205
00206
00207
00208
00209
00210
00211
00216 function createDataDirectory()
00217 {
00218 $lm_data_dir = ilUtil::getWebspaceDir()."/lm_data";
00219 ilUtil::makeDir($lm_data_dir);
00220 ilUtil::makeDir($this->getDataDirectory());
00221 }
00222
00226 function getDataDirectory($mode = "filesystem")
00227 {
00228 $lm_data_dir = ilUtil::getWebspaceDir($mode)."/lm_data";
00229 $lm_dir = $lm_data_dir."/lm_".$this->getId();
00230
00231 return $lm_dir;
00232 }
00233
00237 function getAPIAdapterName()
00238 {
00239 return $this->api_adapter;
00240 }
00241
00245 function setAPIAdapterName($a_api)
00246 {
00247 $this->api_adapter = $a_api;
00248 }
00249
00253 function getAPIFunctionsPrefix()
00254 {
00255 return $this->api_func_prefix;
00256 }
00257
00261 function setAPIFunctionsPrefix($a_prefix)
00262 {
00263 $this->api_func_prefix = $a_prefix;
00264 }
00265
00269 function getCreditMode()
00270 {
00271 return $this->credit_mode;
00272 }
00273
00277 function setCreditMode($a_credit_mode)
00278 {
00279 $this->credit_mode = $a_credit_mode;
00280 }
00281
00285 function setDefaultLessonMode($a_lesson_mode)
00286 {
00287 $this->lesson_mode = $a_lesson_mode;
00288 }
00289
00293 function getDefaultLessonMode()
00294 {
00295 return $this->lesson_mode;
00296 }
00297
00301 function setAutoReview($a_auto_review)
00302 {
00303 $this->auto_review = $a_auto_review;
00304 }
00305
00309 function getAutoReview()
00310 {
00311 return $this->auto_review;
00312 }
00313
00317
00318
00319
00320
00321
00322
00323
00324
00325
00326
00327
00328
00329
00330
00331
00332
00333
00334
00335
00336
00337
00338
00345 function update()
00346 {
00347 global $ilDB;
00348
00349 $this->updateMetaData();
00350 parent::update();
00351
00352 $q = "UPDATE sahs_lm SET ".
00353 " online = ".$ilDB->quote(ilUtil::tf2yn($this->getOnline())).",".
00354 " api_adapter = ".$ilDB->quote($this->getAPIAdapterName()).",".
00355 " api_func_prefix = ".$ilDB->quote($this->getAPIFunctionsPrefix()).",".
00356 " auto_review = ".$ilDB->quote(ilUtil::tf2yn($this->getAutoReview())).",".
00357 " default_lesson_mode = ".$ilDB->quote($this->getDefaultLessonMode()).",".
00358 " type = ".$ilDB->quote($this->getSubType()).",".
00359 " credit = ".$ilDB->quote($this->getCreditMode())."".
00360 " WHERE id = ".$ilDB->quote($this->getId());
00361 $this->ilias->db->query($q);
00362
00363 return true;
00364 }
00365
00369 function setOnline($a_online)
00370 {
00371 $this->online = $a_online;
00372 }
00373
00377 function getOnline()
00378 {
00379 return $this->online;
00380 }
00381
00385 function setSubType($a_sub_type)
00386 {
00387 $this->sub_type = $a_sub_type;
00388 }
00389
00393 function getSubType()
00394 {
00395 return $this->sub_type;
00396 }
00397
00409 function delete()
00410 {
00411 global $ilDB, $ilLog;
00412
00413
00414 if (!parent::delete())
00415 {
00416 return false;
00417 }
00418
00419
00420
00421
00422
00423
00424
00425 $this->deleteMetaData();
00426
00427
00428 ilUtil::delDir($this->getDataDirectory());
00429
00430
00431 $q = "DELETE FROM sahs_lm WHERE id = ".$ilDB->quote($this->getId());
00432 $this->ilias->db->query($q);
00433 $ilLog->write("SAHS Delete(SAHSLM), Subtype: ".$this->getSubType());
00434
00435 if ($this->getSubType() == "scorm")
00436 {
00437
00438 include_once("./Modules/ScormAicc/classes/SCORM/class.ilSCORMTree.php");
00439 include_once("./Modules/ScormAicc/classes/SCORM/class.ilSCORMObject.php");
00440 $sc_tree = new ilSCORMTree($this->getId());
00441 $r_id = $sc_tree->readRootId();
00442 if ($r_id > 0)
00443 {
00444 $items = $sc_tree->getSubTree($sc_tree->getNodeData($r_id));
00445 foreach($items as $item)
00446 {
00447 $sc_object =& ilSCORMObject::_getInstance($item["obj_id"], $this->getId());
00448 if (is_object($sc_object))
00449 {
00450 $sc_object->delete();
00451 }
00452 }
00453 $sc_tree->removeTree($sc_tree->getTreeId());
00454 }
00455 }
00456
00457 if ($this->getSubType() != "scorm")
00458 {
00459
00460
00461 $q = "DELETE FROM aicc_units USING aicc_object, aicc_units WHERE aicc_object.obj_id=aicc_units.obj_id and aicc_object.slm_id=".$ilDB->quote($this->getId());
00462 $this->ilias->db->query($q);
00463
00464 $q = "DELETE FROM aicc_course USING aicc_object, aicc_course WHERE aicc_object.obj_id=aicc_course.obj_id and aicc_object.slm_id=".$ilDB->quote($this->getId());
00465 $this->ilias->db->query($q);
00466
00467 $q = "DELETE FROM aicc_object WHERE slm_id = ".$ilDB->quote($this->getId());
00468 $this->ilias->db->query($q);
00469 }
00470
00471 $q = "DELETE FROM scorm_tracking WHERE obj_id = ".$ilDB->quote($this->getId());
00472 $ilLog->write("SAHS Delete(SAHSLM): ".$q);
00473 $this->ilias->db->query($q);
00474
00475
00476 return true;
00477 }
00478
00489 function notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params = 0)
00490 {
00491 global $tree;
00492
00493 switch ($a_event)
00494 {
00495 case "link":
00496
00497
00498
00499
00500 break;
00501
00502 case "cut":
00503
00504
00505
00506 break;
00507
00508 case "copy":
00509
00510
00511
00512
00513 break;
00514
00515 case "paste":
00516
00517
00518
00519 break;
00520
00521 case "new":
00522
00523
00524
00525 break;
00526 }
00527
00528
00529 if ($a_node_id==$_GET["ref_id"])
00530 {
00531 $parent_obj =& $this->ilias->obj_factory->getInstanceByRefId($a_node_id);
00532 $parent_type = $parent_obj->getType();
00533 if($parent_type == $this->getType())
00534 {
00535 $a_node_id = (int) $tree->getParentId($a_node_id);
00536 }
00537 }
00538
00539 parent::notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params);
00540 }
00541
00542 }
00543 ?>