• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

content/classes/class.ilObjSAHSLearningModule.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003         +-----------------------------------------------------------------------------+
00004         | ILIAS open source                                                           |
00005         +-----------------------------------------------------------------------------+
00006         | Copyright (c) 1998-2001 ILIAS open source, University of Cologne            |
00007         |                                                                             |
00008         | This program is free software; you can redistribute it and/or               |
00009         | modify it under the terms of the GNU General Public License                 |
00010         | as published by the Free Software Foundation; either version 2              |
00011         | of the License, or (at your option) any later version.                      |
00012         |                                                                             |
00013         | This program is distributed in the hope that it will be useful,             |
00014         | but WITHOUT ANY WARRANTY; without even the implied warranty of              |
00015         | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               |
00016         | GNU General Public License for more details.                                |
00017         |                                                                             |
00018         | You should have received a copy of the GNU General Public License           |
00019         | along with this program; if not, write to the Free Software                 |
00020         | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. |
00021         +-----------------------------------------------------------------------------+
00022 */
00023 
00024 
00025 require_once "classes/class.ilObject.php";
00026 require_once "content/classes/class.ilObjSCORMValidator.php";
00027 require_once "classes/class.ilMetaData.php";
00028 
00038 class ilObjSAHSLearningModule extends ilObject
00039 {
00040         var $validator;
00041         var $meta_data;
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                         $new_meta =& new ilMetaData();
00056                         $this->assignMetaData($new_meta);
00057                 }
00058 
00059         }
00060 
00064         function create()
00065         {
00066                 global $ilDB;
00067 
00068                 parent::create();
00069                 $this->createDataDirectory();
00070                 $this->meta_data->setId($this->getId());
00071 //echo "<br>title:".$this->getId();
00072                 $this->meta_data->setType($this->getType());
00073 //echo "<br>title:".$this->getType();
00074                 $this->meta_data->setTitle($this->getTitle());
00075 //echo "<br>title:".$this->getTitle();
00076                 $this->meta_data->setDescription($this->getDescription());
00077                 $this->meta_data->setObject($this);
00078                 $this->meta_data->create();
00079 
00080                 $q = "INSERT INTO sahs_lm (id, online, api_adapter, type) VALUES ".
00081                         " (".$ilDB->quote($this->getID()).",".$ilDB->quote("n").",".
00082                         $ilDB->quote("API").",".$ilDB->quote($this->getSubType()).")";
00083                 $ilDB->query($q);
00084         }
00085 
00089         function read()
00090         {
00091                 parent::read();
00092                 $this->meta_data =& new ilMetaData($this->getType(), $this->getId());
00093 
00094                 $q = "SELECT * FROM sahs_lm WHERE id = '".$this->getId()."'";
00095                 $lm_set = $this->ilias->db->query($q);
00096                 $lm_rec = $lm_set->fetchRow(DB_FETCHMODE_ASSOC);
00097                 $this->setOnline(ilUtil::yn2tf($lm_rec["online"]));
00098                 $this->setAutoReview(ilUtil::yn2tf($lm_rec["auto_review"]));
00099                 $this->setAPIAdapterName($lm_rec["api_adapter"]);
00100                 $this->setDefaultLessonMode($lm_rec["default_lesson_mode"]);
00101                 $this->setAPIFunctionsPrefix($lm_rec["api_func_prefix"]);
00102                 $this->setCreditMode($lm_rec["credit"]);
00103                 $this->setSubType($lm_rec["type"]);
00104         }
00105 
00109         function _lookupOnline($a_id)
00110         {
00111                 $q = "SELECT * FROM sahs_lm WHERE id = '".$a_id."'";
00112                 $lm_set = $this->ilias->db->query($q);
00113                 $lm_rec = $lm_set->fetchRow(DB_FETCHMODE_ASSOC);
00114 
00115                 return ilUtil::yn2tf($lm_rec["online"]);
00116         }
00117 
00123         function _lookupSubType($a_obj_id)
00124         {
00125                 global $ilDB;
00126 
00127                 $q = "SELECT * FROM sahs_lm WHERE id = '".$a_obj_id."'";
00128                 $obj_set = $ilDB->query($q);
00129                 $obj_rec = $obj_set->fetchRow(DB_FETCHMODE_ASSOC);
00130 
00131                 return $obj_rec["type"];
00132         }
00133 
00139         function getTitle()
00140         {
00141                 return parent::getTitle();
00142         }
00143 
00149         function setTitle($a_title)
00150         {
00151                 parent::setTitle($a_title);
00152                 $this->meta_data->setTitle($a_title);
00153         }
00154 
00160         function getDescription()
00161         {
00162                 return $this->meta_data->getDescription();
00163         }
00164 
00170         function setDescription($a_description)
00171         {
00172                 $this->meta_data->setDescription($a_description);
00173         }
00174 
00180         function assignMetaData(&$a_meta_data)
00181         {
00182                 $this->meta_data =& $a_meta_data;
00183         }
00184 
00190         function &getMetaData()
00191         {
00192                 return $this->meta_data;
00193         }
00194 
00195 
00200         function createDataDirectory()
00201         {
00202                 $lm_data_dir = ilUtil::getWebspaceDir()."/lm_data";
00203                 ilUtil::makeDir($lm_data_dir);
00204                 ilUtil::makeDir($this->getDataDirectory());
00205         }
00206 
00210         function getDataDirectory($mode = "filesystem")
00211         {
00212                 $lm_data_dir = ilUtil::getWebspaceDir($mode)."/lm_data";
00213                 $lm_dir = $lm_data_dir."/lm_".$this->getId();
00214 
00215                 return $lm_dir;
00216         }
00217 
00221         function getAPIAdapterName()
00222         {
00223                 return $this->api_adapter;
00224         }
00225 
00229         function setAPIAdapterName($a_api)
00230         {
00231                 $this->api_adapter = $a_api;
00232         }
00233 
00237         function getAPIFunctionsPrefix()
00238         {
00239                 return $this->api_func_prefix;
00240         }
00241 
00245         function setAPIFunctionsPrefix($a_prefix)
00246         {
00247                 $this->api_func_prefix = $a_prefix;
00248         }
00249 
00253         function getCreditMode()
00254         {
00255                 return $this->credit_mode;
00256         }
00257 
00261         function setCreditMode($a_credit_mode)
00262         {
00263                 $this->credit_mode = $a_credit_mode;
00264         }
00265 
00269         function setDefaultLessonMode($a_lesson_mode)
00270         {
00271                 $this->lesson_mode = $a_lesson_mode;
00272         }
00273 
00277         function getDefaultLessonMode()
00278         {
00279                 return $this->lesson_mode;
00280         }
00281 
00285         function setAutoReview($a_auto_review)
00286         {
00287                 $this->auto_review = $a_auto_review;
00288         }
00289 
00293         function getAutoReview()
00294         {
00295                 return $this->auto_review;
00296         }
00297 
00301         function updateMetaData()
00302         {
00303                 $this->meta_data->update();
00304                 if ($this->meta_data->section != "General")
00305                 {
00306                         $meta = $this->meta_data->getElement("Title", "General");
00307                         $this->meta_data->setTitle($meta[0]["value"]);
00308                         $meta = $this->meta_data->getElement("Description", "General");
00309                         $this->meta_data->setDescription($meta[0]["value"]);
00310                 }
00311                 else
00312                 {
00313                         $this->setTitle($this->meta_data->getTitle());
00314                         $this->setDescription($this->meta_data->getDescription());
00315                 }
00316                 parent::update();
00317 
00318         }
00319 
00320 
00327         function update()
00328         {
00329                 global $ilDB;
00330 
00331                 $this->updateMetaData();
00332 
00333                 $q = "UPDATE sahs_lm SET ".
00334                         " online = ".$ilDB->quote(ilUtil::tf2yn($this->getOnline())).",".
00335                         " api_adapter = ".$ilDB->quote($this->getAPIAdapterName()).",".
00336                         " api_func_prefix = ".$ilDB->quote($this->getAPIFunctionsPrefix()).",".
00337                         " auto_review = ".$ilDB->quote(ilUtil::tf2yn($this->getAutoReview())).",".
00338                         " default_lesson_mode = ".$ilDB->quote($this->getDefaultLessonMode()).",".
00339                         " type = ".$ilDB->quote($this->getSubType()).",".
00340                         " credit = ".$ilDB->quote($this->getCreditMode())."".
00341                         " WHERE id = ".$ilDB->quote($this->getId());
00342                 $this->ilias->db->query($q);
00343 
00344                 return true;
00345         }
00346 
00350         function setOnline($a_online)
00351         {
00352                 $this->online = $a_online;
00353         }
00354 
00358         function getOnline()
00359         {
00360                 return $this->online;
00361         }
00362 
00366         function setSubType($a_sub_type)
00367         {
00368                 $this->sub_type = $a_sub_type;
00369         }
00370 
00374         function getSubType()
00375         {
00376                 return $this->sub_type;
00377         }
00378 
00385         function ilClone($a_parent_ref)
00386         {
00387                 global $rbacadmin;
00388 
00389                 // always call parent ilClone function first!!
00390                 $new_ref_id = parent::ilClone($a_parent_ref);
00391 
00392                 // put here slm specific stuff
00393 
00394                 // ... and finally always return new reference ID!!
00395                 return $new_ref_id;
00396         }
00397 
00409         function delete()
00410         {
00411                 global $ilDB;
00412 
00413                 // always call parent delete function first!!
00414                 if (!parent::delete())
00415                 {
00416                         return false;
00417                 }
00418 
00419                 // delete meta data of scorm content object
00420                 $nested = new ilNestedSetXML();
00421                 $nested->init($this->getId(), $this->getType());
00422                 $nested->deleteAllDBData();
00423 
00424                 // delete data directory
00425                 ilUtil::delDir($this->getDataDirectory());
00426 
00427                 // delete scorm learning module record
00428                 $q = "DELETE FROM sahs_lm WHERE id = ".$ilDB->quote($this->getId());
00429                 $this->ilias->db->query($q);
00430 
00431                 // remove all scorm objects and scorm tree
00432                 include_once("content/classes/SCORM/class.ilSCORMTree.php");
00433                 include_once("content/classes/SCORM/class.ilSCORMObject.php");
00434                 $sc_tree = new ilSCORMTree($this->getId());
00435                 $items = $sc_tree->getSubTree($sc_tree->getNodeData($sc_tree->readRootId()));
00436                 foreach($items as $item)
00437                 {
00438                         $sc_object =& ilSCORMObject::_getInstance($item["obj_id"]);
00439                         $sc_object->delete();
00440                 }
00441                 $sc_tree->removeTree($sc_tree->getTreeId());
00442 
00443 
00444                 // always call parent delete function at the end!!
00445                 return true;
00446         }
00447 
00458         function notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params = 0)
00459         {
00460                 global $tree;
00461 
00462                 switch ($a_event)
00463                 {
00464                         case "link":
00465 
00466                                 //var_dump("<pre>",$a_params,"</pre>");
00467                                 //echo "SCORMLearningModule ".$this->getRefId()." triggered by link event. Objects linked into target object ref_id: ".$a_ref_id;
00468                                 //exit;
00469                                 break;
00470 
00471                         case "cut":
00472 
00473                                 //echo "SCORMLearningModule ".$this->getRefId()." triggered by cut event. Objects are removed from target object ref_id: ".$a_ref_id;
00474                                 //exit;
00475                                 break;
00476 
00477                         case "copy":
00478 
00479                                 //var_dump("<pre>",$a_params,"</pre>");
00480                                 //echo "SCORMLearningModule ".$this->getRefId()." triggered by copy event. Objects are copied into target object ref_id: ".$a_ref_id;
00481                                 //exit;
00482                                 break;
00483 
00484                         case "paste":
00485 
00486                                 //echo "SCORMLearningModule ".$this->getRefId()." triggered by paste (cut) event. Objects are pasted into target object ref_id: ".$a_ref_id;
00487                                 //exit;
00488                                 break;
00489 
00490                         case "new":
00491 
00492                                 //echo "SCORMLearningModule ".$this->getRefId()." triggered by paste (new) event. Objects are applied to target object ref_id: ".$a_ref_id;
00493                                 //exit;
00494                                 break;
00495                 }
00496 
00497                 // At the beginning of the recursive process it avoids second call of the notify function with the same parameter
00498                 if ($a_node_id==$_GET["ref_id"])
00499                 {
00500                         $parent_obj =& $this->ilias->obj_factory->getInstanceByRefId($a_node_id);
00501                         $parent_type = $parent_obj->getType();
00502                         if($parent_type == $this->getType())
00503                         {
00504                                 $a_node_id = (int) $tree->getParentId($a_node_id);
00505                         }
00506                 }
00507 
00508                 parent::notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params);
00509         }
00510 
00511 } // END class.ilObjSCORMLearningModule
00512 ?>

Generated on Fri Dec 13 2013 09:06:36 for ILIAS Release_3_4_x_branch .rev 46804 by  doxygen 1.7.1