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
34{
35 // Methods for child objects (TypicalAgeRange, Description, Language)
37 {
38 include_once 'Services/MetaData/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/MetaData/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/MetaData/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/MetaData/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/MetaData/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/MetaData/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/MetaData/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/MetaData/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/MetaData/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
272 function setPhysicalTypicalLearningTime($months,$days,$hours,$minutes,$seconds)
273 {
274 if(!$months and !$days and !$hours and !$minutes and !$seconds)
275 {
276 $this->setTypicalLearningTime('PT00H00M');
277 return true;
278 }
279 $tlt = 'P';
280 if($months)
281 {
282 $tlt .= ($months.'M');
283 }
284 if($days)
285 {
286 $tlt .= ($days.'D');
287 }
288 if($hours or $minutes or $seconds)
289 {
290 $tlt .= 'T';
291 }
292 if($hours)
293 {
294 $tlt .= ($hours.'H');
295 }
296 if($minutes)
297 {
298 $tlt .= ($minutes.'M');
299 }
300 if($seconds)
301 {
302 $tlt .= ($seconds.'S');
303 }
304 $this->setTypicalLearningTime($tlt);
305 return true;
306 }
307
308
309 function setTypicalLearningTime($a_tlt)
310 {
311 $this->typical_learning_time = $a_tlt;
312 }
314 {
315 return $this->typical_learning_time;
316 }
317
319 {
320 include_once './Services/MetaData/classes/class.ilMDUtils.php';
321
323
324 return 60 * 60 * 24 * 30 * $time_arr[0] + 60 * 60 * 24 * $time_arr[1] + 60 * 60 * $time_arr[2] + 60 * $time_arr[3] + $time_arr[4];
325 }
326
327 function save()
328 {
329 global $ilDB;
330
331 $fields = $this->__getFields();
332 $fields['meta_educational_id'] = array('integer',$next_id = $ilDB->nextId('il_meta_educational'));
333
334 if($this->db->insert('il_meta_educational',$fields))
335 {
336 $this->setMetaId($next_id);
337 return $this->getMetaId();
338 }
339 return false;
340 }
341
342 function update()
343 {
344 global $ilDB;
345
346 if($this->getMetaId())
347 {
348 if($this->db->update('il_meta_educational',
349 $this->__getFields(),
350 array("meta_educational_id" => array('integer',$this->getMetaId()))))
351 {
352 return true;
353 }
354 }
355 return false;
356 }
357
358 function delete()
359 {
360 global $ilDB;
361
362 if($this->getMetaId())
363 {
364 $query = "DELETE FROM il_meta_educational ".
365 "WHERE meta_educational_id = ".$ilDB->quote($this->getMetaId());
366 $res = $ilDB->manipulate($query);
367
368 foreach($this->getTypicalAgeRangeIds() as $id)
369 {
370 $typ = $this->getTypicalAgeRange($id);
371 $typ->delete();
372 }
373 foreach($this->getDescriptionIds() as $id)
374 {
375 $des = $this->getDescription($id);
376 $des->delete();
377 }
378 foreach($this->getLanguageIds() as $id)
379 {
380 $lan = $this->getLanguage($id);
381 $lan->delete();
382 }
383
384
385 return true;
386 }
387 return false;
388 }
389
390
391 function __getFields()
392 {
393 return array('rbac_id' => array('integer',$this->getRBACId()),
394 'obj_id' => array('integer',$this->getObjId()),
395 'obj_type' => array('text',$this->getObjType()),
396 'interactivity_type' => array('text',$this->getInteractivityType()),
397 'learning_resource_type' => array('text',$this->getLearningResourceType()),
398 'interactivity_level' => array('text',$this->getInteractivityLevel()),
399 'semantic_density' => array('text',$this->getSemanticDensity()),
400 'intended_end_user_role' => array('text',$this->getIntendedEndUserRole()),
401 'context' => array('text',$this->getContext()),
402 'difficulty' => array('text',$this->getDifficulty()),
403 'typical_learning_time' => array('text',$this->getTypicalLearningTime()));
404 }
405
406 function read()
407 {
408 global $ilDB;
409
410 if($this->getMetaId())
411 {
412
413 $query = "SELECT * FROM il_meta_educational ".
414 "WHERE meta_educational_id = ".$ilDB->quote($this->getMetaId() ,'integer');
415
416
417 $res = $this->db->query($query);
418 while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
419 {
420 $this->setRBACId($row->rbac_id);
421 $this->setObjId($row->obj_id);
422 $this->setObjType($row->obj_type);
423 $this->setInteractivityType($row->interactivity_type);
424 $this->setLearningResourceType($row->learning_resource_type);
425 $this->setInteractivityLevel($row->interactivity_level);
426 $this->setSemanticDensity($row->semantic_density);
427 $this->setIntendedEndUserRole($row->intended_end_user_role);
428 $this->setContext($row->context);
429 $this->setDifficulty($row->difficulty);
430 $this->setTypicalLearningTime($row->typical_learning_time);
431 }
432 return true;
433 }
434 return false;
435 }
436
437 /*
438 * XML Export of all meta data
439 * @param object (xml writer) see class.ilMD2XML.php
440 *
441 */
442 function toXML(&$writer)
443 {
444 $writer->xmlStartTag('Educational',
445 array('InteractivityType' => $this->getInteractivityType()
446 ? $this->getInteractivityType()
447 : 'Active',
448 'LearningResourceType' => $this->getLearningResourceType()
449 ? $this->getLearningResourceType()
450 : 'Exercise',
451 'InteractivityLevel' => $this->getInteractivityLevel()
452 ? $this->getInteractivityLevel()
453 : 'Medium',
454 'SemanticDensity' => $this->getSemanticDensity()
455 ? $this->getSemanticDensity()
456 : 'Medium',
457 'IntendedEndUserRole' => $this->getIntendedEndUserRole()
458 ? $this->getIntendedEndUserRole()
459 : 'Learner',
460 'Context' => $this->getContext()
461 ? $this->getContext()
462 : 'Other',
463 'Difficulty' => $this->getDifficulty()
464 ? $this->getDifficulty()
465 : 'Medium'));
466
467 // TypicalAgeRange
468 $typ_ages = $this->getTypicalAgeRangeIds();
469 foreach($typ_ages as $id)
470 {
471 $key =& $this->getTypicalAgeRange($id);
472
473 // extra test due to bug 5316 (may be due to eLaix import)
474 if (is_object($key))
475 {
476 $key->toXML($writer);
477 }
478 }
479 if(!count($typ_ages))
480 {
481 include_once 'Services/MetaData/classes/class.ilMDTypicalAgeRange.php';
482 $typ = new ilMDTypicalAgeRange($this->getRBACId(),$this->getObjId());
483 $typ->toXML($writer);
484 }
485
486 // TypicalLearningTime
487 $writer->xmlElement('TypicalLearningTime',null,$this->getTypicalLearningTime());
488
489 // Description
490 foreach($this->getDescriptionIds() as $id)
491 {
492 $key =& $this->getDescription($id);
493 $key->toXML($writer);
494 }
495 // Language
496 foreach($this->getLanguageIds() as $id)
497 {
498 $lang =& $this->getLanguage($id);
499 $lang->toXML($writer);
500 }
501 $writer->xmlEndTag('Educational');
502 }
503 // STATIC
504 static function _getId($a_rbac_id,$a_obj_id)
505 {
506 global $ilDB;
507
508 $query = "SELECT meta_educational_id FROM il_meta_educational ".
509 "WHERE rbac_id = ".$ilDB->quote($a_rbac_id ,'integer')." ".
510 "AND obj_id = ".$ilDB->quote($a_obj_id ,'integer');
511
512 $res = $ilDB->query($query);
513 while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
514 {
515 return $row->meta_educational_id;
516 }
517 return false;
518 }
519
520 static function _getTypicalLearningTimeSeconds($a_rbac_id,$a_obj_id = 0)
521 {
522 global $ilDB;
523
524 $a_obj_id = $a_obj_id ? $a_obj_id : $a_rbac_id;
525
526 $query = "SELECT typical_learning_time FROM il_meta_educational ".
527 "WHERE rbac_id = ".$ilDB->quote($a_rbac_id ,'integer')." ".
528 "AND obj_id = ".$ilDB->quote($a_obj_id ,'integer');
529 $res = $ilDB->query($query);
530 while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
531 {
532 include_once './Services/MetaData/classes/class.ilMDUtils.php';
533
534 $time_arr = ilMDUtils::_LOMDurationToArray($row->typical_learning_time);
535
536 return 60 * 60 * 24 * 30 * $time_arr[0] +
537 60 * 60 * 24 * $time_arr[1] +
538 60 * 60 * $time_arr[2] +
539 60 * $time_arr[3] +
540 $time_arr[4];
541 }
542 return 0;
543 }
544
545}
546?>
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)
setPhysicalTypicalLearningTime($months, $days, $hours, $minutes, $seconds)
& getTypicalAgeRange($a_typical_age_range_id)
static _getId($a_rbac_id, $a_obj_id)
& getDescription($a_description_id)
setDifficulty($a_difficulty)
& getLanguage($a_language_id)
static _getTypicalLearningTimeSeconds($a_rbac_id, $a_obj_id=0)
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 _LOMDurationToArray($a_string)
LOM datatype duration is a string like P2M4DT7H18M2S (2 months 4 days 7 hours 18 minutes 2 seconds) T...
for($i=1; $i<=count($kw_cases_sel); $i+=1) $lang
Definition: langwiz.php:349
global $ilDB