ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5
class.ilSCORMItem.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("./Modules/ScormAicc/classes/SCORM/class.ilSCORMObject.php");
6 
16 {
27 
34  function ilSCORMItem($a_id = 0)
35  {
36  parent::ilSCORMObject($a_id);
37  $this->setType("sit");
38  }
39 
40  function getImportId()
41  {
42  return $this->import_id;
43  }
44 
45  function setImportId($a_import_id)
46  {
47  $this->import_id = $a_import_id;
48  }
49 
50  function getIdentifierRef()
51  {
52  return $this->identifierref;
53  }
54 
55  function setIdentifierRef($a_id_ref)
56  {
57  $this->identifierref = $a_id_ref;
58  }
59 
60  function getVisible()
61  {
62  return $this->isvisible;
63  }
64 
65  function setVisible($a_visible)
66  {
67  $this->isvisible = $a_visible;
68  }
69 
70  function getParameters()
71  {
72  return $this->parameters;
73  }
74 
75  function setParameters($a_par)
76  {
77  $this->parameters = $a_par;
78  }
79 
80  function getPrereqType()
81  {
82  return $this->prereq_type;
83  }
84 
85  function setPrereqType($a_p_type)
86  {
87  $this->prereq_type = $a_p_type;
88  }
89 
90  function getPrerequisites()
91  {
92  return $this->prerequisites;
93  }
94 
95  function setPrerequisites($a_pre)
96  {
97  $this->prerequisites = $a_pre;
98  }
99 
100  function getMaxTimeAllowed()
101  {
102  return $this->maxtimeallowed;
103  }
104 
105  function setMaxTimeAllowed($a_max)
106  {
107  $this->maxtimeallowed = $a_max;
108  }
109 
111  {
112  return $this->timelimitaction;
113  }
114 
115  function setTimeLimitAction($a_lim_act)
116  {
117  $this->timelimitaction = $a_lim_act;
118  }
119 
120  function getDataFromLms()
121  {
122  return $this->datafromlms;
123  }
124 
125  function setDataFromLms($a_data)
126  {
127  $this->datafromlms = $a_data;
128  }
129 
130  function getMasteryScore()
131  {
132  return $this->masteryscore;
133  }
134 
135  function setMasteryScore($a_score)
136  {
137  $this->masteryscore = $a_score;
138  }
139 
140  function read()
141  {
142  global $ilDB;
143 
144  parent::read();
145 
146  $obj_set = $ilDB->queryF('SELECT * FROM sc_item WHERE obj_id = %s',
147  array('integer'),array($this->getId()));
148  $obj_rec = $ilDB->fetchAssoc($obj_set);
149 
150  $this->setImportId($obj_rec["import_id"]);
151  $this->setIdentifierRef($obj_rec["identifierref"]);
152  if (strtolower($obj_rec["isvisible"]) == "false")
153  {
154  $this->setVisible(false);
155  }
156  else
157  {
158  $this->setVisible(true);
159  }
160  $this->setParameters($obj_rec["parameters"]);
161  $this->setPrereqType($obj_rec["prereq_type"]);
162  $this->setPrerequisites($obj_rec["prerequisites"]);
163  $this->setMaxTimeAllowed($obj_rec["maxtimeallowed"]);
164  $this->setTimeLimitAction($obj_rec["timelimitaction"]);
165  $this->setDataFromLms($obj_rec["datafromlms"]);
166  $this->setMasteryScore($obj_rec["masteryscore"]);
167  }
168 
169  function create()
170  {
171  global $ilDB;
172 
173  parent::create();
174 
175  $str_visible = ($this->getVisible()) ? 'true' : 'false';
176 
177  $ilDB->insert('sc_item', array(
178  'obj_id' => array('integer', $this->getId()),
179  'import_id' => array('text', $this->getImportId()),
180  'identifierref' => array('text', $this->getIdentifierRef()),
181  'isvisible' => array('text', $str_visible),
182  'parameters' => array('text', $this->getParameters()),
183  'prereq_type' => array('text', $this->getPrereqType()),
184  'prerequisites' => array('text', $this->getPrerequisites()),
185  'maxtimeallowed' => array('text', $this->getMaxTimeAllowed()),
186  'timelimitaction' => array('text', $this->getTimeLimitAction()),
187  'datafromlms' => array('clob', $this->getDataFromLms()),
188  'masteryscore' => array('text', $this->getMasteryScore())
189  ));
190  }
191 
192  function update()
193  {
194  global $ilDB;
195 
196  parent::update();
197 
198  $str_visible = ($this->getVisible()) ? 'true' : 'false';
199 
200  $ilDB->update('sc_item',
201  array(
202  'import_id' => array('text', $this->getImportId()),
203  'identifierref' => array('text', $this->getIdentifierRef()),
204  'isvisible' => array('text', $str_visible),
205  'parameters' => array('text', $this->getParameters()),
206  'prereq_type' => array('text', $this->getPrereqType()),
207  'prerequisites' => array('text', $this->getPrerequisites()),
208  'maxtimeallowed' => array('text', $this->getMaxTimeAllowed()),
209  'timelimitaction' => array('text', $this->getTimeLimitAction()),
210  'datafromlms' => array('clob', $this->getDataFromLms()),
211  'masteryscore' => array('text', $this->getMasteryScore())
212  ),
213  array(
214  'obj_id' => array('integer', $this->getId())
215  )
216  );
217  }
218 
224  function getTrackingDataOfUser($a_user_id = 0)
225  {
226  global $ilDB, $ilUser;
227 
228  if ($a_user_id == 0)
229  {
230  $a_user_id = $ilUser->getId();
231  }
232 
233  $track_set = $ilDB->queryF('
234  SELECT lvalue, rvalue FROM scorm_tracking
235  WHERE sco_id = %s
236  AND user_id = %s
237  AND obj_id = %s',
238  array('integer', 'integer', 'integer'),
239  array($this->getId(), $a_user_id, $this->getSLMId())
240  );
241 
242  $trdata = array();
243  while ($track_rec = $ilDB->fetchAssoc($track_set))
244  {
245  $trdata[$track_rec["lvalue"]] = $track_rec["rvalue"];
246  }
247 
248  return $trdata;
249  }
250 
251  function _lookupTrackingDataOfUser($a_item_id, $a_user_id = 0, $a_obj_id = 0)
252  {
253  global $ilDB, $ilUser;
254 
255  if ($a_user_id == 0)
256  {
257  $a_user_id = $ilUser->getId();
258  }
259 
260  $track_set = $ilDB->queryF('
261  SELECT lvalue, rvalue FROM scorm_tracking
262  WHERE sco_id = %s
263  AND user_id = %s
264  AND obj_id = %s',
265  array('integer', 'integer', 'integer'),
266  array($a_item_id, $a_user_id, $a_obj_id)
267  );
268 
269  $trdata = array();
270  while ($track_rec = $ilDB->fetchAssoc($track_set))
271  {
272  $trdata[$track_rec["lvalue"]] = $track_rec["rvalue"];
273  }
274 
275  return $trdata;
276  }
277 
278  function delete()
279  {
280  global $ilDB, $ilLog;
281 
282  parent::delete();
283 
284  $ilDB->manipulateF(
285  'DELETE FROM sc_item WHERE obj_id = %s',
286  array('integer'),
287  array($this->getId())
288  );
289 
290  $ilLog->write("SAHS Delete(ScormItem): ".
291  'DELETE FROM scorm_tracking WHERE sco_id = '.$this->getId().' AND obj_id = '.$this->getSLMId());
292  $ilDB->manipulateF(
293  'DELETE FROM scorm_tracking WHERE sco_id = %s AND obj_id = %s',
294  array('integer', 'integer'),
295  array($this->getId(), $this->getSLMId())
296  );
297 
298  include_once("./Services/Tracking/classes/class.ilLPStatusWrapper.php");
300  }
301 
302  //function insertTrackData($a_lval, $a_rval, $a_ref_id)
303  function insertTrackData($a_lval, $a_rval, $a_obj_id)
304  {
305  require_once("./Modules/ScormAicc/classes/SCORM/class.ilObjSCORMTracking.php");
306  //ilObjSCORMTracking::_insertTrackData($this->getId(), $a_lval, $a_rval, $a_ref_id);
307  ilObjSCORMTracking::_insertTrackData($this->getId(), $a_lval, $a_rval, $a_obj_id);
308  }
309 
310  // Static
311  function _getItems($a_obj_id)
312  {
313  global $ilDB;
314 
315  $res = $ilDB->queryF('
316  SELECT obj_id FROM scorm_object
317  WHERE slm_id = %s
318  AND c_type = %s',
319  array('integer', 'text'),
320  array($a_obj_id, 'sit')
321  );
322  while($row = $ilDB->fetchObject($res))
323  {
324  $item_ids[] = $row->obj_id;
325  }
326  return $item_ids ? $item_ids : array();
327  }
328 
329  function _lookupTitle($a_obj_id)
330  {
331  global $ilDB;
332 
333  $res = $ilDB->queryF(
334  'SELECT title FROM scorm_object WHERE obj_id = %s',
335  array('integer'),
336  array($a_obj_id)
337  );
338 
339  while($row = $ilDB->fetchObject($res))
340  {
341  return $row->title;
342  }
343  return '';
344  }
345 }
346 ?>
setParameters($a_par)
ilSCORMItem($a_id=0)
Constructor.
setPrerequisites($a_pre)
setTimeLimitAction($a_lim_act)
setMasteryScore($a_score)
setVisible($a_visible)
_lookupTitle($a_obj_id)
_insertTrackData($a_sahs_id, $a_lval, $a_rval, $a_obj_id)
Parent object for all SCORM objects, that are stored in table scorm_object.
setPrereqType($a_p_type)
SCORM Item.
_lookupTrackingDataOfUser($a_item_id, $a_user_id=0, $a_obj_id=0)
_getItems($a_obj_id)
setImportId($a_import_id)
setDataFromLms($a_data)
_refreshStatus($a_obj_id, $a_users=null)
Set dirty.
global $ilUser
Definition: imgupload.php:15
global $ilDB
setIdentifierRef($a_id_ref)
insertTrackData($a_lval, $a_rval, $a_obj_id)
getTrackingDataOfUser($a_user_id=0)
get tracking data of specified or current user
setMaxTimeAllowed($a_max)