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