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

Modules/ScormAicc/classes/class.ilObjAICCLearningModule.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 require_once "classes/class.ilObject.php";
00025 //require_once "Services/MetaData/classes/class.ilMDLanguageItem.php";
00026 require_once "./Modules/ScormAicc/classes/class.ilObjSCORMLearningModule.php";
00027 
00036 class ilObjAICCLearningModule extends ilObjSCORMLearningModule
00037 {
00038         //var $meta_data;
00039 
00046         function ilObjAICCLearningModule($a_id = 0, $a_call_by_reference = true)
00047         {
00048                 $this->type = "sahs";
00049                 parent::ilObject($a_id,$a_call_by_reference);
00050         }
00051 
00055         function readObject()
00056         {
00057                 require_once("./Modules/ScormAicc/classes/class.ilObjAICCCourseInterchangeFiles.php");
00058                 $cifModule = new ilObjAICCCourseInterchangeFiles();
00059                 $cifModule->findFiles($this->getDataDirectory());
00060 
00061                 $cifModule->readFiles();
00062                 if (!empty($cifModule->errorText))
00063                 {
00064                         $this->ilias->raiseError("<b>Error reading LM-File(s):</b><br>".implode("<br>", $cifModule->errorText), $this->ilias->error_obj->WARNING);
00065                 }
00066 
00067                 if ($_POST["validate"] == "y")
00068                 {
00069 
00070                         $cifModule->validate();
00071                         if (!empty($cifModule->errorText))
00072                         {
00073                                 $this->ilias->raiseError("<b>Validation Error(s):</b><br>".implode("<br>", $cifModule->errorText), $this->ilias->error_obj->WARNING);
00074                         }
00075                 }
00076 
00077                 $cifModule->writeToDatabase($this->getId());
00078         }
00079 
00080 
00092         function delete()
00093         {
00094                 global $ilDB, $ilLog;
00095 
00096                 // always call parent delete function first!!
00097                 if (!parent::delete())
00098                 {
00099                         return false;
00100                 }
00101 
00102                 // delete meta data of scorm content object
00103 /*
00104                 $nested = new ilNestedSetXML();
00105                 $nested->init($this->getId(), $this->getType());
00106                 $nested->deleteAllDBData();
00107 */
00108                 $this->deleteMetaData();
00109 
00110                 // delete data directory
00111                 ilUtil::delDir($this->getDataDirectory());
00112 
00113                 // delete scorm learning module record
00114                 $q = "DELETE FROM sahs_lm WHERE id = ".$ilDB->quote($this->getId());
00115                 $this->ilias->db->query($q);
00116 
00117                 // delete aicc data
00118                 // this is highly dependent on the database
00119                 $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());
00120                 $this->ilias->db->query($q);
00121 
00122                 $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());
00123                 $this->ilias->db->query($q);
00124 
00125                 $q = "DELETE FROM scorm_tree WHERE slm_id = ".$ilDB->quote($this->getId());
00126                 $this->ilias->db->query($q);
00127 
00128                 $q = "DELETE FROM aicc_object WHERE slm_id = ".$ilDB->quote($this->getId());
00129                 $this->ilias->db->query($q);
00130 
00131                 $q = "DELETE FROM scorm_tracking WHERE obj_id = ".$ilDB->quote($this->getId());
00132                 $ilLog->write("SAHS Delete (AICC LM): ".$q);
00133                 $this->ilias->db->query($q);
00134 
00135                 // always call parent delete function at the end!!
00136                 return true;
00137         }
00138 
00139 
00143         function getTrackingItems()
00144         {
00145                 return ilObjAICCLearningModule::_getTrackingItems($this->getId());
00146         }
00147 
00148 
00152         function _getTrackingItems($a_obj_id)
00153         {
00154                 global $ilDB;
00155 
00156                 include_once("./Modules/ScormAicc/classes/AICC/class.ilAICCUnit.php");
00157 
00158                 $query = "SELECT obj_id,title FROM aicc_object ".
00159                         "WHERE slm_id = ".$ilDB->quote($a_obj_id)." ".
00160                         "AND type = 'sau'";
00161 
00162                 $res = $ilDB->query($query);
00163                 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
00164                 {
00165                         $items[$row->obj_id]['obj_id'] = $row->obj_id;
00166                         $items[$row->obj_id]['title'] = $row->title;
00167 
00168                 }
00169                 return $items ? $items : array();
00170 
00171                 /*
00172                 include_once("./Modules/ScormAicc/classes/SCORM/class.ilSCORMTree.php");
00173                 $tree = new ilSCORMTree($a_obj_id);
00174                 $root_id = $tree->readRootId();
00175 
00176                 $items = array();
00177                 $childs = $tree->getSubTree($tree->getNodeData($root_id));
00178                 foreach($childs as $child)
00179                 {
00180                         if($child["type"] == "sau")
00181                         {
00182                                 include_once("./Modules/ScormAicc/classes/AICC/class.ilAICCUnit.php");
00183                                 $ac_item =& new ilAICCUnit($child["obj_id"]);
00184                                 $items[count($items)] =& $ac_item;
00185                         }
00186                 }
00187 
00188                 return $items;
00189                 */
00190         }
00191 
00195         function getTrackedItems()
00196         {
00197                 global $ilUser, $ilDB, $ilUser;
00198 
00199                 $query = "SELECT DISTINCT sco_id FROM scorm_tracking WHERE".
00200                         " obj_id = ".$ilDB->quote($this->getId());
00201 
00202                 $sco_set = $ilDB->query($query);
00203 
00204                 $items = array();
00205                 while($sco_rec = $sco_set->fetchRow(DB_FETCHMODE_ASSOC))
00206                 {
00207                         include_once("./Modules/ScormAicc/classes/AICC/class.ilAICCUnit.php");  
00208                         $ac_item =& new ilAICCUnit($sco_rec["sco_id"]);
00209                         $items[count($items)] =& $ac_item;
00210 
00211                 }
00212 
00213                 return $items;
00214         }
00215 
00216         function getTrackingData($a_sco_id)
00217         {
00218                 global $ilDB;
00219 
00220                 $query = "SELECT * FROM scorm_tracking WHERE".
00221                         " obj_id = ".$ilDB->quote($this->getId()).
00222                         " AND sco_id = ".$ilDB->quote($a_sco_id).
00223                         " ORDER BY user_id, lvalue";
00224                 $data_set = $ilDB->query($query);
00225 
00226                 $data = array();
00227                 while($data_rec = $data_set->fetchRow(DB_FETCHMODE_ASSOC))
00228                 {
00229                         $data[] = $data_rec;
00230                 }
00231 
00232                 return $data;
00233         }
00234 
00235 } // END class.ilObjAICCLearningModule
00236 
00237 ?>

Generated on Fri Dec 13 2013 17:56:52 for ILIAS Release_3_9_x_branch .rev 46835 by  doxygen 1.7.1