ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilSCORMItem.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
30{
31 public string $import_id;
32 public string $identifierref;
33 public bool $isvisible = true;
34 public ?string $parameters = null;
35 public ?string $prereq_type = null;
36 public ?string $prerequisites = null;
37 public ?string $maxtimeallowed = null;
38 public ?string $timelimitaction = null;
39 public ?string $datafromlms = null;
40 public ?string $masteryscore = null;
41
45 public function __construct(int $a_id = 0)
46 {
48 $this->setType("sit");
49 }
50
51 public function getImportId(): string
52 {
53 return $this->import_id;
54 }
55
56 public function setImportId(string $a_import_id): void
57 {
58 $this->import_id = $a_import_id;
59 }
60
61 public function getIdentifierRef(): string
62 {
64 }
65
66 public function setIdentifierRef(string $a_id_ref): void
67 {
68 $this->identifierref = $a_id_ref;
69 }
70
71 public function getVisible(): bool
72 {
73 return $this->isvisible;
74 }
75
76 public function setVisible(bool $a_visible): void
77 {
78 $this->isvisible = $a_visible;
79 }
80
81 public function getParameters(): ?string
82 {
83 return $this->parameters;
84 }
85
86 public function setParameters(?string $a_par): void
87 {
88 $this->parameters = $a_par;
89 }
90
91 public function getPrereqType(): ?string
92 {
93 return $this->prereq_type;
94 }
95
96 public function setPrereqType(?string $a_p_type): void
97 {
98 $this->prereq_type = $a_p_type;
99 }
100
101 public function getPrerequisites(): ?string
102 {
104 }
105
106 public function setPrerequisites(?string $a_pre): void
107 {
108 $this->prerequisites = $a_pre;
109 }
110
111 public function getMaxTimeAllowed(): ?string
112 {
114 }
115
116 public function setMaxTimeAllowed(?string $a_max): void
117 {
118 $this->maxtimeallowed = $a_max;
119 }
120
121 public function getTimeLimitAction(): ?string
122 {
124 }
125
126 public function setTimeLimitAction(?string $a_lim_act): void
127 {
128 $this->timelimitaction = $a_lim_act;
129 }
130
131 public function getDataFromLms(): ?string
132 {
133 return $this->datafromlms;
134 }
135
136 public function setDataFromLms(?string $a_data): void
137 {
138 $this->datafromlms = $a_data;
139 }
140
141 public function getMasteryScore(): ?string
142 {
143 return $this->masteryscore;
144 }
145
146 public function setMasteryScore(?string $a_score): void
147 {
148 $this->masteryscore = $a_score;
149 }
150
151 public function read(): void
152 {
153 global $DIC;
154 $ilDB = $DIC->database();
155
156 parent::read();
157
158 $obj_set = $ilDB->queryF(
159 'SELECT * FROM sc_item WHERE obj_id = %s',
160 array('integer'),
161 array($this->getId())
162 );
163 $obj_rec = $ilDB->fetchAssoc($obj_set);
164 $this->setImportId((string) $obj_rec["import_id"]);
165 $this->setIdentifierRef((string) $obj_rec["identifierref"]);
166 if (strtolower((string) $obj_rec["isvisible"]) === "false") {
167 $this->setVisible(false);
168 } else {
169 $this->setVisible(true);
170 }
171 $this->setParameters($obj_rec["parameters"]);
172 $this->setPrereqType($obj_rec["prereq_type"]);
173 $this->setPrerequisites($obj_rec["prerequisites"]);
174 $this->setMaxTimeAllowed($obj_rec["maxtimeallowed"]);
175 $this->setTimeLimitAction($obj_rec["timelimitaction"]);
176 $this->setDataFromLms($obj_rec["datafromlms"]);
177 $this->setMasteryScore($obj_rec["masteryscore"]);
178 }
179
180 public function create(): void
181 {
182 global $DIC;
183 $ilDB = $DIC->database();
184
185 parent::create();
186
187 $str_visible = ($this->getVisible()) ? 'true' : 'false';
188
189 $ilDB->insert('sc_item', array(
190 'obj_id' => array('integer', $this->getId()),
191 'import_id' => array('text', $this->getImportId()),
192 'identifierref' => array('text', $this->getIdentifierRef()),
193 'isvisible' => array('text', $str_visible),
194 'parameters' => array('text', $this->getParameters()),
195 'prereq_type' => array('text', $this->getPrereqType()),
196 'prerequisites' => array('text', $this->getPrerequisites()),
197 'maxtimeallowed' => array('text', $this->getMaxTimeAllowed()),
198 'timelimitaction' => array('text', $this->getTimeLimitAction()),
199 'datafromlms' => array('clob', $this->getDataFromLms()),
200 'masteryscore' => array('text', $this->getMasteryScore())
201 ));
202 }
203
204 public function update(): void
205 {
206 global $DIC;
207 $ilDB = $DIC->database();
208
209 parent::update();
210
211 $str_visible = ($this->getVisible()) ? 'true' : 'false';
212
213 $ilDB->update(
214 'sc_item',
215 array(
216 'import_id' => array('text', $this->getImportId()),
217 'identifierref' => array('text', $this->getIdentifierRef()),
218 'isvisible' => array('text', $str_visible),
219 'parameters' => array('text', $this->getParameters()),
220 'prereq_type' => array('text', $this->getPrereqType()),
221 'prerequisites' => array('text', $this->getPrerequisites()),
222 'maxtimeallowed' => array('text', $this->getMaxTimeAllowed()),
223 'timelimitaction' => array('text', $this->getTimeLimitAction()),
224 'datafromlms' => array('clob', $this->getDataFromLms()),
225 'masteryscore' => array('text', $this->getMasteryScore())
226 ),
227 array(
228 'obj_id' => array('integer', $this->getId())
229 )
230 );
231 }
232
238 public function getTrackingDataOfUser(int $a_user_id = 0): array
239 {
240 global $DIC;
241 $ilDB = $DIC->database();
242 $ilUser = $DIC->user();
243
244 if ($a_user_id == 0) {
245 $a_user_id = $ilUser->getId();
246 }
247
248 $track_set = $ilDB->queryF(
249 '
250 SELECT lvalue, rvalue FROM scorm_tracking
251 WHERE sco_id = %s
252 AND user_id = %s
253 AND obj_id = %s',
254 array('integer', 'integer', 'integer'),
255 array($this->getId(), $a_user_id, $this->getSLMId())
256 );
257
258 $trdata = array();
259 while ($track_rec = $ilDB->fetchAssoc($track_set)) {
260 $trdata[$track_rec["lvalue"]] = $track_rec["rvalue"];
261 }
262
263 return $trdata;
264 }
265
269 public static function _lookupTrackingDataOfUser(int $a_item_id, int $a_user_id = 0, int $a_obj_id = 0): array
270 {
271 global $DIC;
272 $ilDB = $DIC->database();
273 $ilUser = $DIC->user();
274
275 if ($a_user_id == 0) {
276 $a_user_id = $ilUser->getId();
277 }
278
279 $track_set = $ilDB->queryF(
280 '
281 SELECT lvalue, rvalue FROM scorm_tracking
282 WHERE sco_id = %s
283 AND user_id = %s
284 AND obj_id = %s',
285 array('integer', 'integer', 'integer'),
286 array($a_item_id, $a_user_id, $a_obj_id)
287 );
288
289 $trdata = array();
290 while ($track_rec = $ilDB->fetchAssoc($track_set)) {
291 $trdata[$track_rec["lvalue"]] = $track_rec["rvalue"];
292 }
293
294 return $trdata;
295 }
296
297 public function delete(): void
298 {
299 global $DIC;
300 $ilDB = $DIC->database();
301 $ilLog = ilLoggerFactory::getLogger('sahs');
302
303 parent::delete();
304
305 $ilDB->manipulateF(
306 'DELETE FROM sc_item WHERE obj_id = %s',
307 array('integer'),
308 array($this->getId())
309 );
310
311 $ilLog->write("SAHS Delete(ScormItem): " .
312 'DELETE FROM scorm_tracking WHERE sco_id = ' . $this->getId() . ' AND obj_id = ' . $this->getSLMId());
313 $ilDB->manipulateF(
314 'DELETE FROM scorm_tracking WHERE sco_id = %s AND obj_id = %s',
315 array('integer', 'integer'),
316 array($this->getId(), $this->getSLMId())
317 );
319 }
320
321 public function insertTrackData(string $a_lval, string $a_rval, int $a_obj_id): void
322 {
323 //ilObjSCORMTracking::_insertTrackData($this->getId(), $a_lval, $a_rval, $a_ref_id);
324 ilObjSCORMTracking::_insertTrackData($this->getId(), $a_lval, $a_rval, $a_obj_id);
325 }
326
330 public static function _getItems(int $a_obj_id): array
331 {
332 global $DIC;
333 $ilDB = $DIC->database();
334 $item_ids = [];
335
336 $res = $ilDB->queryF(
337 '
338 SELECT obj_id FROM scorm_object
339 WHERE slm_id = %s
340 AND c_type = %s',
341 array('integer', 'text'),
342 array($a_obj_id, 'sit')
343 );
344 while ($row = $ilDB->fetchObject($res)) {
345 $item_ids[] = $row->obj_id;
346 }
347 return $item_ids;
348 }
349
350 public static function _lookupTitle(int $a_obj_id): string
351 {
352 global $DIC;
353 $ilDB = $DIC->database();
354
355 $res = $ilDB->queryF(
356 'SELECT title FROM scorm_object WHERE obj_id = %s',
357 array('integer'),
358 array($a_obj_id)
359 );
360
361 while ($row = $ilDB->fetchObject($res)) {
362 return $row->title;
363 }
364 return '';
365 }
366}
static _refreshStatus(int $a_obj_id, ?array $a_users=null)
static getLogger(string $a_component_id)
Get component logger.
static _insertTrackData(int $a_sahs_id, string $a_lval, string $a_rval, int $a_obj_id)
setTimeLimitAction(?string $a_lim_act)
setVisible(bool $a_visible)
getTrackingDataOfUser(int $a_user_id=0)
get tracking data of specified or current user
string $timelimitaction
string $maxtimeallowed
insertTrackData(string $a_lval, string $a_rval, int $a_obj_id)
setIdentifierRef(string $a_id_ref)
static _getItems(int $a_obj_id)
setParameters(?string $a_par)
setDataFromLms(?string $a_data)
update()
Updates database record for SCORM object.
static _lookupTrackingDataOfUser(int $a_item_id, int $a_user_id=0, int $a_obj_id=0)
setImportId(string $a_import_id)
setPrereqType(?string $a_p_type)
static _lookupTitle(int $a_obj_id)
setPrerequisites(?string $a_pre)
setMasteryScore(?string $a_score)
__construct(int $a_id=0)
create()
Create database record for SCORM object.
setMaxTimeAllowed(?string $a_max)
Parent object for all SCORM objects, that are stored in table scorm_object.
setType(?string $a_type)
$res
Definition: ltiservices.php:69
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26