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