24 require_once(
"./Modules/ScormAicc/classes/SCORM/class.ilSCORMObject.php");
25 require_once(
"./Modules/ScormAicc/classes/SCORM/class.ilSCORMResourceFile.php");
26 require_once(
"./Modules/ScormAicc/classes/SCORM/class.ilSCORMResourceDependency.php");
55 $this->files = array();
56 $this->dependencies = array();
69 $this->import_id = $a_import_id;
79 $this->resourcetype = $a_type;
89 $this->scormtype = $a_scormtype;
99 $this->href = $a_href;
110 $this->xml_base = $a_xml_base;
115 $this->files[] =& $a_file_obj;
125 $this->dependencies[] =& $a_dependency;
139 $obj_set = $ilDB->queryF(
140 'SELECT * FROM sc_resource WHERE obj_id = %s',
142 array($this->
getId())
144 $obj_rec = $ilDB->fetchAssoc($obj_set);
148 $this->
setHRef($obj_rec[
"href"]);
152 $file_set = $ilDB->queryF(
153 'SELECT href FROM sc_resource_file WHERE res_id = %s ORDER BY nr',
155 array($this->
getId())
157 while ($file_rec =$ilDB->fetchAssoc($file_set))
160 $res_file->setHref($file_rec[
"href"]);
165 $dep_set = $ilDB->queryF(
166 'SELECT identifierref FROM sc_resource_dependen WHERE res_id = %s ORDER BY nr',
168 array($this->
getId())
170 while ($dep_rec =$ilDB->fetchAssoc($dep_set))
173 $res_dep->setIdentifierRef($dep_rec[
"identifierref"]);
182 $ilBench->start(
"SCORMResource",
"readByIdRef_Query");
184 $id_set = $ilDB->queryF(
185 'SELECT ob.obj_id id FROM sc_resource res, scorm_object ob
186 WHERE ob.obj_id = res.obj_id
187 AND res.import_id = %s
189 array(
'text',
'integer'),
190 array($a_id_ref, $a_slm_id)
193 $ilBench->stop(
"SCORMResource",
"readByIdRef_Query");
195 if ($id_rec = $ilDB->fetchAssoc($id_set))
197 $this->
setId($id_rec[
"id"]);
206 $id_set = $ilDB->queryF(
207 'SELECT ob.obj_id id FROM sc_resource res, scorm_object ob
208 WHERE ob.obj_id = res.obj_id
209 AND res.import_id = %s
211 array(
'text',
'integer'),
212 array($a_id_ref ,$a_slm_id)
215 if ($id_rec = $ilDB->fetchAssoc($id_set))
217 return $id_rec[
"id"];
226 $st_set = $ilDB->queryF(
227 'SELECT scormtype FROM sc_resource WHERE obj_id = %s',
231 if ($st_rec = $ilDB->fetchAssoc($st_set))
233 return $st_rec[
"scormtype"];
245 INSERT INTO sc_resource
246 (obj_id, import_id, resourcetype, scormtype, href, xml_base)
247 VALUES(%s, %s, %s, %s, %s, %s)',
248 array(
'integer',
'text',
'text',
'text',
'text',
'text'),
249 array( $this->
getId(),
259 for($i=0; $i<count($this->files); $i++)
261 $nextId = $ilDB->nextId(
'sc_resource_file');
264 INSERT INTO sc_resource_file (id,res_id, href, nr)
265 VALUES(%s, %s, %s, %s)',
266 array(
'integer',
'integer',
'text',
'integer'),
267 array($nextId, $this->
getId(), $this->files[$i]->getHref(), ($i + 1))
273 for($i=0; $i<count($this->dependencies); $i++)
275 $nextId = $ilDB->nextId(
'sc_resource_dependen');
278 INSERT INTO sc_resource_dependen (id, res_id, identifierref, nr)
279 VALUES(%s, %s, %s, %s)',
280 array(
'integer',
'integer',
'text',
'integer'),
281 array($nextId, $this->
getId(), $this->files[$i]->getHref(), ($i + 1))
300 array(
'text',
'text',
'text',
'text',
'text',
'integer'),
311 'DELETE FROM sc_resource_file WHERE res_id = %s',
313 array($this->
getId())
316 for($i=0; $i<count($this->files); $i++)
318 $nextId = $ilDB->nextId(
'sc_resource_file');
321 'INSERT INTO sc_resource_file (id, res_id, href, nr)
322 VALUES (%s, %s, %s, %s)',
323 array(
'integer',
'integer',
'text',
'integer'),
324 array($nextId, $this->
getId(), $this->files[$i]->getHref(), ($i + 1))
330 'DELETE FROM sc_resource_dependen WHERE res_id = %s',
332 array($this->
getId())
335 for($i = 0; $i < count($this->dependencies); $i++)
337 $nextId = $ilDB->nextId(
'sc_resource_dependen');
340 INSERT INTO sc_resource_dependen (id, res_id, identifierref, nr) VALUES
342 array(
'integer',
'integer',
'text',
'integer'),
343 array($nextId, $this->
getId(), $this->dependencies[$i]->getIdentifierRef(), ($i + 1))
355 'DELETE FROM sc_resource WHERE obj_id = %s',
357 array($this->
getId())
361 'DELETE FROM sc_resource_file WHERE res_id = %s',
363 array($this->
getId())
367 'DELETE FROM sc_resource_dependen WHERE res_id = %s',
369 array($this->
getId())