ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilSCORMObject.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
29{
30 public int $id;
31 public string $title = "";
32 public ?string $type = null;
33 public int $slm_id;
34
39 public function __construct(int $a_id = 0)
40 {
41 $this->id = $a_id;
42 if ($a_id > 0) {
43 $this->read();
44 }
45 }
46
47 public function getId(): int
48 {
49 return $this->id;
50 }
51
52 public function setId(int $a_id): void
53 {
54 $this->id = $a_id;
55 }
56
57 public function getType(): ?string
58 {
59 return $this->type;
60 }
61
62 public function setType(?string $a_type): void
63 {
64 $this->type = $a_type;
65 }
66
67 public function getTitle(): string
68 {
69 return $this->title;
70 }
71
72 public function setTitle(string $a_title): void
73 {
74 $this->title = $a_title;
75 }
76
77 public function getSLMId(): int
78 {
79 return $this->slm_id;
80 }
81
82 public function setSLMId(int $a_slm_id): void
83 {
84 $this->slm_id = $a_slm_id;
85 }
86
90 public function read(): void
91 {
92 global $DIC;
93 $ilDB = $DIC->database();
94
95 $obj_set = $ilDB->queryF(
96 'SELECT * FROM scorm_object WHERE obj_id = %s',
97 array('integer'),
98 array($this->getId())
99 );
100 $obj_rec = $ilDB->fetchAssoc($obj_set);
101 $this->setTitle($obj_rec["title"] ?? '');
102 $this->setType($obj_rec["c_type"]);
103 $this->setSLMId((int) $obj_rec["slm_id"]);
104 }
105
109 public static function _lookupPresentableItems(int $a_slm_id): array
110 {
111 global $DIC;
112 $ilDB = $DIC->database();
113
114 $set = $ilDB->queryF(
115 "
116 SELECT sit.obj_id id
117 FROM scorm_object sob, sc_item sit
118 WHERE sob.slm_id = %s
119 AND sob.obj_id = sit.obj_id
120 AND sit.identifierref IS NOT NULL",
121 array('integer'),
122 array($a_slm_id)
123 );
124 $items = array();
125 while ($rec = $ilDB->fetchAssoc($set)) {
126 $items[] = $rec["id"];
127 }
128
129 return $items;
130 }
131
135 public function create(): void
136 {
137 global $DIC;
138 $ilDB = $DIC->database();
139
140 $nextId = $ilDB->nextId('scorm_object');
141 $this->setId($nextId);
142
143 $ilDB->manipulateF(
144 '
145 INSERT INTO scorm_object (obj_id,title, c_type, slm_id)
146 VALUES (%s,%s,%s,%s) ',
147 array('integer','text','text','integer'),
148 array($nextId, $this->getTitle(),$this->getType(), $this->getSLMId())
149 );
150 }
151
155 public function update(): void
156 {
157 global $DIC;
158 $ilDB = $DIC->database();
159
160 $ilDB->manipulateF(
161 '
162 UPDATE scorm_object
163 SET title = %s,
164 c_type = %s,
165 slm_id = %s
166 WHERE obj_id = %s',
167 array('text','text','integer','integer'),
168 array($this->getTitle(),$this->getType(), $this->getSLMId(),$this->getId())
169 );
170 }
171
172 public function delete(): void
173 {
174 global $DIC;
175 $ilDB = $DIC->database();
176 $ilDB->manipulateF(
177 'DELETE FROM scorm_object WHERE obj_id = %s',
178 array('integer'),
179 array($this->getId())
180 );
181 }
182
184 {
185 global $DIC;
186 $ilDB = $DIC->database();
187
188 $sc_set = $ilDB->queryF(
189 '
190 SELECT c_type FROM scorm_object
191 WHERE obj_id = %s
192 AND slm_id = %s',
193 array('integer','integer'),
194 array($a_id, $a_slm_id)
195 );
196 $sc_rec = $ilDB->fetchAssoc($sc_set);
197
198 switch ($sc_rec["c_type"]) {
199 case "sit": $item = new ilSCORMItem($a_id);
200 return $item;
201
202 case "sos": $sos = new ilSCORMOrganizations($a_id);
203 return $sos;
204
205 case "sor": $sor = new ilSCORMOrganization($a_id);
206 return $sor;
207
208 case "sma": $sma = new ilSCORMManifest($a_id);
209 return $sma;
210
211 case "srs": $srs = new ilSCORMResources($a_id);
212 return $srs;
213
214 default:
215 case "sre": $sre = new ilSCORMResource($a_id);
216 return $sre;
217 }
218 }
219}
Parent object for all SCORM objects, that are stored in table scorm_object.
setSLMId(int $a_slm_id)
setTitle(string $a_title)
create()
Create database record for SCORM object.
setType(?string $a_type)
update()
Updates database record for SCORM object.
static & _getInstance(int $a_id, int $a_slm_id)
static _lookupPresentableItems(int $a_slm_id)
Count number of presentable SCOs/Assets of SCORM learning module.
__construct(int $a_id=0)
Constructor.
SCORM Resources Element.
global $DIC
Definition: shib_login.php:26