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 "content/classes/class.ilObjSCORMValidator.php";
00027
00028
00038 class ilObjSAHSLearningModule extends ilObject
00039 {
00040 var $validator;
00041
00042
00049 function ilObjSAHSLearningModule($a_id = 0, $a_call_by_reference = true)
00050 {
00051 $this->type = "sahs";
00052 parent::ilObject($a_id,$a_call_by_reference);
00053 if ($a_id == 0)
00054 {
00055
00056
00057
00058
00059 }
00060
00061 }
00062
00066 function create()
00067 {
00068 global $ilDB;
00069
00070 parent::create();
00071 $this->createMetaData();
00072
00073 $this->createDataDirectory();
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087 $q = "INSERT INTO sahs_lm (id, online, api_adapter, type) VALUES ".
00088 " (".$ilDB->quote($this->getID()).",".$ilDB->quote("n").",".
00089 $ilDB->quote("API").",".$ilDB->quote($this->getSubType()).")";
00090 $ilDB->query($q);
00091 }
00092
00096 function read()
00097 {
00098 parent::read();
00099
00100
00101 $q = "SELECT * FROM sahs_lm WHERE id = '".$this->getId()."'";
00102 $lm_set = $this->ilias->db->query($q);
00103 $lm_rec = $lm_set->fetchRow(DB_FETCHMODE_ASSOC);
00104 $this->setOnline(ilUtil::yn2tf($lm_rec["online"]));
00105 $this->setAutoReview(ilUtil::yn2tf($lm_rec["auto_review"]));
00106 $this->setAPIAdapterName($lm_rec["api_adapter"]);
00107 $this->setDefaultLessonMode($lm_rec["default_lesson_mode"]);
00108 $this->setAPIFunctionsPrefix($lm_rec["api_func_prefix"]);
00109 $this->setCreditMode($lm_rec["credit"]);
00110 $this->setSubType($lm_rec["type"]);
00111 }
00112
00116 function _lookupOnline($a_id)
00117 {
00118 $q = "SELECT * FROM sahs_lm WHERE id = '".$a_id."'";
00119 $lm_set = $this->ilias->db->query($q);
00120 $lm_rec = $lm_set->fetchRow(DB_FETCHMODE_ASSOC);
00121
00122 return ilUtil::yn2tf($lm_rec["online"]);
00123 }
00124
00130 function _lookupSubType($a_obj_id)
00131 {
00132 global $ilDB;
00133
00134 $q = "SELECT * FROM sahs_lm WHERE id = '".$a_obj_id."'";
00135 $obj_set = $ilDB->query($q);
00136 $obj_rec = $obj_set->fetchRow(DB_FETCHMODE_ASSOC);
00137
00138 return $obj_rec["type"];
00139 }
00140
00146
00147
00148
00149
00150
00151
00152
00158
00159
00160
00161
00162
00163
00164
00165
00171
00172
00173
00174
00175
00176
00177
00183
00184
00185
00186
00187
00188
00189
00195
00196
00197
00198
00199
00200
00201
00207
00208
00209
00210
00211
00212
00213
00214
00219 function createDataDirectory()
00220 {
00221 $lm_data_dir = ilUtil::getWebspaceDir()."/lm_data";
00222 ilUtil::makeDir($lm_data_dir);
00223 ilUtil::makeDir($this->getDataDirectory());
00224 }
00225
00229 function getDataDirectory($mode = "filesystem")
00230 {
00231 $lm_data_dir = ilUtil::getWebspaceDir($mode)."/lm_data";
00232 $lm_dir = $lm_data_dir."/lm_".$this->getId();
00233
00234 return $lm_dir;
00235 }
00236
00240 function getAPIAdapterName()
00241 {
00242 return $this->api_adapter;
00243 }
00244
00248 function setAPIAdapterName($a_api)
00249 {
00250 $this->api_adapter = $a_api;
00251 }
00252
00256 function getAPIFunctionsPrefix()
00257 {
00258 return $this->api_func_prefix;
00259 }
00260
00264 function setAPIFunctionsPrefix($a_prefix)
00265 {
00266 $this->api_func_prefix = $a_prefix;
00267 }
00268
00272 function getCreditMode()
00273 {
00274 return $this->credit_mode;
00275 }
00276
00280 function setCreditMode($a_credit_mode)
00281 {
00282 $this->credit_mode = $a_credit_mode;
00283 }
00284
00288 function setDefaultLessonMode($a_lesson_mode)
00289 {
00290 $this->lesson_mode = $a_lesson_mode;
00291 }
00292
00296 function getDefaultLessonMode()
00297 {
00298 return $this->lesson_mode;
00299 }
00300
00304 function setAutoReview($a_auto_review)
00305 {
00306 $this->auto_review = $a_auto_review;
00307 }
00308
00312 function getAutoReview()
00313 {
00314 return $this->auto_review;
00315 }
00316
00320
00321
00322
00323
00324
00325
00326
00327
00328
00329
00330
00331
00332
00333
00334
00335
00336
00337
00338
00339
00340
00341
00348 function update()
00349 {
00350 global $ilDB;
00351
00352 $this->updateMetaData();
00353 parent::update();
00354
00355 $q = "UPDATE sahs_lm SET ".
00356 " online = ".$ilDB->quote(ilUtil::tf2yn($this->getOnline())).",".
00357 " api_adapter = ".$ilDB->quote($this->getAPIAdapterName()).",".
00358 " api_func_prefix = ".$ilDB->quote($this->getAPIFunctionsPrefix()).",".
00359 " auto_review = ".$ilDB->quote(ilUtil::tf2yn($this->getAutoReview())).",".
00360 " default_lesson_mode = ".$ilDB->quote($this->getDefaultLessonMode()).",".
00361 " type = ".$ilDB->quote($this->getSubType()).",".
00362 " credit = ".$ilDB->quote($this->getCreditMode())."".
00363 " WHERE id = ".$ilDB->quote($this->getId());
00364 $this->ilias->db->query($q);
00365
00366 return true;
00367 }
00368
00372 function setOnline($a_online)
00373 {
00374 $this->online = $a_online;
00375 }
00376
00380 function getOnline()
00381 {
00382 return $this->online;
00383 }
00384
00388 function setSubType($a_sub_type)
00389 {
00390 $this->sub_type = $a_sub_type;
00391 }
00392
00396 function getSubType()
00397 {
00398 return $this->sub_type;
00399 }
00400
00407 function ilClone($a_parent_ref)
00408 {
00409 global $rbacadmin;
00410
00411
00412 $new_ref_id = parent::ilClone($a_parent_ref);
00413
00414
00415
00416
00417 return $new_ref_id;
00418 }
00419
00431 function delete()
00432 {
00433 global $ilDB;
00434
00435
00436 if (!parent::delete())
00437 {
00438 return false;
00439 }
00440
00441
00442
00443
00444
00445
00446
00447 $this->deleteMetaData();
00448
00449
00450 ilUtil::delDir($this->getDataDirectory());
00451
00452
00453 $q = "DELETE FROM sahs_lm WHERE id = ".$ilDB->quote($this->getId());
00454 $this->ilias->db->query($q);
00455
00456 if ($this->getSubType() == "scorm")
00457 {
00458
00459 include_once("content/classes/SCORM/class.ilSCORMTree.php");
00460 include_once("content/classes/SCORM/class.ilSCORMObject.php");
00461 $sc_tree = new ilSCORMTree($this->getId());
00462 $r_id = $sc_tree->readRootId();
00463 if ($r_id > 0)
00464 {
00465 $items = $sc_tree->getSubTree($sc_tree->getNodeData($r_id));
00466 foreach($items as $item)
00467 {
00468 $sc_object =& ilSCORMObject::_getInstance($item["obj_id"], $this->getId());
00469 if (is_object($sc_object))
00470 {
00471 $sc_object->delete();
00472 }
00473 }
00474 $sc_tree->removeTree($sc_tree->getTreeId());
00475 }
00476 }
00477
00478
00479
00480 return true;
00481 }
00482
00493 function notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params = 0)
00494 {
00495 global $tree;
00496
00497 switch ($a_event)
00498 {
00499 case "link":
00500
00501
00502
00503
00504 break;
00505
00506 case "cut":
00507
00508
00509
00510 break;
00511
00512 case "copy":
00513
00514
00515
00516
00517 break;
00518
00519 case "paste":
00520
00521
00522
00523 break;
00524
00525 case "new":
00526
00527
00528
00529 break;
00530 }
00531
00532
00533 if ($a_node_id==$_GET["ref_id"])
00534 {
00535 $parent_obj =& $this->ilias->obj_factory->getInstanceByRefId($a_node_id);
00536 $parent_type = $parent_obj->getType();
00537 if($parent_type == $this->getType())
00538 {
00539 $a_node_id = (int) $tree->getParentId($a_node_id);
00540 }
00541 }
00542
00543 parent::notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params);
00544 }
00545
00546 }
00547 ?>