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 require_once("content/classes/SCORM/class.ilSCORMObject.php");
00025
00035 class ilSCORMItem extends ilSCORMObject
00036 {
00037 var $import_id;
00038 var $identifierref;
00039 var $isvisible;
00040 var $parameters;
00041 var $prereq_type;
00042 var $prerequisites;
00043 var $maxtimeallowed;
00044 var $timelimitaction;
00045 var $datafromlms;
00046 var $masteryscore;
00047
00054 function ilSCORMItem($a_id = 0)
00055 {
00056 parent::ilSCORMObject($a_id);
00057 $this->setType("sit");
00058 }
00059
00060 function getImportId()
00061 {
00062 return $this->import_id;
00063 }
00064
00065 function setImportId($a_import_id)
00066 {
00067 $this->import_id = $a_import_id;
00068 }
00069
00070 function getIdentifierRef()
00071 {
00072 return $this->identifierref;
00073 }
00074
00075 function setIdentifierRef($a_id_ref)
00076 {
00077 $this->identifierref = $a_id_ref;
00078 }
00079
00080 function getVisible()
00081 {
00082 return $this->isvisible;
00083 }
00084
00085 function setVisible($a_visible)
00086 {
00087 $this->isvisible = $a_visible;
00088 }
00089
00090 function getParameters()
00091 {
00092 return $this->parameters;
00093 }
00094
00095 function setParameters($a_par)
00096 {
00097 $this->parameters = $a_par;
00098 }
00099
00100 function getPrereqType()
00101 {
00102 return $this->prereq_type;
00103 }
00104
00105 function setPrereqType($a_p_type)
00106 {
00107 $this->prereq_type = $a_p_type;
00108 }
00109
00110 function getPrerequisites()
00111 {
00112 return $this->prerequisites;
00113 }
00114
00115 function setPrerequisites($a_pre)
00116 {
00117 $this->prerequisites = $a_pre;
00118 }
00119
00120 function getMaxTimeAllowed()
00121 {
00122 return $this->maxtimeallowed;
00123 }
00124
00125 function setMaxTimeAllowed($a_max)
00126 {
00127 $this->maxtimeallowed = $a_max;
00128 }
00129
00130 function getTimeLimitAction()
00131 {
00132 return $this->timelimitaction;
00133 }
00134
00135 function setTimeLimitAction($a_lim_act)
00136 {
00137 $this->timelimitaction = $a_lim_act;
00138 }
00139
00140 function getDataFromLms()
00141 {
00142 return $this->datafromlms;
00143 }
00144
00145 function setDataFromLms($a_data)
00146 {
00147 $this->datafromlms = $a_data;
00148 }
00149
00150 function getMasteryScore()
00151 {
00152 return $this->masteryscore;
00153 }
00154
00155 function setMasteryScore($a_score)
00156 {
00157 $this->masteryscore = $a_score;
00158 }
00159
00160 function read()
00161 {
00162 parent::read();
00163
00164 $q = "SELECT * FROM sc_item WHERE obj_id = '".$this->getId()."'";
00165
00166 $obj_set = $this->ilias->db->query($q);
00167 $obj_rec = $obj_set->fetchRow(DB_FETCHMODE_ASSOC);
00168 $this->setImportId($obj_rec["import_id"]);
00169 $this->setIdentifierRef($obj_rec["identifierref"]);
00170 if (strtolower($obj_rec["isvisible"]) == "false")
00171 {
00172 $this->setVisible(false);
00173 }
00174 else
00175 {
00176 $this->setVisible(true);
00177 }
00178 $this->setParameters($obj_rec["parameters"]);
00179 $this->setPrereqType($obj_rec["prereq_type"]);
00180 $this->setPrerequisites($obj_rec["prerequisites"]);
00181 $this->setMaxTimeAllowed($obj_rec["maxtimeallowed"]);
00182 $this->setTimeLimitAction($obj_rec["timelimitaction"]);
00183 $this->setDataFromLms($obj_rec["datafromlms"]);
00184 $this->setMasteryScore($obj_rec["masteryscore"]);
00185 }
00186
00187 function create()
00188 {
00189 parent::create();
00190
00191 $str_visible = ($this->getVisible())
00192 ? "true"
00193 : "false";
00194
00195 $q = "INSERT INTO sc_item (obj_id, import_id, identifierref,".
00196 "isvisible, parameters, prereq_type, prerequisites, maxtimeallowed,".
00197 "timelimitaction, datafromlms, masteryscore) VALUES ".
00198 "('".$this->getId()."', '".$this->getImportId()."','".$this->getIdentifierRef().
00199 "','$str_visible','".$this->getParameters()."','".$this->getPrereqType().
00200 "','".$this->getPrerequisites()."','".$this->getMaxTimeAllowed()."','".
00201 $this->getTimeLimitAction()."','".$this->getDataFromLms()."','".
00202 $this->getMasteryScore()."')";
00203 $this->ilias->db->query($q);
00204 }
00205
00206 function update()
00207 {
00208 $str_visible = ($this->getVisible())
00209 ? "true"
00210 : "false";
00211
00212 parent::update();
00213 $q = "UPDATE sc_item SET ".
00214 "import_id = '".$this->getImportId()."', ".
00215 "identifierref = '".$this->getIdentifierRef()."', ".
00216 "isvisible = '".$str_visible."', ".
00217 "parameters = '".$this->getParameters()."', ".
00218 "prereq_type = '".$this->getPrereqType()."', ".
00219 "prerequisites = '".$this->getPrerequisites()."', ".
00220 "maxtimeallowed = '".$this->getMaxTimeAllowed()."', ".
00221 "timelimitaction = '".$this->getTimeLimitAction()."', ".
00222 "datafromlms = '".$this->getDataFromLms()."', ".
00223 "masteryscore = '".$this->getMasteryScore()."' ".
00224 "WHERE obj_id = '".$this->getId()."'";
00225 $this->ilias->db->query($q);
00226 }
00227
00233 function getTrackingDataOfUser($a_user_id = 0)
00234 {
00235 global $ilDB, $ilUser;
00236
00237 if ($a_user_id == 0)
00238 {
00239 $a_user_id = $ilUser->getId();
00240 }
00241
00242 $q = "SELECT * FROM scorm_tracking WHERE ".
00243 "sco_id = '".$this->getId()."' AND ".
00244 "user_id = '".$a_user_id."'";
00245
00246 $track_set = $ilDB->query($q);
00247 $trdata = array();
00248 while ($track_rec = $track_set->fetchRow(DB_FETCHMODE_ASSOC))
00249 {
00250 $trdata[$track_rec["lvalue"]] = $track_rec["rvalue"];
00251 }
00252
00253 return $trdata;
00254 }
00255
00256 function _lookupTrackingDataOfUser($a_item_id, $a_user_id = 0)
00257 {
00258 global $ilDB, $ilUser;
00259
00260 if ($a_user_id == 0)
00261 {
00262 $a_user_id = $ilUser->getId();
00263 }
00264
00265 $q = "SELECT * FROM scorm_tracking WHERE ".
00266 "sco_id = '".$a_item_id."' AND ".
00267 "user_id = '".$a_user_id."'";
00268
00269 $track_set = $ilDB->query($q);
00270 $trdata = array();
00271 while ($track_rec = $track_set->fetchRow(DB_FETCHMODE_ASSOC))
00272 {
00273 $trdata[$track_rec["lvalue"]] = $track_rec["rvalue"];
00274 }
00275
00276 return $trdata;
00277 }
00278
00279 function delete()
00280 {
00281 global $ilDB;
00282
00283 parent::delete();
00284
00285 $q = "DELETE FROM sc_item WHERE obj_id =".$ilDB->quote($this->getId());
00286 $ilDB->query($q);
00287
00288 $q = "DELETE FROM scorm_tracking WHERE ".
00289 "sco_id = ".$ilDB->quote($this->getId());
00290 $ilDB->query($q);
00291
00292 }
00293
00294
00295 function insertTrackData($a_lval, $a_rval, $a_obj_id)
00296 {
00297 require_once("content/classes/SCORM/class.ilObjSCORMTracking.php");
00298
00299 ilObjSCORMTracking::_insertTrackData($this->getId(), $a_lval, $a_rval, $a_obj_id);
00300 }
00301
00302
00303 function _getItems($a_obj_id)
00304 {
00305 global $ilDB;
00306
00307 $query = "SELECT * FROM scorm_object ".
00308 "WHERE slm_id = '".$a_obj_id."' ".
00309 "AND type = 'sit'";
00310
00311 $res = $ilDB->query($query);
00312 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
00313 {
00314 $item_ids[] = $row->obj_id;
00315 }
00316 return $item_ids ? $item_ids : array();
00317 }
00318
00319 function _lookupTitle($a_obj_id)
00320 {
00321 global $ilDB;
00322
00323 $query = "SELECT * FROM scorm_object ".
00324 "WHERE obj_id = '".$a_obj_id."'";
00325
00326 $res = $ilDB->query($query);
00327 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
00328 {
00329 return $row->title;
00330 }
00331 return '';
00332 }
00333
00334
00335 }
00336 ?>