ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilSCORMObject.php
Go to the documentation of this file.
1<?php
2/*
3 +-----------------------------------------------------------------------------+
4 | ILIAS open source |
5 +-----------------------------------------------------------------------------+
6 | Copyright (c) 1998-2001 ILIAS open source, University of Cologne |
7 | |
8 | This program is free software; you can redistribute it and/or |
9 | modify it under the terms of the GNU General Public License |
10 | as published by the Free Software Foundation; either version 2 |
11 | of the License, or (at your option) any later version. |
12 | |
13 | This program is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | GNU General Public License for more details. |
17 | |
18 | You should have received a copy of the GNU General Public License |
19 | along with this program; if not, write to the Free Software |
20 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21 +-----------------------------------------------------------------------------+
22*/
23
24
34{
35 public $id;
36 public $title;
37 public $type;
38 public $slm_id;
39
40
47 public function __construct($a_id = 0)
48 {
49 global $DIC;
50 $ilias = $DIC['ilias'];
51
52 $this->ilias = $ilias;
53 $this->id = $a_id;
54 if ($a_id > 0) {
55 $this->read();
56 }
57 }
58
59 public function getId()
60 {
61 return $this->id;
62 }
63
64 public function setId($a_id)
65 {
66 $this->id = $a_id;
67 }
68
69 public function getType()
70 {
71 return $this->type;
72 }
73
74 public function setType($a_type)
75 {
76 $this->type = $a_type;
77 }
78
79 public function getTitle()
80 {
81 return $this->title;
82 }
83
84 public function setTitle($a_title)
85 {
86 $this->title = $a_title;
87 }
88
89 public function getSLMId()
90 {
91 return $this->slm_id;
92 }
93
94 public function setSLMId($a_slm_id)
95 {
96 $this->slm_id = $a_slm_id;
97 }
98
99 public function read()
100 {
101 global $DIC;
102 $ilDB = $DIC['ilDB'];
103
104 $obj_set = $ilDB->queryF(
105 'SELECT * FROM scorm_object WHERE obj_id = %s',
106 array('integer'),
107 array($this->getId())
108 );
109 $obj_rec = $ilDB->fetchAssoc($obj_set);
110 $this->setTitle($obj_rec["title"]);
111 $this->setType($obj_rec["c_type"]);
112 $this->setSLMId($obj_rec["slm_id"]);
113 }
114
118 public static function _lookupPresentableItems($a_slm_id)
119 {
120 global $DIC;
121 $ilDB = $DIC['ilDB'];
122
123 $set = $ilDB->queryF(
124 "
125 SELECT sit.obj_id id
126 FROM scorm_object sob, sc_item sit
127 WHERE sob.slm_id = %s
128 AND sob.obj_id = sit.obj_id
129 AND sit.identifierref IS NOT NULL",
130 array('integer'),
131 array($a_slm_id)
132 );
133 $items = array();
134 while ($rec = $ilDB->fetchAssoc($set)) {
135 $items[] = $rec["id"];
136 }
137
138 return $items;
139 }
140
145 public function create()
146 {
147 global $DIC;
148 $ilDB = $DIC['ilDB'];
149
150 $nextId = $ilDB->nextId('scorm_object');
151 $this->setId($nextId);
152
153 $ilDB->manipulateF(
154 '
155 INSERT INTO scorm_object (obj_id,title, c_type, slm_id)
156 VALUES (%s,%s,%s,%s) ',
157 array('integer','text','text','integer'),
158 array($nextId, $this->getTitle(),$this->getType(), $this->getSLMId())
159 );
160 }
161
166 public function update()
167 {
168 global $DIC;
169 $ilDB = $DIC['ilDB'];
170
171 $ilDB->manipulateF(
172 '
173 UPDATE scorm_object
174 SET title = %s,
175 c_type = %s,
176 slm_id = %s
177 WHERE obj_id = %s',
178 array('text','text','integer','integer'),
179 array($this->getTitle(),$this->getType(), $this->getSLMId(),$this->getId())
180 );
181 }
182
183 public function delete()
184 {
185 global $DIC;
186 $ilDB = $DIC['ilDB'];
187 $ilDB->manipulateF(
188 'DELETE FROM scorm_object WHERE obj_id = %s',
189 array('integer'),
190 array($this->getId())
191 );
192 }
193
199 public static function &_getInstance($a_id, $a_slm_id)
200 {
201 global $DIC;
202 $ilDB = $DIC['ilDB'];
203
204 $sc_set = $ilDB->queryF(
205 '
206 SELECT c_type FROM scorm_object
207 WHERE obj_id = %s
208 AND slm_id = %s',
209 array('integer','integer'),
210 array($a_id, $a_slm_id)
211 );
212 $sc_rec = $ilDB->fetchAssoc($sc_set);
213
214 switch ($sc_rec["c_type"]) {
215 case "sit": // item
216 include_once("./Modules/ScormAicc/classes/SCORM/class.ilSCORMItem.php");
217 $item = new ilSCORMItem($a_id);
218 return $item;
219 break;
220
221 case "sos": // organizations
222 include_once("./Modules/ScormAicc/classes/SCORM/class.ilSCORMOrganizations.php");
223 $sos = new ilSCORMOrganizations($a_id);
224 return $sos;
225 break;
226
227 case "sor": // organization
228 include_once("./Modules/ScormAicc/classes/SCORM/class.ilSCORMOrganization.php");
229 $sor = new ilSCORMOrganization($a_id);
230 return $sor;
231 break;
232
233 case "sma": // manifest
234 include_once("./Modules/ScormAicc/classes/SCORM/class.ilSCORMManifest.php");
235 $sma = new ilSCORMManifest($a_id);
236 return $sma;
237 break;
238
239 case "srs": // resources
240 include_once("./Modules/ScormAicc/classes/SCORM/class.ilSCORMResources.php");
241 $srs = new ilSCORMResources($a_id);
242 return $srs;
243 break;
244
245 case "sre": // resource
246 include_once("./Modules/ScormAicc/classes/SCORM/class.ilSCORMResource.php");
247 $sre = new ilSCORMResource($a_id);
248 return $sre;
249 break;
250 }
251 }
252}
An exception for terminatinating execution or to throw for unit testing.
Parent object for all SCORM objects, that are stored in table scorm_object.
static _lookupPresentableItems($a_slm_id)
Count number of presentable SCOs/Assets of SCORM learning module.
__construct($a_id=0)
Constructor.
create()
Create database record for SCORM object.
static & _getInstance($a_id, $a_slm_id)
get instance of specialized GUI class
update()
Updates database record for SCORM object.
SCORM Resources Element.
redirection script todo: (a better solution should control the processing via a xml file)
global $ilDB
$a_type
Definition: workflow.php:92
$DIC
Definition: xapitoken.php:46