Go to the documentation of this file.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/Migration/DBUpdate_426/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/Migration/DBUpdate_426/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/Migration/DBUpdate_426/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/Migration/DBUpdate_426/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/Migration/DBUpdate_426/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/Migration/DBUpdate_426/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/Migration/DBUpdate_426/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/Migration/DBUpdate_426/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/Migration/DBUpdate_426/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 function setTypicalLearningTime($a_tlt)
00279 {
00280 $this->typical_learning_time = $a_tlt;
00281 }
00282 function getTypicalLearningTime()
00283 {
00284 return $this->typical_learning_time;
00285 }
00286
00287
00288 function save()
00289 {
00290 if($this->db->autoExecute('il_meta_educational',
00291 $this->__getFields(),
00292 DB_AUTOQUERY_INSERT))
00293 {
00294 $this->setMetaId($this->db->getLastInsertId());
00295
00296 return $this->getMetaId();
00297 }
00298
00299 return false;
00300 }
00301
00302 function update()
00303 {
00304 if($this->getMetaId())
00305 {
00306 if($this->db->autoExecute('il_meta_educational',
00307 $this->__getFields(),
00308 DB_AUTOQUERY_UPDATE,
00309 "meta_educational_id = '".$this->getMetaId()."'"))
00310 {
00311 return true;
00312 }
00313 }
00314 return false;
00315 }
00316
00317 function delete()
00318 {
00319 if($this->getMetaId())
00320 {
00321 $query = "DELETE FROM il_meta_educational ".
00322 "WHERE meta_educational_id = '".$this->getMetaId()."'";
00323
00324 $this->db->query($query);
00325
00326 foreach($this->getTypicalAgeRangeIds() as $id)
00327 {
00328 $typ =& $this->getTypicalAgeRange($id);
00329 $typ->delete();
00330 }
00331 foreach($this->getDescriptionIds() as $id)
00332 {
00333 $des =& $this->getDescription($id);
00334 $des->delete();
00335 }
00336 foreach($this->getLanguageIds() as $id)
00337 {
00338 $lan =& $this->getLanguage($id);
00339 $lan->delete();
00340 }
00341
00342
00343 return true;
00344 }
00345 return false;
00346 }
00347
00348
00349 function __getFields()
00350 {
00351 return array('rbac_id' => $this->getRBACId(),
00352 'obj_id' => $this->getObjId(),
00353 'obj_type' => ilUtil::prepareDBString($this->getObjType()),
00354 'interactivity_type' => ilUtil::prepareDBString($this->getInteractivityType()),
00355 'learning_resource_type' => ilUtil::prepareDBString($this->getLearningResourceType()),
00356 'interactivity_level' => ilUtil::prepareDBString($this->getInteractivityLevel()),
00357 'semantic_density' => ilUtil::prepareDBString($this->getSemanticDensity()),
00358 'intended_end_user_role' => ilUtil::prepareDBString($this->getIntendedEndUserRole()),
00359 'context' => ilUtil::prepareDBString($this->getContext()),
00360 'difficulty' => ilUtil::prepareDBString($this->getDifficulty()),
00361 'typical_learning_time' => ilUtil::prepareDBString($this->getTypicalLearningTime()));
00362 }
00363
00364 function read()
00365 {
00366 if($this->getMetaId())
00367 {
00368
00369 $query = "SELECT * FROM il_meta_educational ".
00370 "WHERE meta_educational_id = '".$this->getMetaId()."'";
00371
00372
00373 $res = $this->db->query($query);
00374 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
00375 {
00376 $this->setRBACId($row->rbac_id);
00377 $this->setObjId($row->obj_id);
00378 $this->setObjType($row->obj_type);
00379 $this->setInteractivityType(ilUtil::stripSlashes($row->interactivity_type));
00380 $this->setLearningResourceType(ilUtil::stripSlashes($row->learning_resource_type));
00381 $this->setInteractivityLevel(ilUtil::stripSlashes($row->interactivity_level));
00382 $this->setSemanticDensity(ilUtil::stripSlashes($row->semantic_density));
00383 $this->setIntendedEndUserRole(ilUtil::stripSlashes($row->intended_end_user_role));
00384 $this->setContext(ilUtil::stripSlashes($row->context));
00385 $this->setDifficulty(ilUtil::stripSlashes($row->difficulty));
00386 $this->setTypicalLearningTime(ilUtil::stripSlashes($row->typical_learning_time));
00387 }
00388 return true;
00389 }
00390 return false;
00391 }
00392
00393
00394
00395
00396
00397
00398 function toXML(&$writer)
00399 {
00400 $writer->xmlStartTag('Educational',
00401 array('InteractivityType' => $this->getInteractivityType(),
00402 'LearningResourceType' => $this->getLearningResourceType(),
00403 'InteractivityLevel' => $this->getInteractivityLevel(),
00404 'SemanticDensity' => $this->getSemanticDensity(),
00405 'IntendedEndUserRole' => $this->getIntendedEndUserRole(),
00406 'Context' => $this->getContext(),
00407 'Difficulty' => $this->getDifficulty()));
00408
00409
00410 foreach($this->getTypicalAgeRangeIds() as $id)
00411 {
00412 $key =& $this->getTypicalAgeRange($id);
00413 $key->toXML($writer);
00414 }
00415
00416 $writer->xmlElement('TypicalLearningTime',null,$this->getTypicalLearningTime());
00417
00418
00419 foreach($this->getDescriptionIds() as $id)
00420 {
00421 $key =& $this->getDescription($id);
00422 $key->toXML($writer);
00423 }
00424
00425 foreach($this->getLanguageIds() as $id)
00426 {
00427 $lang =& $this->getLanguage($id);
00428 $lang->toXML($writer);
00429 }
00430 $writer->xmlEndTag('Educational');
00431 }
00432
00433 function _getId($a_rbac_id,$a_obj_id)
00434 {
00435 global $ilDB;
00436
00437 $query = "SELECT meta_educational_id FROM il_meta_educational ".
00438 "WHERE rbac_id = '".$a_rbac_id."' ".
00439 "AND obj_id = '".$a_obj_id."'";
00440
00441 $res = $ilDB->query($query);
00442 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
00443 {
00444 return $row->meta_educational_id;
00445 }
00446 return false;
00447 }
00448 }
00449 ?>