• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

course/classes/class.ilCourseObjectiveLM.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003         +-----------------------------------------------------------------------------+
00004         | ILIAS open source                                                           |
00005         +-----------------------------------------------------------------------------+
00006         | Copyright (c) 1998-2001 ILIAS open source, University of Cologne            |
00007         |                                                                             |
00008         | This program is free software; you can redistribute it and/or               |
00009         | modify it under the terms of the GNU General Public License                 |
00010         | as published by the Free Software Foundation; either version 2              |
00011         | of the License, or (at your option) any later version.                      |
00012         |                                                                             |
00013         | This program is distributed in the hope that it will be useful,             |
00014         | but WITHOUT ANY WARRANTY; without even the implied warranty of              |
00015         | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               |
00016         | GNU General Public License for more details.                                |
00017         |                                                                             |
00018         | You should have received a copy of the GNU General Public License           |
00019         | along with this program; if not, write to the Free Software                 |
00020         | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. |
00021         +-----------------------------------------------------------------------------+
00022 */
00023 
00024 
00035 class ilCourseObjectiveLM
00036 {
00037         var $db = null;
00038 
00039         var $objective_id = null;
00040         var $lms;
00041 
00042         function ilCourseObjectiveLM($a_objective_id)
00043         {
00044                 global $ilDB;
00045 
00046                 $this->db =& $ilDB;
00047         
00048                 $this->objective_id = $a_objective_id;
00049 
00050                 $this->__read();
00051         }
00052 
00053         function getLMs()
00054         {
00055                 return $this->lms ? $this->lms : array();
00056         }
00057 
00058         function getChapters()
00059         {
00060                 foreach($this->lms as $lm_data)
00061                 {
00062                         if($lm_data['type'] == 'st')
00063                         {
00064                                 $chapters[] = $lm_data;
00065                         }
00066                 }
00067                 return $chapters ? $chapters : array();
00068         }
00069         
00070         function getLM($lm_id)
00071         {
00072                 return $this->lms[$lm_id] ? $this->lms[$lm_id] : array();
00073         }
00074 
00075         function getObjectiveId()
00076         {
00077                 return $this->objective_id;
00078         }
00079 
00080         function setLMRefId($a_ref_id)
00081         {
00082                 $this->lm_ref_id = $a_ref_id;
00083         }
00084         function getLMRefId()
00085         {
00086                 return $this->lm_ref_id ? $this->lm_ref_id : 0;
00087         }
00088         function setLMObjId($a_obj_id)
00089         {
00090                 $this->lm_obj_id = $a_obj_id;
00091         }
00092         function getLMObjId()
00093         {
00094                 return $this->lm_obj_id ? $this->lm_obj_id : 0;
00095         }
00096         function setType($a_type)
00097         {
00098                 $this->type = $a_type;
00099         }
00100         function getType()
00101         {
00102                 return $this->type;
00103         }
00104 
00105         function checkExists()
00106         {
00107                 if($this->getLMObjId())
00108                 {
00109                         $query = "SELECT * FROM crs_objective_lm ".
00110                                 "WHERE objective_id = '".$this->getObjectiveId()."' ".
00111                                 "AND ref_id = '".$this->getLMRefId()."' ".
00112                                 "AND obj_id = '".$this->getLMObjId()."'";
00113                 }
00114                 else
00115                 {
00116                         $query = "SELECT * FROM crs_objective_lm ".
00117                                 "WHERE objective_id = '".$this->getObjectiveId()."' ".
00118                                 "AND ref_id = '".$this->getLMRefId()."'";
00119                 }
00120 
00121                 $res = $this->db->query($query);
00122 
00123                 return $res->numRows() ? true : false;
00124         }
00125 
00126         function add()
00127         {
00128                 $query = "INSERT INTO crs_objective_lm ".
00129                         "SET objective_id = '".$this->getObjectiveId()."', ".
00130                         "ref_id = '".$this->getLMRefId()."', ".
00131                         "obj_id = '".$this->getLMObjId()."', ".
00132                         "type = '".$this->getType()."'";
00133 
00134                 $this->db->query($query);
00135 
00136                 return true;
00137         }
00138         function delete($lm_id)
00139         {
00140                 if(!$lm_id)
00141                 {
00142                         return false;
00143                 }
00144 
00145                 $query = "DELETE FROM crs_objective_lm ".
00146                         "WHERE lm_ass_id = '".$lm_id."'";
00147 
00148                 $this->db->query($query);
00149 
00150                 return true;
00151         }
00152 
00153         function deleteAll()
00154         {
00155                 $query = "DELETE FROM crs_objective_lm ".
00156                         "WHERE objective_id = '".$this->getObjectiveId()."'";
00157 
00158                 $this->db->query($query);
00159 
00160                 return true;
00161         }
00162 
00163         // PRIVATE
00164         function __read()
00165         {
00166                 global $tree;
00167 
00168                 $this->lms = array();
00169                 $query = "SELECT * FROM crs_objective_lm ".
00170                         "WHERE objective_id = '".$this->getObjectiveId()."'";
00171 
00172                 $res = $this->db->query($query);
00173                 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
00174                 {
00175                         if(!$tree->isInTree($row->ref_id))
00176                         {
00177                                 $this->delete($row->lm_ass_id);
00178                                 continue;
00179                         }
00180                         $lm['ref_id'] = $row->ref_id;
00181                         $lm['obj_id'] = $row->obj_id;
00182                         $lm['type'] = $row->type;
00183                         $lm['lm_ass_id'] = $row->lm_ass_id;
00184 
00185                         $this->lms[$row->lm_ass_id] = $lm;
00186                 }
00187                 return true;
00188         }
00189 }
00190 ?>

Generated on Fri Dec 13 2013 09:06:36 for ILIAS Release_3_4_x_branch .rev 46804 by  doxygen 1.7.1