3 declare(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;
129 $ilDB = $DIC->database();
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'];
174 $ilDB = $DIC->database();
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'];
199 $ilDB = $DIC->database();
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"];
219 $ilDB = $DIC->database();
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"];
235 $ilDB = $DIC->database();
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))
284 $ilDB = $DIC->database();
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 347 $ilDB = $DIC->database();
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...
setResourceType(string $a_type)
static _lookupScormType(int $a_obj_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
addFile(ilSCORMResourceFile $a_file_obj)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setScormType(?string $a_scormtype)
setTitle(string $a_title)
addDependency(ilSCORMResourceDependency $a_dependency)
setXmlBase(?string $a_xml_base)
static _lookupIdByIdRef(string $a_id_ref, int $a_slm_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(Container $dic, ilPlugin $plugin)
readByIdRef(string $a_id_ref, int $a_slm_id)
setImportId(string $a_import_id)