3declare(strict_types=1);
43 $this->files = array();
44 $this->dependencies = array();
56 $this->import_id = $a_import_id;
66 $this->resourcetype = $a_type;
76 $this->scormtype = $a_scormtype;
84 public function setHRef(?
string $a_href): void
86 $this->href = $a_href;
97 $this->xml_base = $a_xml_base;
102 $this->files[] = &$a_file_obj;
115 $this->dependencies[] = &$a_dependency;
133 $obj_set =
$ilDB->queryF(
134 'SELECT * FROM sc_resource WHERE obj_id = %s',
136 array($this->
getId())
138 $obj_rec =
$ilDB->fetchAssoc($obj_set);
142 $this->
setHRef($obj_rec[
"href"]);
146 $file_set =
$ilDB->queryF(
147 'SELECT href FROM sc_resource_file WHERE res_id = %s ORDER BY nr',
149 array($this->
getId())
151 while ($file_rec =
$ilDB->fetchAssoc($file_set)) {
153 $res_file->setHref($file_rec[
"href"]);
158 $dep_set =
$ilDB->queryF(
159 'SELECT identifierref FROM sc_resource_dependen WHERE res_id = %s ORDER BY nr',
161 array($this->
getId())
163 while ($dep_rec =
$ilDB->fetchAssoc($dep_set)) {
165 $res_dep->setIdentifierRef($dep_rec[
"identifierref"]);
170 public function readByIdRef(
string $a_id_ref,
int $a_slm_id): void
173 $ilBench =
$DIC[
'ilBench'];
176 $ilBench->start(
"SCORMResource",
"readByIdRef_Query");
178 $id_set =
$ilDB->queryF(
179 'SELECT ob.obj_id id FROM sc_resource res, scorm_object ob
180 WHERE ob.obj_id = res.obj_id
181 AND res.import_id = %s
183 array(
'text',
'integer'),
184 array($a_id_ref, $a_slm_id)
187 $ilBench->stop(
"SCORMResource",
"readByIdRef_Query");
189 if ($id_rec =
$ilDB->fetchAssoc($id_set)) {
190 $this->
setId($id_rec[
"id"]);
198 $ilBench =
$DIC[
'ilBench'];
201 $id_set =
$ilDB->queryF(
202 'SELECT ob.obj_id id FROM sc_resource res, scorm_object ob
203 WHERE ob.obj_id = res.obj_id
204 AND res.import_id = %s
206 array(
'text',
'integer'),
207 array($a_id_ref ,$a_slm_id)
210 if ($id_rec =
$ilDB->fetchAssoc($id_set)) {
211 return (
int) $id_rec[
"id"];
221 $st_set =
$ilDB->queryF(
222 'SELECT scormtype FROM sc_resource WHERE obj_id = %s',
226 if ($st_rec =
$ilDB->fetchAssoc($st_set)) {
227 return (
string) $st_rec[
"scormtype"];
241 INSERT INTO sc_resource
242 (obj_id, import_id, resourcetype, scormtype, href, xml_base)
243 VALUES(%s, %s, %s, %s, %s, %s)',
244 array(
'integer',
'text',
'text',
'text',
'text',
'text'),
245 array( $this->
getId(),
255 foreach ($this->files as
$i => $value) {
256 $nextId =
$ilDB->nextId(
'sc_resource_file');
260 INSERT INTO sc_resource_file (id,res_id, href, nr)
261 VALUES(%s, %s, %s, %s)',
262 array(
'integer',
'integer',
'text',
'integer'),
263 array($nextId, $this->
getId(), $value->getHref(), (
$i + 1))
268 for (
$i = 0, $max = count($this->dependencies);
$i < $max;
$i++) {
269 $nextId =
$ilDB->nextId(
'sc_resource_dependen');
273 INSERT INTO sc_resource_dependen (id, res_id, identifierref, nr)
274 VALUES(%s, %s, %s, %s)',
275 array(
'integer',
'integer',
'text',
'integer'),
276 array($nextId, $this->
getId(), $this->files[
$i]->getHref(), (
$i + 1))
297 array(
'text',
'text',
'text',
'text',
'text',
'integer'),
308 'DELETE FROM sc_resource_file WHERE res_id = %s',
310 array($this->
getId())
313 foreach ($this->files as
$i => $value) {
314 $nextId =
$ilDB->nextId(
'sc_resource_file');
317 'INSERT INTO sc_resource_file (id, res_id, href, nr)
318 VALUES (%s, %s, %s, %s)',
319 array(
'integer',
'integer',
'text',
'integer'),
320 array($nextId, $this->
getId(), $value->getHref(), (
$i + 1))
326 'DELETE FROM sc_resource_dependen WHERE res_id = %s',
328 array($this->
getId())
331 foreach ($this->dependencies as
$i => $value) {
332 $nextId =
$ilDB->nextId(
'sc_resource_dependen');
336 INSERT INTO sc_resource_dependen (id, res_id, identifierref, nr) VALUES
338 array(
'integer',
'integer',
'text',
'integer'),
339 array($nextId, $this->
getId(), $value->getIdentifierRef(), (
$i + 1))
344 public function delete():
void
352 'DELETE FROM sc_resource WHERE obj_id = %s',
354 array($this->
getId())
358 'DELETE FROM sc_resource_file WHERE res_id = %s',
360 array($this->
getId())
364 'DELETE FROM sc_resource_dependen WHERE res_id = %s',
366 array($this->
getId())
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...
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...
setImportId(string $a_import_id)
addFile(ilSCORMResourceFile $a_file_obj)
static _lookupIdByIdRef(string $a_id_ref, int $a_slm_id)
readByIdRef(string $a_id_ref, int $a_slm_id)
setScormType(?string $a_scormtype)
setXmlBase(?string $a_xml_base)
update()
Updates database record for SCORM object.
addDependency(ilSCORMResourceDependency $a_dependency)
static _lookupScormType(int $a_obj_id)
setResourceType(string $a_type)
create()
Create database record for SCORM object.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc