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