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
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 'htlm':
00136 case 'alm':
00137 case 'sahs':
00138 case 'tst':
00139 $poss_items[] = $node['ref_id'];
00140 break;
00141 }
00142 }
00143 return $poss_items ? $poss_items : array();
00144 }
00145
00146 function isFullfilled($user_id)
00147 {
00148 $fullfilled = true;
00149
00150
00151 include_once './course/classes/class.ilCourseLMHistory.php';
00152
00153 $lm_continue =& new ilCourseLMHistory($this->getRefId(),$user_id);
00154 $continue_data = $lm_continue->getLMHistory();
00155
00156 foreach($this->getStartObjects() as $item)
00157 {
00158 $tmp_obj = ilObjectFactory::getInstanceByRefId($item['item_ref_id']);
00159
00160 if($tmp_obj->getType() == 'tst')
00161 {
00162 include_once './assessment/classes/class.ilObjTest.php';
00163
00164 if(!ilObjTest::_checkCondition($tmp_obj->getId(),'finished',''))
00165 {
00166 $fullfilled = false;
00167 continue;
00168 }
00169 }
00170 else
00171 {
00172 if(!isset($continue_data[$tmp_obj->getRefId()]))
00173 {
00174 $fullfilled = false;
00175 continue;
00176 }
00177 }
00178 }
00179 return $fullfilled;
00180 }
00181
00182
00183
00184 function __read()
00185 {
00186 global $tree;
00187
00188 $this->start_objs = array();
00189
00190 $query = "SELECT * FROM crs_start ".
00191 "WHERE crs_id = '".$this->getId()."'";
00192
00193 $res = $this->db->query($query);
00194 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
00195 {
00196 if($tree->isInTree($row->item_ref_id))
00197 {
00198 $this->start_objs[$row->crs_start_id]['item_ref_id'] = $row->item_ref_id;
00199 }
00200 else
00201 {
00202 $this->delete($row->item_ref_id);
00203 }
00204 }
00205 return true;
00206 }
00207
00208
00209
00210
00211 }
00212 ?>