ILIAS  Release_4_1_x_branch Revision 61804
 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 "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  // update learning progress status
139  include_once("./Services/Tracking/classes/class.ilLPStatusWrapper.php");
141 
142  // always call parent delete function at the end!!
143  return true;
144  }
145 
146 
150  function getTrackingItems()
151  {
153  }
154 
155 
159  function _getTrackingItems($a_obj_id)
160  {
161  global $ilDB;
162 
163  include_once("./Modules/ScormAicc/classes/AICC/class.ilAICCUnit.php");
164 
165  $statement = $ilDB->queryF('
166  SELECT obj_id,title FROM aicc_object
167  WHERE slm_id = %s
168  AND c_type = %s ',
169  array('integer', 'text'),
170  array($a_obj_id,'sau')
171  );
172 
173  while($row = $ilDB->fetchObject($statement))
174  {
175  $items[$row->obj_id]['obj_id'] = $row->obj_id;
176  $items[$row->obj_id]['title'] = $row->title;
177 
178  }
179 
180  return $items ? $items : array();
181 
182  /*
183  include_once("./Modules/ScormAicc/classes/SCORM/class.ilSCORMTree.php");
184  $tree = new ilSCORMTree($a_obj_id);
185  $root_id = $tree->readRootId();
186 
187  $items = array();
188  $childs = $tree->getSubTree($tree->getNodeData($root_id));
189  foreach($childs as $child)
190  {
191  if($child["c_type"] == "sau")
192  {
193  include_once("./Modules/ScormAicc/classes/AICC/class.ilAICCUnit.php");
194  $ac_item =& new ilAICCUnit($child["obj_id"]);
195  $items[count($items)] =& $ac_item;
196  }
197  }
198 
199  return $items;
200  */
201  }
202 
206  function getTrackedItems()
207  {
208  global $ilUser, $ilDB, $ilUser;
209 
210  $sco_set = $ilDB->queryF('
211  SELECT DISTINCT sco_id FROM scorm_tracking WHERE obj_id = %s',
212  array('integer'), array($this->getId()));
213 
214  $items = array();
215  while($sco_rec = $ilDB->fetchAssoc($sco_set))
216  {
217  include_once("./Modules/ScormAicc/classes/AICC/class.ilAICCUnit.php");
218  $ac_item =& new ilAICCUnit($sco_rec["sco_id"]);
219  $items[count($items)] =& $ac_item;
220 
221  }
222 
223  return $items;
224  }
225 
226  function getTrackingData($a_sco_id)
227  {
228  global $ilDB;
229 
230  $data_set = $ilDB->queryF('
231  SELECT * FROM scorm_tracking
232  WHERE obj_id = %s
233  AND sco_id = %s
234  ORDER BY user_id, lvalue',
235  array('integer', 'integer'),
236  array($this->getId(), $a_sco_id));
237 
238  $data = array();
239  while($data_rec = $ilDB->fetchAssoc($data_set))
240  {
241  $data[] = $data_rec;
242  }
243  return $data;
244  }
245 
246 } // END class.ilObjAICCLearningModule
247 
248 ?>