ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilMDEducational.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
31include_once 'class.ilMDBase.php';
32
33class ilMDEducational extends ilMDBase
34{
35 function ilMDEducational($a_rbac_id = 0,$a_obj_id = 0,$a_obj_type = '')
36 {
37 parent::ilMDBase($a_rbac_id,
38 $a_obj_id,
39 $a_obj_type);
40 }
41
42 // Methods for child objects (TypicalAgeRange, Description, Language)
44 {
45 include_once 'Services/Migration/DBUpdate_426/classes/class.ilMDTypicalAgeRange.php';
46
47 return ilMDTypicalAgeRange::_getIds($this->getRBACId(),$this->getObjId(),$this->getMetaId(),'meta_educational');
48 }
49 function &getTypicalAgeRange($a_typical_age_range_id)
50 {
51 include_once 'Services/Migration/DBUpdate_426/classes/class.ilMDTypicalAgeRange.php';
52
53 if(!$a_typical_age_range_id)
54 {
55 return false;
56 }
57 $typ =& new ilMDTypicalAgeRange();
58 $typ->setMetaId($a_typical_age_range_id);
59
60 return $typ;
61 }
63 {
64 include_once 'Services/Migration/DBUpdate_426/classes/class.ilMDTypicalAgeRange.php';
65
66 $typ =& new ilMDTypicalAgeRange($this->getRBACId(),$this->getObjId(),$this->getObjType());
67 $typ->setParentId($this->getMetaId());
68 $typ->setParentType('meta_educational');
69
70 return $typ;
71 }
73 {
74 include_once 'Services/Migration/DBUpdate_426/classes/class.ilMDDescription.php';
75
76 return ilMDDescription::_getIds($this->getRBACId(),$this->getObjId(),$this->getMetaId(),'meta_educational');
77 }
78 function &getDescription($a_description_id)
79 {
80 include_once 'Services/Migration/DBUpdate_426/classes/class.ilMDDescription.php';
81
82 if(!$a_description_id)
83 {
84 return false;
85 }
86 $des =& new ilMDDescription();
87 $des->setMetaId($a_description_id);
88
89 return $des;
90 }
91 function &addDescription()
92 {
93 include_once 'Services/Migration/DBUpdate_426/classes/class.ilMDDescription.php';
94
95 $des =& new ilMDDescription($this->getRBACId(),$this->getObjId(),$this->getObjType());
96 $des->setParentId($this->getMetaId());
97 $des->setParentType('meta_educational');
98
99 return $des;
100 }
101 function &getLanguageIds()
102 {
103 include_once 'Services/Migration/DBUpdate_426/classes/class.ilMDLanguage.php';
104
105 return ilMDLanguage::_getIds($this->getRBACId(),$this->getObjId(),$this->getMetaId(),'meta_educational');
106 }
107 function &getLanguage($a_language_id)
108 {
109 include_once 'Services/Migration/DBUpdate_426/classes/class.ilMDLanguage.php';
110
111 if(!$a_language_id)
112 {
113 return false;
114 }
115 $lan =& new ilMDLanguage();
116 $lan->setMetaId($a_language_id);
117
118 return $lan;
119 }
120 function &addLanguage()
121 {
122 include_once 'Services/Migration/DBUpdate_426/classes/class.ilMDLanguage.php';
123
124 $lan =& new ilMDLanguage($this->getRBACId(),$this->getObjId(),$this->getObjType());
125 $lan->setParentId($this->getMetaId());
126 $lan->setParentType('meta_educational');
127
128 return $lan;
129 }
130
131 // SET/GET
132 function setInteractivityType($a_iat)
133 {
134 switch($a_iat)
135 {
136 case 'Active':
137 case 'Expositive':
138 case 'Mixed':
139 $this->interactivity_type = $a_iat;
140 return true;
141
142 default:
143 return false;
144 }
145 }
147 {
148 return $this->interactivity_type;
149 }
150 function setLearningResourceType($a_lrt)
151 {
152 switch($a_lrt)
153 {
154 case 'Exercise':
155 case 'Simulation':
156 case 'Questionnaire':
157 case 'Diagram':
158 case 'Figure':
159 case 'Graph':
160 case 'Index':
161 case 'Slide':
162 case 'Table':
163 case 'NarrativeText':
164 case 'Exam':
165 case 'Experiment':
166 case 'ProblemStatement':
167 case 'SelfAssessment':
168 case 'Lecture':
169 $this->learning_resource_type = $a_lrt;
170 return true;
171
172 default:
173 return false;
174 }
175 }
177 {
178 return $this->learning_resource_type;
179 }
180 function setInteractivityLevel($a_iat)
181 {
182 switch($a_iat)
183 {
184 case 'VeryLow':
185 case 'Low':
186 case 'Medium':
187 case 'High':
188 case 'VeryHigh':
189 $this->interactivity_level = $a_iat;
190 return true;
191
192 default:
193 return false;
194 }
195 }
197 {
198 return $this->interactivity_level;
199 }
200 function setSemanticDensity($a_sd)
201 {
202 switch($a_sd)
203 {
204 case 'VeryLow':
205 case 'Low':
206 case 'Medium':
207 case 'High':
208 case 'VeryHigh':
209 $this->semantic_density = $a_sd;
210 return true;
211
212 default:
213 return false;
214 }
215 }
217 {
218 return $this->semantic_density;
219 }
220 function setIntendedEndUserRole($a_ieur)
221 {
222 switch($a_ieur)
223 {
224 case 'Teacher':
225 case 'Author':
226 case 'Learner':
227 case 'Manager':
228 $this->intended_end_user_role = $a_ieur;
229 return true;
230
231 default:
232 return false;
233 }
234 }
236 {
237 return $this->intended_end_user_role;
238 }
239 function setContext($a_context)
240 {
241 switch($a_context)
242 {
243 case 'School':
244 case 'HigherEducation':
245 case 'Training':
246 case 'Other':
247 $this->context = $a_context;
248 return true;
249
250 default:
251 return false;
252 }
253 }
254 function getContext()
255 {
256 return $this->context;
257 }
258 function setDifficulty($a_difficulty)
259 {
260 switch($a_difficulty)
261 {
262 case 'VeryEasy':
263 case 'Easy':
264 case 'Medium':
265 case 'Difficult':
266 case 'VeryDifficult':
267 $this->difficulty = $a_difficulty;
268 return true;
269
270 default:
271 return false;
272 }
273 }
274 function getDifficulty()
275 {
276 return $this->difficulty;
277 }
278 function setTypicalLearningTime($a_tlt)
279 {
280 $this->typical_learning_time = $a_tlt;
281 }
283 {
284 return $this->typical_learning_time;
285 }
286
287
288 function save()
289 {
290 if($this->db->autoExecute('il_meta_educational',
291 $this->__getFields(),
292 DB_AUTOQUERY_INSERT))
293 {
294 $this->setMetaId($this->db->getLastInsertId());
295
296 return $this->getMetaId();
297 }
298
299 return false;
300 }
301
302 function update()
303 {
304 global $ilDB;
305
306 if($this->getMetaId())
307 {
308 if($this->db->autoExecute('il_meta_educational',
309 $this->__getFields(),
310 DB_AUTOQUERY_UPDATE,
311 "meta_educational_id = ".$ilDB->quote($this->getMetaId())))
312 {
313 return true;
314 }
315 }
316 return false;
317 }
318
319 function delete()
320 {
321 global $ilDB;
322
323 if($this->getMetaId())
324 {
325 $query = "DELETE FROM il_meta_educational ".
326 "WHERE meta_educational_id = ".$ilDB->quote($this->getMetaId());
327
328 $this->db->query($query);
329
330 foreach($this->getTypicalAgeRangeIds() as $id)
331 {
332 $typ =& $this->getTypicalAgeRange($id);
333 $typ->delete();
334 }
335 foreach($this->getDescriptionIds() as $id)
336 {
337 $des =& $this->getDescription($id);
338 $des->delete();
339 }
340 foreach($this->getLanguageIds() as $id)
341 {
342 $lan =& $this->getLanguage($id);
343 $lan->delete();
344 }
345
346
347 return true;
348 }
349 return false;
350 }
351
352
353 function __getFields()
354 {
355 return array('rbac_id' => $this->getRBACId(),
356 'obj_id' => $this->getObjId(),
357 'obj_type' => ilUtil::prepareDBString($this->getObjType()),
358 'interactivity_type' => ilUtil::prepareDBString($this->getInteractivityType()),
359 'learning_resource_type' => ilUtil::prepareDBString($this->getLearningResourceType()),
360 'interactivity_level' => ilUtil::prepareDBString($this->getInteractivityLevel()),
361 'semantic_density' => ilUtil::prepareDBString($this->getSemanticDensity()),
362 'intended_end_user_role' => ilUtil::prepareDBString($this->getIntendedEndUserRole()),
363 'context' => ilUtil::prepareDBString($this->getContext()),
364 'difficulty' => ilUtil::prepareDBString($this->getDifficulty()),
365 'typical_learning_time' => ilUtil::prepareDBString($this->getTypicalLearningTime()));
366 }
367
368 function read()
369 {
370 global $ilDB;
371
372 if($this->getMetaId())
373 {
374
375 $query = "SELECT * FROM il_meta_educational ".
376 "WHERE meta_educational_id = ".$ilDB->quote($this->getMetaId());
377
378
379 $res = $this->db->query($query);
380 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
381 {
382 $this->setRBACId($row->rbac_id);
383 $this->setObjId($row->obj_id);
384 $this->setObjType($row->obj_type);
385 $this->setInteractivityType(ilUtil::stripSlashes($row->interactivity_type));
386 $this->setLearningResourceType(ilUtil::stripSlashes($row->learning_resource_type));
387 $this->setInteractivityLevel(ilUtil::stripSlashes($row->interactivity_level));
388 $this->setSemanticDensity(ilUtil::stripSlashes($row->semantic_density));
389 $this->setIntendedEndUserRole(ilUtil::stripSlashes($row->intended_end_user_role));
390 $this->setContext(ilUtil::stripSlashes($row->context));
391 $this->setDifficulty(ilUtil::stripSlashes($row->difficulty));
392 $this->setTypicalLearningTime(ilUtil::stripSlashes($row->typical_learning_time));
393 }
394 return true;
395 }
396 return false;
397 }
398
399 /*
400 * XML Export of all meta data
401 * @param object (xml writer) see class.ilMD2XML.php
402 *
403 */
404 function toXML(&$writer)
405 {
406 $writer->xmlStartTag('Educational',
407 array('InteractivityType' => $this->getInteractivityType(),
408 'LearningResourceType' => $this->getLearningResourceType(),
409 'InteractivityLevel' => $this->getInteractivityLevel(),
410 'SemanticDensity' => $this->getSemanticDensity(),
411 'IntendedEndUserRole' => $this->getIntendedEndUserRole(),
412 'Context' => $this->getContext(),
413 'Difficulty' => $this->getDifficulty()));
414
415 // TypicalAgeRange
416 foreach($this->getTypicalAgeRangeIds() as $id)
417 {
418 $key =& $this->getTypicalAgeRange($id);
419 $key->toXML($writer);
420 }
421 // TypicalLearningTime
422 $writer->xmlElement('TypicalLearningTime',null,$this->getTypicalLearningTime());
423
424 // Description
425 foreach($this->getDescriptionIds() as $id)
426 {
427 $key =& $this->getDescription($id);
428 $key->toXML($writer);
429 }
430 // Language
431 foreach($this->getLanguageIds() as $id)
432 {
433 $lang =& $this->getLanguage($id);
434 $lang->toXML($writer);
435 }
436 $writer->xmlEndTag('Educational');
437 }
438 // STATIC
439 function _getId($a_rbac_id,$a_obj_id)
440 {
441 global $ilDB;
442
443 $query = "SELECT meta_educational_id FROM il_meta_educational ".
444 "WHERE rbac_id = ".$ilDB->quote($a_rbac_id)." ".
445 "AND obj_id = ".$ilDB->quote($a_obj_id);
446
447 $res = $ilDB->query($query);
448 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
449 {
450 return $row->meta_educational_id;
451 }
452 return false;
453 }
454}
455?>
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
setObjId($a_id)
setMetaId($a_meta_id, $a_read_data=true)
setObjType($a_type)
setRBACId($a_id)
_getIds($a_rbac_id, $a_obj_id, $a_parent_id, $a_parent_type)
_getId($a_rbac_id, $a_obj_id)
& getTypicalAgeRange($a_typical_age_range_id)
ilMDEducational($a_rbac_id=0, $a_obj_id=0, $a_obj_type='')
& getDescription($a_description_id)
setDifficulty($a_difficulty)
& getLanguage($a_language_id)
_getIds($a_rbac_id, $a_obj_id, $a_parent_id, $a_parent_type)
_getIds($a_rbac_id, $a_obj_id, $a_parent_id, $a_parent_type)
static prepareDBString($a_str)
prepare a string for db writing (insert/update)
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
global $ilDB