ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 $ilDB;
143 
144  parent::read();
145 
146  $obj_set = $ilDB->queryF(
147  'SELECT * FROM sc_item WHERE obj_id = %s',
148  array('integer'),
149  array($this->getId())
150  );
151  $obj_rec = $ilDB->fetchAssoc($obj_set);
152 
153  $this->setImportId($obj_rec["import_id"]);
154  $this->setIdentifierRef($obj_rec["identifierref"]);
155  if (strtolower($obj_rec["isvisible"]) == "false") {
156  $this->setVisible(false);
157  } else {
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  public 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  public function update()
193  {
194  global $ilDB;
195 
196  parent::update();
197 
198  $str_visible = ($this->getVisible()) ? 'true' : 'false';
199 
200  $ilDB->update(
201  'sc_item',
202  array(
203  'import_id' => array('text', $this->getImportId()),
204  'identifierref' => array('text', $this->getIdentifierRef()),
205  'isvisible' => array('text', $str_visible),
206  'parameters' => array('text', $this->getParameters()),
207  'prereq_type' => array('text', $this->getPrereqType()),
208  'prerequisites' => array('text', $this->getPrerequisites()),
209  'maxtimeallowed' => array('text', $this->getMaxTimeAllowed()),
210  'timelimitaction' => array('text', $this->getTimeLimitAction()),
211  'datafromlms' => array('clob', $this->getDataFromLms()),
212  'masteryscore' => array('text', $this->getMasteryScore())
213  ),
214  array(
215  'obj_id' => array('integer', $this->getId())
216  )
217  );
218  }
219 
225  public function getTrackingDataOfUser($a_user_id = 0)
226  {
227  global $ilDB, $ilUser;
228 
229  if ($a_user_id == 0) {
230  $a_user_id = $ilUser->getId();
231  }
232 
233  $track_set = $ilDB->queryF(
234  '
235  SELECT lvalue, rvalue FROM scorm_tracking
236  WHERE sco_id = %s
237  AND user_id = %s
238  AND obj_id = %s',
239  array('integer', 'integer', 'integer'),
240  array($this->getId(), $a_user_id, $this->getSLMId())
241  );
242 
243  $trdata = array();
244  while ($track_rec = $ilDB->fetchAssoc($track_set)) {
245  $trdata[$track_rec["lvalue"]] = $track_rec["rvalue"];
246  }
247 
248  return $trdata;
249  }
250 
251  public static 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  $a_user_id = $ilUser->getId();
257  }
258 
259  $track_set = $ilDB->queryF(
260  '
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  $trdata[$track_rec["lvalue"]] = $track_rec["rvalue"];
272  }
273 
274  return $trdata;
275  }
276 
277  public function delete()
278  {
279  global $ilDB, $ilLog;
280 
281  parent::delete();
282 
283  $ilDB->manipulateF(
284  'DELETE FROM sc_item WHERE obj_id = %s',
285  array('integer'),
286  array($this->getId())
287  );
288 
289  $ilLog->write("SAHS Delete(ScormItem): " .
290  'DELETE FROM scorm_tracking WHERE sco_id = ' . $this->getId() . ' AND obj_id = ' . $this->getSLMId());
291  $ilDB->manipulateF(
292  'DELETE FROM scorm_tracking WHERE sco_id = %s AND obj_id = %s',
293  array('integer', 'integer'),
294  array($this->getId(), $this->getSLMId())
295  );
296 
297  include_once("./Services/Tracking/classes/class.ilLPStatusWrapper.php");
299  }
300 
301  //function insertTrackData($a_lval, $a_rval, $a_ref_id)
302  public function insertTrackData($a_lval, $a_rval, $a_obj_id)
303  {
304  require_once("./Modules/ScormAicc/classes/SCORM/class.ilObjSCORMTracking.php");
305  //ilObjSCORMTracking::_insertTrackData($this->getId(), $a_lval, $a_rval, $a_ref_id);
306  ilObjSCORMTracking::_insertTrackData($this->getId(), $a_lval, $a_rval, $a_obj_id);
307  }
308 
309  // Static
310  public static function _getItems($a_obj_id)
311  {
312  global $ilDB;
313 
314  $res = $ilDB->queryF(
315  '
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  $item_ids[] = $row->obj_id;
324  }
325  return $item_ids ? $item_ids : array();
326  }
327 
328  public static function _lookupTitle($a_obj_id)
329  {
330  global $ilDB;
331 
332  $res = $ilDB->queryF(
333  'SELECT title FROM scorm_object WHERE obj_id = %s',
334  array('integer'),
335  array($a_obj_id)
336  );
337 
338  while ($row = $ilDB->fetchObject($res)) {
339  return $row->title;
340  }
341  return '';
342  }
343 }
setParameters($a_par)
setPrerequisites($a_pre)
setTimeLimitAction($a_lim_act)
static _getItems($a_obj_id)
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
Create styles array
The data for the language used.
setImportId($a_import_id)
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)