00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00031 include_once 'class.ilMDBase.php';
00032
00033 class ilMDEducational extends ilMDBase
00034 {
00035 function ilMDEducational($a_rbac_id = 0,$a_obj_id = 0,$a_obj_type = '')
00036 {
00037 parent::ilMDBase($a_rbac_id,
00038 $a_obj_id,
00039 $a_obj_type);
00040 }
00041
00042
00043 function &getTypicalAgeRangeIds()
00044 {
00045 include_once 'Services/MetaData/classes/class.ilMDTypicalAgeRange.php';
00046
00047 return ilMDTypicalAgeRange::_getIds($this->getRBACId(),$this->getObjId(),$this->getMetaId(),'meta_educational');
00048 }
00049 function &getTypicalAgeRange($a_typical_age_range_id)
00050 {
00051 include_once 'Services/MetaData/classes/class.ilMDTypicalAgeRange.php';
00052
00053 if(!$a_typical_age_range_id)
00054 {
00055 return false;
00056 }
00057 $typ =& new ilMDTypicalAgeRange();
00058 $typ->setMetaId($a_typical_age_range_id);
00059
00060 return $typ;
00061 }
00062 function &addTypicalAgeRange()
00063 {
00064 include_once 'Services/MetaData/classes/class.ilMDTypicalAgeRange.php';
00065
00066 $typ =& new ilMDTypicalAgeRange($this->getRBACId(),$this->getObjId(),$this->getObjType());
00067 $typ->setParentId($this->getMetaId());
00068 $typ->setParentType('meta_educational');
00069
00070 return $typ;
00071 }
00072 function &getDescriptionIds()
00073 {
00074 include_once 'Services/MetaData/classes/class.ilMDDescription.php';
00075
00076 return ilMDDescription::_getIds($this->getRBACId(),$this->getObjId(),$this->getMetaId(),'meta_educational');
00077 }
00078 function &getDescription($a_description_id)
00079 {
00080 include_once 'Services/MetaData/classes/class.ilMDDescription.php';
00081
00082 if(!$a_description_id)
00083 {
00084 return false;
00085 }
00086 $des =& new ilMDDescription();
00087 $des->setMetaId($a_description_id);
00088
00089 return $des;
00090 }
00091 function &addDescription()
00092 {
00093 include_once 'Services/MetaData/classes/class.ilMDDescription.php';
00094
00095 $des =& new ilMDDescription($this->getRBACId(),$this->getObjId(),$this->getObjType());
00096 $des->setParentId($this->getMetaId());
00097 $des->setParentType('meta_educational');
00098
00099 return $des;
00100 }
00101 function &getLanguageIds()
00102 {
00103 include_once 'Services/MetaData/classes/class.ilMDLanguage.php';
00104
00105 return ilMDLanguage::_getIds($this->getRBACId(),$this->getObjId(),$this->getMetaId(),'meta_educational');
00106 }
00107 function &getLanguage($a_language_id)
00108 {
00109 include_once 'Services/MetaData/classes/class.ilMDLanguage.php';
00110
00111 if(!$a_language_id)
00112 {
00113 return false;
00114 }
00115 $lan =& new ilMDLanguage();
00116 $lan->setMetaId($a_language_id);
00117
00118 return $lan;
00119 }
00120 function &addLanguage()
00121 {
00122 include_once 'Services/MetaData/classes/class.ilMDLanguage.php';
00123
00124 $lan =& new ilMDLanguage($this->getRBACId(),$this->getObjId(),$this->getObjType());
00125 $lan->setParentId($this->getMetaId());
00126 $lan->setParentType('meta_educational');
00127
00128 return $lan;
00129 }
00130
00131
00132 function setInteractivityType($a_iat)
00133 {
00134 switch($a_iat)
00135 {
00136 case 'Active':
00137 case 'Expositive':
00138 case 'Mixed':
00139 $this->interactivity_type = $a_iat;
00140 return true;
00141
00142 default:
00143 return false;
00144 }
00145 }
00146 function getInteractivityType()
00147 {
00148 return $this->interactivity_type;
00149 }
00150 function setLearningResourceType($a_lrt)
00151 {
00152 switch($a_lrt)
00153 {
00154 case 'Exercise':
00155 case 'Simulation':
00156 case 'Questionnaire':
00157 case 'Diagram':
00158 case 'Figure':
00159 case 'Graph':
00160 case 'Index':
00161 case 'Slide':
00162 case 'Table':
00163 case 'NarrativeText':
00164 case 'Exam':
00165 case 'Experiment':
00166 case 'ProblemStatement':
00167 case 'SelfAssessment':
00168 case 'Lecture':
00169 $this->learning_resource_type = $a_lrt;
00170 return true;
00171
00172 default:
00173 return false;
00174 }
00175 }
00176 function getLearningResourceType()
00177 {
00178 return $this->learning_resource_type;
00179 }
00180 function setInteractivityLevel($a_iat)
00181 {
00182 switch($a_iat)
00183 {
00184 case 'VeryLow':
00185 case 'Low':
00186 case 'Medium':
00187 case 'High':
00188 case 'VeryHigh':
00189 $this->interactivity_level = $a_iat;
00190 return true;
00191
00192 default:
00193 return false;
00194 }
00195 }
00196 function getInteractivityLevel()
00197 {
00198 return $this->interactivity_level;
00199 }
00200 function setSemanticDensity($a_sd)
00201 {
00202 switch($a_sd)
00203 {
00204 case 'VeryLow':
00205 case 'Low':
00206 case 'Medium':
00207 case 'High':
00208 case 'VeryHigh':
00209 $this->semantic_density = $a_sd;
00210 return true;
00211
00212 default:
00213 return false;
00214 }
00215 }
00216 function getSemanticDensity()
00217 {
00218 return $this->semantic_density;
00219 }
00220 function setIntendedEndUserRole($a_ieur)
00221 {
00222 switch($a_ieur)
00223 {
00224 case 'Teacher':
00225 case 'Author':
00226 case 'Learner':
00227 case 'Manager':
00228 $this->intended_end_user_role = $a_ieur;
00229 return true;
00230
00231 default:
00232 return false;
00233 }
00234 }
00235 function getIntendedEndUserRole()
00236 {
00237 return $this->intended_end_user_role;
00238 }
00239 function setContext($a_context)
00240 {
00241 switch($a_context)
00242 {
00243 case 'School':
00244 case 'HigherEducation':
00245 case 'Training':
00246 case 'Other':
00247 $this->context = $a_context;
00248 return true;
00249
00250 default:
00251 return false;
00252 }
00253 }
00254 function getContext()
00255 {
00256 return $this->context;
00257 }
00258 function setDifficulty($a_difficulty)
00259 {
00260 switch($a_difficulty)
00261 {
00262 case 'VeryEasy':
00263 case 'Easy':
00264 case 'Medium':
00265 case 'Difficult':
00266 case 'VeryDifficult':
00267 $this->difficulty = $a_difficulty;
00268 return true;
00269
00270 default:
00271 return false;
00272 }
00273 }
00274 function getDifficulty()
00275 {
00276 return $this->difficulty;
00277 }
00278
00279 function setPhysicalTypicalLearningTime($months,$days,$hours,$minutes,$seconds)
00280 {
00281 if(!$months and !$days and !$hours and !$minutes and !$seconds)
00282 {
00283 $this->setTypicalLearningTime('PT00H00M');
00284 return true;
00285 }
00286 $tlt = 'P';
00287 if($months)
00288 {
00289 $tlt .= ($months.'M');
00290 }
00291 if($days)
00292 {
00293 $tlt .= ($days.'D');
00294 }
00295 if($hours or $minutes or $seconds)
00296 {
00297 $tlt .= 'T';
00298 }
00299 if($hours)
00300 {
00301 $tlt .= ($hours.'H');
00302 }
00303 if($minutes)
00304 {
00305 $tlt .= ($minutes.'M');
00306 }
00307 if($seconds)
00308 {
00309 $tlt .= ($seconds.'S');
00310 }
00311 $this->setTypicalLearningTime($tlt);
00312 return true;
00313 }
00314
00315
00316 function setTypicalLearningTime($a_tlt)
00317 {
00318 $this->typical_learning_time = $a_tlt;
00319 }
00320 function getTypicalLearningTime()
00321 {
00322 return $this->typical_learning_time;
00323 }
00324
00325 function getTypicalLearningTimeSeconds()
00326 {
00327 include_once './Services/MetaData/classes/class.ilMDUtils.php';
00328
00329 $time_arr = ilMDUtils::_LOMDurationToArray($this->getTypicalLearningTime());
00330
00331 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];
00332 }
00333
00334 function save()
00335 {
00336 if($this->db->autoExecute('il_meta_educational',
00337 $this->__getFields(),
00338 DB_AUTOQUERY_INSERT))
00339 {
00340 $this->setMetaId($this->db->getLastInsertId());
00341
00342 return $this->getMetaId();
00343 }
00344
00345 return false;
00346 }
00347
00348 function update()
00349 {
00350 if($this->getMetaId())
00351 {
00352 if($this->db->autoExecute('il_meta_educational',
00353 $this->__getFields(),
00354 DB_AUTOQUERY_UPDATE,
00355 "meta_educational_id = '".$this->getMetaId()."'"))
00356 {
00357 return true;
00358 }
00359 }
00360 return false;
00361 }
00362
00363 function delete()
00364 {
00365 if($this->getMetaId())
00366 {
00367 $query = "DELETE FROM il_meta_educational ".
00368 "WHERE meta_educational_id = '".$this->getMetaId()."'";
00369
00370 $this->db->query($query);
00371
00372 foreach($this->getTypicalAgeRangeIds() as $id)
00373 {
00374 $typ = $this->getTypicalAgeRange($id);
00375 $typ->delete();
00376 }
00377 foreach($this->getDescriptionIds() as $id)
00378 {
00379 $des = $this->getDescription($id);
00380 $des->delete();
00381 }
00382 foreach($this->getLanguageIds() as $id)
00383 {
00384 $lan = $this->getLanguage($id);
00385 $lan->delete();
00386 }
00387
00388
00389 return true;
00390 }
00391 return false;
00392 }
00393
00394
00395 function __getFields()
00396 {
00397 return array('rbac_id' => $this->getRBACId(),
00398 'obj_id' => $this->getObjId(),
00399 'obj_type' => $this->getObjType(),
00400 'interactivity_type' => $this->getInteractivityType(),
00401 'learning_resource_type' => $this->getLearningResourceType(),
00402 'interactivity_level' => $this->getInteractivityLevel(),
00403 'semantic_density' => $this->getSemanticDensity(),
00404 'intended_end_user_role' => $this->getIntendedEndUserRole(),
00405 'context' => $this->getContext(),
00406 'difficulty' => $this->getDifficulty(),
00407 'typical_learning_time' => $this->getTypicalLearningTime());
00408 }
00409
00410 function read()
00411 {
00412 if($this->getMetaId())
00413 {
00414
00415 $query = "SELECT * FROM il_meta_educational ".
00416 "WHERE meta_educational_id = '".$this->getMetaId()."'";
00417
00418
00419 $res = $this->db->query($query);
00420 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
00421 {
00422 $this->setRBACId($row->rbac_id);
00423 $this->setObjId($row->obj_id);
00424 $this->setObjType($row->obj_type);
00425 $this->setInteractivityType($row->interactivity_type);
00426 $this->setLearningResourceType($row->learning_resource_type);
00427 $this->setInteractivityLevel($row->interactivity_level);
00428 $this->setSemanticDensity($row->semantic_density);
00429 $this->setIntendedEndUserRole($row->intended_end_user_role);
00430 $this->setContext($row->context);
00431 $this->setDifficulty($row->difficulty);
00432 $this->setTypicalLearningTime($row->typical_learning_time);
00433 }
00434 return true;
00435 }
00436 return false;
00437 }
00438
00439
00440
00441
00442
00443
00444 function toXML(&$writer)
00445 {
00446 $writer->xmlStartTag('Educational',
00447 array('InteractivityType' => $this->getInteractivityType()
00448 ? $this->getInteractivityType()
00449 : 'Active',
00450 'LearningResourceType' => $this->getLearningResourceType()
00451 ? $this->getLearningResourceType()
00452 : 'Exercise',
00453 'InteractivityLevel' => $this->getInteractivityLevel()
00454 ? $this->getInteractivityLevel()
00455 : 'Medium',
00456 'SemanticDensity' => $this->getSemanticDensity()
00457 ? $this->getSemanticDensity()
00458 : 'Medium',
00459 'IntendedEndUserRole' => $this->getIntendedEndUserRole()
00460 ? $this->getIntendedEndUserRole()
00461 : 'Learner',
00462 'Context' => $this->getContext()
00463 ? $this->getContext()
00464 : 'Other',
00465 'Difficulty' => $this->getDifficulty()
00466 ? $this->getDifficulty()
00467 : 'Medium'));
00468
00469
00470 $typ_ages = $this->getTypicalAgeRangeIds();
00471 foreach($typ_ages as $id)
00472 {
00473 $key =& $this->getTypicalAgeRange($id);
00474 $key->toXML($writer);
00475 }
00476 if(!count($typ_ages))
00477 {
00478 include_once 'Services/MetaData/classes/class.ilMDTypicalAgeRange.php';
00479 $typ = new ilMDTypicalAgeRange($this->getRBACId(),$this->getObjId());
00480 $typ->toXML($writer);
00481 }
00482
00483
00484 $writer->xmlElement('TypicalLearningTime',null,$this->getTypicalLearningTime());
00485
00486
00487 foreach($this->getDescriptionIds() as $id)
00488 {
00489 $key =& $this->getDescription($id);
00490 $key->toXML($writer);
00491 }
00492
00493 foreach($this->getLanguageIds() as $id)
00494 {
00495 $lang =& $this->getLanguage($id);
00496 $lang->toXML($writer);
00497 }
00498 $writer->xmlEndTag('Educational');
00499 }
00500
00501 function _getId($a_rbac_id,$a_obj_id)
00502 {
00503 global $ilDB;
00504
00505 $query = "SELECT meta_educational_id FROM il_meta_educational ".
00506 "WHERE rbac_id = '".$a_rbac_id."' ".
00507 "AND obj_id = '".$a_obj_id."'";
00508
00509 $res = $ilDB->query($query);
00510 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
00511 {
00512 return $row->meta_educational_id;
00513 }
00514 return false;
00515 }
00516
00517 function _getTypicalLearningTimeSeconds($a_rbac_id,$a_obj_id = 0)
00518 {
00519 global $ilDB;
00520
00521 $a_obj_id = $a_obj_id ? $a_obj_id : $a_rbac_id;
00522
00523 $query = "SELECT typical_learning_time FROM il_meta_educational ".
00524 "WHERE rbac_id = '".$a_rbac_id."' ".
00525 "AND obj_id = '".$a_obj_id."'";
00526 $res = $ilDB->query($query);
00527 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
00528 {
00529 include_once './Services/MetaData/classes/class.ilMDUtils.php';
00530
00531 $time_arr = ilMDUtils::_LOMDurationToArray($row->typical_learning_time);
00532
00533 return 60 * 60 * 24 * 30 * $time_arr[0] +
00534 60 * 60 * 24 * $time_arr[1] +
00535 60 * 60 * $time_arr[2] +
00536 60 * $time_arr[3] +
00537 $time_arr[4];
00538 }
00539 return 0;
00540 }
00541
00542 }
00543 ?>