ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 $ilias;
50
51 $this->ilias = $ilias;
52 $this->id = $a_id;
53 if ($a_id > 0) {
54 $this->read();
55 }
56 }
57
58 public function getId()
59 {
60 return $this->id;
61 }
62
63 public function setId($a_id)
64 {
65 $this->id = $a_id;
66 }
67
68 public function getType()
69 {
70 return $this->type;
71 }
72
73 public function setType($a_type)
74 {
75 $this->type = $a_type;
76 }
77
78 public function getTitle()
79 {
80 return $this->title;
81 }
82
83 public function setTitle($a_title)
84 {
85 $this->title = $a_title;
86 }
87
88 public function getSLMId()
89 {
90 return $this->slm_id;
91 }
92
93 public function setSLMId($a_slm_id)
94 {
95 $this->slm_id = $a_slm_id;
96 }
97
98 public function read()
99 {
100 global $ilDB;
101
102 $obj_set = $ilDB->queryF(
103 'SELECT * FROM scorm_object WHERE obj_id = %s',
104 array('integer'),
105 array($this->getId())
106 );
107 $obj_rec = $ilDB->fetchAssoc($obj_set);
108 $this->setTitle($obj_rec["title"]);
109 $this->setType($obj_rec["c_type"]);
110 $this->setSLMId($obj_rec["slm_id"]);
111 }
112
116 public static function _lookupPresentableItems($a_slm_id)
117 {
118 global $ilDB;
119
120 $set = $ilDB->queryF(
121 "
122 SELECT sit.obj_id id
123 FROM scorm_object sob, sc_item sit
124 WHERE sob.slm_id = %s
125 AND sob.obj_id = sit.obj_id
126 AND sit.identifierref IS NOT NULL",
127 array('integer'),
128 array($a_slm_id)
129 );
130 $items = array();
131 while ($rec = $ilDB->fetchAssoc($set)) {
132 $items[] = $rec["id"];
133 }
134
135 return $items;
136 }
137
142 public function create()
143 {
144 global $ilDB;
145
146 $nextId = $ilDB->nextId('scorm_object');
147 $this->setId($nextId);
148
149 $ilDB->manipulateF(
150 '
151 INSERT INTO scorm_object (obj_id,title, c_type, slm_id)
152 VALUES (%s,%s,%s,%s) ',
153 array('integer','text','text','integer'),
154 array($nextId, $this->getTitle(),$this->getType(), $this->getSLMId())
155 );
156 }
157
162 public function update()
163 {
164 global $ilDB;
165
166 $ilDB->manipulateF(
167 '
168 UPDATE scorm_object
169 SET title = %s,
170 c_type = %s,
171 slm_id = %s
172 WHERE obj_id = %s',
173 array('text','text','integer','integer'),
174 array($this->getTitle(),$this->getType(), $this->getSLMId(),$this->getId())
175 );
176 }
177
178 public function delete()
179 {
180 global $ilDB;
181 $ilDB->manipulateF(
182 'DELETE FROM scorm_object WHERE obj_id = %s',
183 array('integer'),
184 array($this->getId())
185 );
186 }
187
193 public static function &_getInstance($a_id, $a_slm_id)
194 {
195 global $ilDB;
196
197 $sc_set = $ilDB->queryF(
198 '
199 SELECT c_type FROM scorm_object
200 WHERE obj_id = %s
201 AND slm_id = %s',
202 array('integer','integer'),
203 array($a_id, $a_slm_id)
204 );
205 $sc_rec = $ilDB->fetchAssoc($sc_set);
206
207 switch ($sc_rec["c_type"]) {
208 case "sit": // item
209 include_once("./Modules/ScormAicc/classes/SCORM/class.ilSCORMItem.php");
210 $item = new ilSCORMItem($a_id);
211 return $item;
212 break;
213
214 case "sos": // organizations
215 include_once("./Modules/ScormAicc/classes/SCORM/class.ilSCORMOrganizations.php");
216 $sos = new ilSCORMOrganizations($a_id);
217 return $sos;
218 break;
219
220 case "sor": // organization
221 include_once("./Modules/ScormAicc/classes/SCORM/class.ilSCORMOrganization.php");
222 $sor = new ilSCORMOrganization($a_id);
223 return $sor;
224 break;
225
226 case "sma": // manifest
227 include_once("./Modules/ScormAicc/classes/SCORM/class.ilSCORMManifest.php");
228 $sma = new ilSCORMManifest($a_id);
229 return $sma;
230 break;
231
232 case "srs": // resources
233 include_once("./Modules/ScormAicc/classes/SCORM/class.ilSCORMResources.php");
234 $srs = new ilSCORMResources($a_id);
235 return $srs;
236 break;
237
238 case "sre": // resource
239 include_once("./Modules/ScormAicc/classes/SCORM/class.ilSCORMResource.php");
240 $sre = new ilSCORMResource($a_id);
241 return $sre;
242 break;
243 }
244 }
245}
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