ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilSCORMObject.php
Go to the documentation of this file.
1 <?php
2 
3 declare(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 
186  public static function &_getInstance(int $a_id, int $a_slm_id)
187  {
188  global $DIC;
189  $ilDB = $DIC->database();
190 
191  $sc_set = $ilDB->queryF(
192  '
193  SELECT c_type FROM scorm_object
194  WHERE obj_id = %s
195  AND slm_id = %s',
196  array('integer','integer'),
197  array($a_id, $a_slm_id)
198  );
199  $sc_rec = $ilDB->fetchAssoc($sc_set);
200 
201  switch ($sc_rec["c_type"]) {
202  case "sit": $item = new ilSCORMItem($a_id);
203  return $item;
204 
205  case "sos": $sos = new ilSCORMOrganizations($a_id);
206  return $sos;
207 
208  case "sor": $sor = new ilSCORMOrganization($a_id);
209  return $sor;
210 
211  case "sma": $sma = new ilSCORMManifest($a_id);
212  return $sma;
213 
214  case "srs": $srs = new ilSCORMResources($a_id);
215  return $srs;
216 
217  default:
218  case "sre": $sre = new ilSCORMResource($a_id);
219  return $sre;
220  }
221  }
222 }
setType(?string $a_type)
__construct(int $a_id=0)
Constructor.
setSLMId(int $a_slm_id)
static _lookupPresentableItems(int $a_slm_id)
Count number of presentable SCOs/Assets of SCORM learning module.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
create()
Create database record for SCORM object.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: feed.php:28
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setTitle(string $a_title)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
update()
Updates database record for SCORM object.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static & _getInstance(int $a_id, int $a_slm_id)