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

course/classes/class.ilCourseStart.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003         +-----------------------------------------------------------------------------+
00004         | ILIAS open source                                                           |
00005         +-----------------------------------------------------------------------------+
00006         | Copyright (c) 1998-2005 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 
00034 class ilCourseStart
00035 {
00036         var $db;
00037 
00038         var $ref_id;
00039         var $id;
00040         var $start_objs = array();
00041 
00048         function ilCourseStart($a_course_ref_id,$a_course_obj_id)
00049         {
00050                 global $ilDB;
00051 
00052                 $this->db =& $ilDB;
00053 
00054                 $this->ref_id = $a_course_ref_id;
00055                 $this->id = $a_course_obj_id;
00056 
00057                 $this->__read();
00058         }
00059         function setId($a_id)
00060         {
00061                 $this->id = $a_id;
00062         }
00063         function getId()
00064         {
00065                 return $this->id;
00066         }
00067         function setRefId($a_ref_id)
00068         {
00069                 $this->ref_id = $a_ref_id;
00070         }
00071         function getRefId()
00072         {
00073                 return $this->ref_id;
00074         }
00075         function getStartObjects()
00076         {
00077                 return $this->start_objs ? $this->start_objs : array();
00078         }
00079 
00080         function delete($a_crs_start_id)
00081         {
00082                 $query = "DELETE FROM crs_start ".
00083                         "WHERE crs_start_id = '".$a_crs_start_id."' ".
00084                         "AND crs_id = '".$this->getId()."'";
00085 
00086                 $this->db->query($query);
00087 
00088                 return true;
00089         }
00090 
00091         function exists($a_item_ref_id)
00092         {
00093                 $query = "SELECT * FROM crs_start ".
00094                         "WHERE crs_id = '".$this->getId()."' ".
00095                         "AND item_ref_id = '".$a_item_ref_id."'";
00096 
00097                 $res = $this->db->query($query);
00098 
00099                 return $res->numRows() ? true : false;
00100         }
00101 
00102         function add($a_item_ref_id)
00103         {
00104                 if($a_item_ref_id)
00105                 {
00106                         $query = "INSERT INTO crs_start ".
00107                                 "SET crs_id = '".$this->getId()."', ".
00108                                 "item_ref_id = '".$a_item_ref_id."'";
00109 
00110                         $this->db->query($query);
00111 
00112                         return true;
00113                 }
00114                 return false;
00115         }
00116 
00117         function __deleteAll()
00118         {
00119                 $query = "DELETE FROM crs_start ".
00120                         "WHERE crs_id = '".$this->getId()."'";
00121 
00122 
00123                 $this->db->query($query);
00124 
00125                 return true;
00126         }
00127 
00128         function getPossibleStarters(&$item_obj)
00129         {
00130                 foreach($item_obj->getItems() as $node)
00131                 {
00132                         switch($node['type'])
00133                         {
00134                                 case 'lm':
00135                                 case 'sahs':
00136                                 case 'tst':
00137                                         $poss_items[] = $node['ref_id'];
00138                                         break;
00139                         }
00140                 }
00141                 return $poss_items ? $poss_items : array();
00142         }
00143 
00144         function isFullfilled($user_id)
00145         {
00146                 $fullfilled = true;
00147 
00148 
00149                 include_once './course/classes/class.ilCourseLMHistory.php';
00150 
00151                 $lm_continue =& new ilCourseLMHistory($this->getRefId(),$user_id);
00152                 $continue_data = $lm_continue->getLMHistory();
00153                 
00154                 foreach($this->getStartObjects() as $item)
00155                 {
00156                         $tmp_obj = ilObjectFactory::getInstanceByRefId($item['item_ref_id']);
00157 
00158                         if($tmp_obj->getType() == 'tst')
00159                         {
00160                                 include_once './assessment/classes/class.ilObjTestAccess.php';
00161 
00162                                 if(!ilObjTestAccess::_checkCondition($tmp_obj->getId(),'finished',''))
00163                                 {
00164                                         $fullfilled = false;
00165                                         continue;
00166                                 }
00167                         }
00168                         elseif($tmp_obj->getType() == 'sahs')
00169                         {
00170                                 include_once 'Services/Tracking/classes/class.ilLPStatusSCORM.php';
00171 
00172                                 $completed = ilLPStatusSCORM::_getCompleted($tmp_obj->getId());
00173 
00174                                 if(!in_array($user_id,$completed))
00175                                 {
00176                                         $fullfilled = false;
00177                                         continue;
00178                                 }
00179                         }
00180                         else
00181                         {
00182                                 if(!isset($continue_data[$tmp_obj->getRefId()]))
00183                                 {
00184                                         $fullfilled = false;
00185                                         continue;
00186                                 }
00187                         }
00188                 }
00189                 return $fullfilled;
00190         }
00191 
00192 
00193         // PRIVATE
00194         function __read()
00195         {
00196                 global $tree;
00197 
00198                 $this->start_objs = array();
00199 
00200                 $query = "SELECT * FROM crs_start ".
00201                         "WHERE crs_id = '".$this->getId()."'";
00202 
00203                 $res = $this->db->query($query);
00204                 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
00205                 {
00206                         if($tree->isInTree($row->item_ref_id))
00207                         {
00208                                 $this->start_objs[$row->crs_start_id]['item_ref_id'] = $row->item_ref_id;
00209                         }
00210                         else
00211                         {
00212                                 $this->delete($row->item_ref_id);
00213                         }
00214                 }
00215                 return true;
00216         }
00217 
00218                 
00219 
00220 
00221 } // END class.ilObjCourseGrouping
00222 ?>

Generated on Fri Dec 13 2013 11:57:58 for ILIAS Release_3_6_x_branch .rev 46809 by  doxygen 1.7.1