ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjAICCLearningModule.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2001 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
24 require_once "classes/class.ilObject.php";
25 //require_once "Services/MetaData/classes/class.ilMDLanguageItem.php";
26 require_once "./Modules/ScormAicc/classes/class.ilObjSCORMLearningModule.php";
27 
37 {
38  //var $meta_data;
39 
46  function ilObjAICCLearningModule($a_id = 0, $a_call_by_reference = true)
47  {
48  $this->type = "sahs";
49  parent::ilObject($a_id,$a_call_by_reference);
50  }
51 
55  function readObject()
56  {
57  require_once("./Modules/ScormAicc/classes/class.ilObjAICCCourseInterchangeFiles.php");
58  $cifModule = new ilObjAICCCourseInterchangeFiles();
59  $cifModule->findFiles($this->getDataDirectory());
60 
61  $cifModule->readFiles();
62  if (!empty($cifModule->errorText))
63  {
64  $this->ilias->raiseError("<b>Error reading LM-File(s):</b><br>".implode("<br>", $cifModule->errorText), $this->ilias->error_obj->WARNING);
65  }
66 
67  if ($_POST["validate"] == "y")
68  {
69 
70  $cifModule->validate();
71  if (!empty($cifModule->errorText))
72  {
73  $this->ilias->raiseError("<b>Validation Error(s):</b><br>".implode("<br>", $cifModule->errorText), $this->ilias->error_obj->WARNING);
74  }
75  }
76 
77  $cifModule->writeToDatabase($this->getId());
78  }
79 
80 
92  function delete()
93  {
94  global $ilDB, $ilLog;
95 
96  // always call parent delete function first!!
97  if (!parent::delete())
98  {
99  return false;
100  }
101 
102  // delete meta data of scorm content object
103 /*
104  $nested = new ilNestedSetXML();
105  $nested->init($this->getId(), $this->getType());
106  $nested->deleteAllDBData();
107 */
108  $this->deleteMetaData();
109 
110  // delete data directory
112 
113  // delete scorm learning module record
114  $q = "DELETE FROM sahs_lm WHERE id = ".$ilDB->quote($this->getId());
115  $this->ilias->db->query($q);
116 
117  // delete aicc data
118  // this is highly dependent on the database
119  $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());
120  $this->ilias->db->query($q);
121 
122  $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());
123  $this->ilias->db->query($q);
124 
125  $q = "DELETE FROM scorm_tree WHERE slm_id = ".$ilDB->quote($this->getId());
126  $this->ilias->db->query($q);
127 
128  $q = "DELETE FROM aicc_object WHERE slm_id = ".$ilDB->quote($this->getId());
129  $this->ilias->db->query($q);
130 
131  $q = "DELETE FROM scorm_tracking WHERE obj_id = ".$ilDB->quote($this->getId());
132  $ilLog->write("SAHS Delete (AICC LM): ".$q);
133  $this->ilias->db->query($q);
134 
135  // always call parent delete function at the end!!
136  return true;
137  }
138 
139 
143  function getTrackingItems()
144  {
146  }
147 
148 
152  function _getTrackingItems($a_obj_id)
153  {
154  global $ilDB;
155 
156  include_once("./Modules/ScormAicc/classes/AICC/class.ilAICCUnit.php");
157 
158  $query = "SELECT obj_id,title FROM aicc_object ".
159  "WHERE slm_id = ".$ilDB->quote($a_obj_id)." ".
160  "AND type = 'sau'";
161 
162  $res = $ilDB->query($query);
163  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
164  {
165  $items[$row->obj_id]['obj_id'] = $row->obj_id;
166  $items[$row->obj_id]['title'] = $row->title;
167 
168  }
169  return $items ? $items : array();
170 
171  /*
172  include_once("./Modules/ScormAicc/classes/SCORM/class.ilSCORMTree.php");
173  $tree = new ilSCORMTree($a_obj_id);
174  $root_id = $tree->readRootId();
175 
176  $items = array();
177  $childs = $tree->getSubTree($tree->getNodeData($root_id));
178  foreach($childs as $child)
179  {
180  if($child["type"] == "sau")
181  {
182  include_once("./Modules/ScormAicc/classes/AICC/class.ilAICCUnit.php");
183  $ac_item =& new ilAICCUnit($child["obj_id"]);
184  $items[count($items)] =& $ac_item;
185  }
186  }
187 
188  return $items;
189  */
190  }
191 
195  function getTrackedItems()
196  {
197  global $ilUser, $ilDB, $ilUser;
198 
199  $query = "SELECT DISTINCT sco_id FROM scorm_tracking WHERE".
200  " obj_id = ".$ilDB->quote($this->getId());
201 
202  $sco_set = $ilDB->query($query);
203 
204  $items = array();
205  while($sco_rec = $sco_set->fetchRow(DB_FETCHMODE_ASSOC))
206  {
207  include_once("./Modules/ScormAicc/classes/AICC/class.ilAICCUnit.php");
208  $ac_item =& new ilAICCUnit($sco_rec["sco_id"]);
209  $items[count($items)] =& $ac_item;
210 
211  }
212 
213  return $items;
214  }
215 
216  function getTrackingData($a_sco_id)
217  {
218  global $ilDB;
219 
220  $query = "SELECT * FROM scorm_tracking WHERE".
221  " obj_id = ".$ilDB->quote($this->getId()).
222  " AND sco_id = ".$ilDB->quote($a_sco_id).
223  " ORDER BY user_id, lvalue";
224  $data_set = $ilDB->query($query);
225 
226  $data = array();
227  while($data_rec = $data_set->fetchRow(DB_FETCHMODE_ASSOC))
228  {
229  $data[] = $data_rec;
230  }
231 
232  return $data;
233  }
234 
235 } // END class.ilObjAICCLearningModule
236 
237 ?>