• Main Page
  • Related Pages
  • Modules
  • 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 /*
00056                         $new_meta =& new ilMetaData();
00057                         $this->assignMetaData($new_meta);
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                 $this->meta_data->setId($this->getId());
00077 //echo "<br>title:".$this->getId();
00078                 $this->meta_data->setType($this->getType());
00079 //echo "<br>title:".$this->getType();
00080                 $this->meta_data->setTitle($this->getTitle());
00081 //echo "<br>title:".$this->getTitle();
00082                 $this->meta_data->setDescription($this->getDescription());
00083                 $this->meta_data->setObject($this);
00084                 $this->meta_data->create();
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 //              $this->meta_data =& new ilMetaData($this->getType(), $this->getId());
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         function getTitle()
00148         {
00149                 return parent::getTitle();
00150         }
00151 */
00152 
00158 /*
00159         function setTitle($a_title)
00160         {
00161                 parent::setTitle($a_title);
00162 //              $this->meta_data->setTitle($a_title);
00163         }
00164 */
00165 
00171 /*
00172         function getDescription()
00173         {
00174                 return $this->meta_data->getDescription();
00175         }
00176 */
00177 
00183 /*
00184         function setDescription($a_description)
00185         {
00186                 $this->meta_data->setDescription($a_description);
00187         }
00188 */
00189 
00195 /*
00196         function assignMetaData(&$a_meta_data)
00197         {
00198                 $this->meta_data =& $a_meta_data;
00199         }
00200 */
00201 
00207 /*
00208         function &getMetaData()
00209         {
00210                 return $this->meta_data;
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         function updateMetaData()
00322         {
00323                 $this->meta_data->update();
00324                 if ($this->meta_data->section != "General")
00325                 {
00326                         $meta = $this->meta_data->getElement("Title", "General");
00327                         $this->meta_data->setTitle($meta[0]["value"]);
00328                         $meta = $this->meta_data->getElement("Description", "General");
00329                         $this->meta_data->setDescription($meta[0]["value"]);
00330                 }
00331                 else
00332                 {
00333                         $this->setTitle($this->meta_data->getTitle());
00334                         $this->setDescription($this->meta_data->getDescription());
00335                 }
00336                 parent::update();
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                 // always call parent ilClone function first!!
00412                 $new_ref_id = parent::ilClone($a_parent_ref);
00413 
00414                 // put here slm specific stuff
00415 
00416                 // ... and finally always return new reference ID!!
00417                 return $new_ref_id;
00418         }
00419 
00431         function delete()
00432         {
00433                 global $ilDB;
00434 
00435                 // always call parent delete function first!!
00436                 if (!parent::delete())
00437                 {
00438                         return false;
00439                 }
00440 
00441                 // delete meta data of scorm content object
00442 /*
00443                 $nested = new ilNestedSetXML();
00444                 $nested->init($this->getId(), $this->getType());
00445                 $nested->deleteAllDBData();
00446 */
00447                 $this->deleteMetaData();
00448 
00449                 // delete data directory
00450                 ilUtil::delDir($this->getDataDirectory());
00451 
00452                 // delete scorm learning module record
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                         // remove all scorm objects and scorm tree
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                 // always call parent delete function at the end!!
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                                 //var_dump("<pre>",$a_params,"</pre>");
00502                                 //echo "SCORMLearningModule ".$this->getRefId()." triggered by link event. Objects linked into target object ref_id: ".$a_ref_id;
00503                                 //exit;
00504                                 break;
00505 
00506                         case "cut":
00507 
00508                                 //echo "SCORMLearningModule ".$this->getRefId()." triggered by cut event. Objects are removed from target object ref_id: ".$a_ref_id;
00509                                 //exit;
00510                                 break;
00511 
00512                         case "copy":
00513 
00514                                 //var_dump("<pre>",$a_params,"</pre>");
00515                                 //echo "SCORMLearningModule ".$this->getRefId()." triggered by copy event. Objects are copied into target object ref_id: ".$a_ref_id;
00516                                 //exit;
00517                                 break;
00518 
00519                         case "paste":
00520 
00521                                 //echo "SCORMLearningModule ".$this->getRefId()." triggered by paste (cut) event. Objects are pasted into target object ref_id: ".$a_ref_id;
00522                                 //exit;
00523                                 break;
00524 
00525                         case "new":
00526 
00527                                 //echo "SCORMLearningModule ".$this->getRefId()." triggered by paste (new) event. Objects are applied to target object ref_id: ".$a_ref_id;
00528                                 //exit;
00529                                 break;
00530                 }
00531 
00532                 // At the beginning of the recursive process it avoids second call of the notify function with the same parameter
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 } // END class.ilObjSCORMLearningModule
00547 ?>

Generated on Fri Dec 13 2013 13:52:09 for ILIAS Release_3_7_x_branch .rev 46817 by  doxygen 1.7.1