ILIAS  Release_4_4_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 /* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
5 require_once "./Services/Object/classes/class.ilObject.php";
6 //require_once "Services/MetaData/classes/class.ilMDLanguageItem.php";
7 require_once "./Modules/ScormAicc/classes/class.ilObjSCORMLearningModule.php";
8 
18 {
19  //var $meta_data;
20 
27  function ilObjAICCLearningModule($a_id = 0, $a_call_by_reference = true)
28  {
29  $this->type = "sahs";
30  parent::ilObject($a_id,$a_call_by_reference);
31  }
32 
36  function readObject()
37  {
38  require_once("./Modules/ScormAicc/classes/class.ilObjAICCCourseInterchangeFiles.php");
39  $cifModule = new ilObjAICCCourseInterchangeFiles();
40  $cifModule->findFiles($this->getDataDirectory());
41 
42  $cifModule->readFiles();
43  if (!empty($cifModule->errorText))
44  {
45  $this->ilias->raiseError("<b>Error reading LM-File(s):</b><br>".implode("<br>", $cifModule->errorText), $this->ilias->error_obj->WARNING);
46  }
47 
48  if ($_POST["validate"] == "y")
49  {
50 
51  $cifModule->validate();
52  if (!empty($cifModule->errorText))
53  {
54  $this->ilias->raiseError("<b>Validation Error(s):</b><br>".implode("<br>", $cifModule->errorText), $this->ilias->error_obj->WARNING);
55  }
56  }
57 
58  $cifModule->writeToDatabase($this->getId());
59  }
60 
61 
73  function delete()
74  {
75  global $ilDB, $ilLog;
76 
77  // always call parent delete function first!!
78  if (!parent::delete())
79  {
80  return false;
81  }
82 
83  // delete meta data of scorm content object
84 /*
85  $nested = new ilNestedSetXML();
86  $nested->init($this->getId(), $this->getType());
87  $nested->deleteAllDBData();
88 */
89  $this->deleteMetaData();
90 
91  // delete data directory
93 
94  // delete scorm learning module record
95  $ilDB->manipulateF('DELETE FROM sahs_lm WHERE id = %s',
96  array('integer'), array($this->getId()));
97 
98  // delete aicc data
99  $res = $ilDB->queryF('
100  SELECT * FROM aicc_object, aicc_units
101  WHERE aicc_object.obj_id = aicc_units.obj_id
102  AND aicc_object.slm_id = %s',
103  array('integer'), array($this->getId()));
104 
105  while($row = $ilDB->fetchAssoc($res))
106  {
107  $obj_id = $row['obj_id'];
108  $ilDB->manipulateF('
109  DELETE FROM aicc_units WHERE obj_id = %s',
110  array('integer'), array($obj_id));
111  }
112 
113  $res = $ilDB->queryF('
114  SELECT * FROM aicc_object, aicc_course
115  WHERE aicc_object.obj_id = aicc_course.obj_id
116  AND aicc_object.slm_id = %s',
117  array('integer'), array($this->getId()));
118 
119  while($row = $ilDB->fetchAssoc($res))
120  {
121  $obj_id = $row['obj_id'];
122  $ilDB->manipulateF('
123  DELETE FROM aicc_course WHERE obj_id = %s',
124  array('integer'), array($obj_id));
125  }
126 
127  $ilDB->manipulateF('DELETE FROM scorm_tree WHERE slm_id = %s',
128  array('integer'), array($this->getId()));
129 
130  $ilDB->manipulateF('DELETE FROM aicc_object WHERE slm_id = %s',
131  array('integer'), array($this->getId()));
132 
133  $q_log = "DELETE FROM scorm_tracking WHERE obj_id = ".$ilDB->quote($this->getId());
134  $ilLog->write("SAHS Delete (AICC LM): ".$q_log);
135  $ilDB->manipulateF('DELETE FROM scorm_tracking WHERE obj_id = %s',
136  array('integer'), array($this->getId()));
137 
138  $q_log = "DELETE FROM sahs_user WHERE obj_id = ".$ilDB->quote($this->getId());
139  $ilLog->write("SAHS Delete (AICC LM): ".$q_log);
140  $ilDB->manipulateF('DELETE FROM sahs_user WHERE obj_id = %s',
141  array('integer'), array($this->getId()));
142 
143  // update learning progress status
144  include_once("./Services/Tracking/classes/class.ilLPStatusWrapper.php");
146 
147  // always call parent delete function at the end!!
148  return true;
149  }
150 
151 
155  function getTrackingItems()
156  {
158  }
159 
160 
164  function _getTrackingItems($a_obj_id)
165  {
166  global $ilDB;
167 
168  include_once("./Modules/ScormAicc/classes/AICC/class.ilAICCUnit.php");
169 
170  $statement = $ilDB->queryF('
171  SELECT obj_id,title FROM aicc_object
172  WHERE slm_id = %s
173  AND c_type = %s ',
174  array('integer', 'text'),
175  array($a_obj_id,'sau')
176  );
177 
178  while($row = $ilDB->fetchObject($statement))
179  {
180  $items[$row->obj_id]['obj_id'] = $row->obj_id;
181  $items[$row->obj_id]['title'] = $row->title;
182 
183  }
184 
185  return $items ? $items : array();
186 
187  /*
188  include_once("./Modules/ScormAicc/classes/SCORM/class.ilSCORMTree.php");
189  $tree = new ilSCORMTree($a_obj_id);
190  $root_id = $tree->readRootId();
191 
192  $items = array();
193  $childs = $tree->getSubTree($tree->getNodeData($root_id));
194  foreach($childs as $child)
195  {
196  if($child["c_type"] == "sau")
197  {
198  include_once("./Modules/ScormAicc/classes/AICC/class.ilAICCUnit.php");
199  $ac_item =& new ilAICCUnit($child["obj_id"]);
200  $items[count($items)] =& $ac_item;
201  }
202  }
203 
204  return $items;
205  */
206  }
207 
211  function getTrackedItems()
212  {
213  global $ilUser, $ilDB, $ilUser;
214 
215  $sco_set = $ilDB->queryF('
216  SELECT DISTINCT sco_id FROM scorm_tracking WHERE obj_id = %s',
217  array('integer'), array($this->getId()));
218 
219  $items = array();
220  while($sco_rec = $ilDB->fetchAssoc($sco_set))
221  {
222  include_once("./Modules/ScormAicc/classes/AICC/class.ilAICCUnit.php");
223  $ac_item =& new ilAICCUnit($sco_rec["sco_id"]);
224  $items[count($items)] =& $ac_item;
225 
226  }
227 
228  return $items;
229  }
230 
231  function getTrackingData($a_sco_id)
232  {
233  global $ilDB;
234 
235  $data_set = $ilDB->queryF('
236  SELECT * FROM scorm_tracking
237  WHERE obj_id = %s
238  AND sco_id = %s
239  ORDER BY user_id, lvalue',
240  array('integer', 'integer'),
241  array($this->getId(), $a_sco_id));
242 
243  $data = array();
244  while($data_rec = $ilDB->fetchAssoc($data_set))
245  {
246  $data[] = $data_rec;
247  }
248  return $data;
249  }
250 
251 } // END class.ilObjAICCLearningModule
252 
253 ?>