ILIAS  Release_4_0_x_branch Revision 61816
 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  $ilDB->manipulateF('DELETE FROM sahs_lm WHERE id = %s',
115  array('integer'), array($this->getId()));
116 
117  // delete aicc data
118  $res = $ilDB->queryF('
119  SELECT * FROM aicc_object, aicc_units
120  WHERE aicc_object.obj_id = aicc_units.obj_id
121  AND aicc_object.slm_id = %s',
122  array('integer'), array($this->getId()));
123 
124  while($row = $ilDB->fetchAssoc($res))
125  {
126  $obj_id = $row['obj_id'];
127  $ilDB->manipulateF('
128  DELETE FROM aicc_units WHERE obj_id = %s',
129  array('integer'), array($obj_id));
130  }
131 
132  $res = $ilDB->queryF('
133  SELECT * FROM aicc_object, aicc_course
134  WHERE aicc_object.obj_id = aicc_course.obj_id
135  AND aicc_object.slm_id = %s',
136  array('integer'), array($this->getId()));
137 
138  while($row = $ilDB->fetchAssoc($res))
139  {
140  $obj_id = $row['obj_id'];
141  $ilDB->manipulateF('
142  DELETE FROM aicc_course WHERE obj_id = %s',
143  array('integer'), array($obj_id));
144  }
145 
146  $ilDB->manipulateF('DELETE FROM scorm_tree WHERE slm_id = %s',
147  array('integer'), array($this->getId()));
148 
149  $ilDB->manipulateF('DELETE FROM aicc_object WHERE slm_id = %s',
150  array('integer'), array($this->getId()));
151 
152  $q_log = "DELETE FROM scorm_tracking WHERE obj_id = ".$ilDB->quote($this->getId());
153  $ilLog->write("SAHS Delete (AICC LM): ".$q_log);
154  $ilDB->manipulateF('DELETE FROM scorm_tracking WHERE obj_id = %s',
155  array('integer'), array($this->getId()));
156 
157  // always call parent delete function at the end!!
158  return true;
159  }
160 
161 
165  function getTrackingItems()
166  {
168  }
169 
170 
174  function _getTrackingItems($a_obj_id)
175  {
176  global $ilDB;
177 
178  include_once("./Modules/ScormAicc/classes/AICC/class.ilAICCUnit.php");
179 
180  $statement = $ilDB->queryF('
181  SELECT obj_id,title FROM aicc_object
182  WHERE slm_id = %s
183  AND c_type = %s ',
184  array('integer', 'text'),
185  array($a_obj_id,'sau')
186  );
187 
188  while($row = $ilDB->fetchObject($statement))
189  {
190  $items[$row->obj_id]['obj_id'] = $row->obj_id;
191  $items[$row->obj_id]['title'] = $row->title;
192 
193  }
194 
195  return $items ? $items : array();
196 
197  /*
198  include_once("./Modules/ScormAicc/classes/SCORM/class.ilSCORMTree.php");
199  $tree = new ilSCORMTree($a_obj_id);
200  $root_id = $tree->readRootId();
201 
202  $items = array();
203  $childs = $tree->getSubTree($tree->getNodeData($root_id));
204  foreach($childs as $child)
205  {
206  if($child["c_type"] == "sau")
207  {
208  include_once("./Modules/ScormAicc/classes/AICC/class.ilAICCUnit.php");
209  $ac_item =& new ilAICCUnit($child["obj_id"]);
210  $items[count($items)] =& $ac_item;
211  }
212  }
213 
214  return $items;
215  */
216  }
217 
221  function getTrackedItems()
222  {
223  global $ilUser, $ilDB, $ilUser;
224 
225  $sco_set = $ilDB->queryF('
226  SELECT DISTINCT sco_id FROM scorm_tracking WHERE obj_id = %s',
227  array('integer'), array($this->getId()));
228 
229  $items = array();
230  while($sco_rec = $ilDB->fetchAssoc($sco_set))
231  {
232  include_once("./Modules/ScormAicc/classes/AICC/class.ilAICCUnit.php");
233  $ac_item =& new ilAICCUnit($sco_rec["sco_id"]);
234  $items[count($items)] =& $ac_item;
235 
236  }
237 
238  return $items;
239  }
240 
241  function getTrackingData($a_sco_id)
242  {
243  global $ilDB;
244 
245  $data_set = $ilDB->queryF('
246  SELECT * FROM scorm_tracking
247  WHERE obj_id = %s
248  AND sco_id = %s
249  ORDER BY user_id, lvalue',
250  array('integer', 'interger'),
251  array($this->getId(), $a_sco_id));
252 
253  $data = array();
254  while($data_rec = $ilDB->fetchAssoc($data_set))
255  {
256  $data[] = $data_rec;
257  }
258  return $data;
259  }
260 
261 } // END class.ilObjAICCLearningModule
262 
263 ?>