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