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 require_once ('./classes/class.ilObject.php');
00035 require_once ('class.ilnetucateXMLAPI.php');
00036
00037 class ilObjiLincClassroom extends ilObject
00038 {
00045 function ilObjiLincClassroom($a_icla_id,$a_icrs_id)
00046 {
00047 global $ilErr,$ilias,$lng;
00048
00049 $this->type = "icla";
00050 $this->id = $a_icla_id;
00051 $this->parent = $a_icrs_id;
00052 $this->ilincAPI = new ilnetucateXMLAPI();
00053
00054 $this->ilErr =& $ilErr;
00055 $this->ilias =& $ilias;
00056 $this->lng =& $lng;
00057
00058 $this->max_title = MAXLENGTH_OBJ_TITLE;
00059 $this->max_desc = MAXLENGTH_OBJ_DESC;
00060 $this->add_dots = true;
00061
00062 $this->referenced = false;
00063 $this->call_by_reference = false;
00064
00065 if (!empty($this->id))
00066 {
00067 $this->read();
00068 }
00069
00070 return $this;
00071 }
00072
00073 function _lookupiCourseId($a_ref_id)
00074 {
00075 global $ilDB;
00076
00077 $q = "SELECT course_id FROM ilinc_data ".
00078 "LEFT JOIN object_reference ON object_reference.obj_id=ilinc_data.obj_id ".
00079 "WHERE object_reference.ref_id = ".$ilDB->quote($a_ref_id);
00080 $obj_set = $ilDB->query($q);
00081 $obj_rec = $obj_set->fetchRow(DB_FETCHMODE_ASSOC);
00082
00083 return $obj_rec["course_id"];
00084 }
00085
00090 function read()
00091 {
00092 $this->ilincAPI->findClass($this->id);
00093 $response = $this->ilincAPI->sendRequest();
00094
00095 if ($response->isError())
00096 {
00097 if (!$response->getErrorMsg())
00098 {
00099 $this->error_msg = "err_read_class";
00100 }
00101 else
00102 {
00103 $this->error_msg = $response->getErrorMsg();
00104 }
00105
00106 return false;
00107 }
00108
00109 $this->setTitle($response->data['classes'][$this->id]['name']);
00110 $this->setDescription($response->data['classes'][$this->id]['description']);
00111 $this->setDocentId($response->data['classes'][$this->id]['instructoruserid']);
00112 $this->setStatus($response->data['classes'][$this->id]['alwaysopen']);
00113
00114
00115
00116 }
00117
00118 function joinClass(&$a_user_obj,$a_ilinc_class_id)
00119 {
00120 $this->ilincAPI->joinClass($a_user_obj,$a_ilinc_class_id);
00121 $response = $this->ilincAPI->sendRequest("joinClass");
00122
00123 if ($response->isError())
00124 {
00125 if (!$response->getErrorMsg())
00126 {
00127 $this->error_msg = "err_join_classroom";
00128 }
00129 else
00130 {
00131 $this->error_msg = $response->getErrorMsg();
00132 }
00133
00134 return false;
00135 }
00136
00137
00138 return trim($response->data['url']['cdata']);
00139 }
00140
00141 function findUser(&$a_user_obj)
00142 {
00143 $this->ilincAPI->findUser($a_user_obj);
00144 $response = $this->ilincAPI->sendRequest();
00145
00146 var_dump($response->data);
00147 exit;
00148 }
00149
00156 function update()
00157 {
00158 $this->ilincAPI->editClass($this->id,array("name" => $this->getTitle(),"description" => $this->getDescription(), "instructoruserid" => $this->getDocentId(), "alwaysopen" => $this->getStatus()));
00159 $response = $this->ilincAPI->sendRequest("editClass");
00160
00161 if ($response->isError())
00162 {
00163 if (!$response->getErrorMsg())
00164 {
00165 $this->error_msg = "err_edit_classroom";
00166 }
00167 else
00168 {
00169 $this->error_msg = $response->getErrorMsg();
00170 }
00171
00172 return false;
00173 }
00174
00175 $this->result_msg = $response->getResultMsg();
00176
00177 return true;
00178 }
00179
00186 function delete()
00187 {
00188 $this->ilincAPI->removeClass($this->id);
00189 $response = $this->ilincAPI->sendRequest();
00190
00191 if ($response->isError())
00192 {
00193 if (!$response->getErrorMsg())
00194 {
00195 $this->error_msg = "err_delete_classroom";
00196 }
00197 else
00198 {
00199 $this->error_msg = $response->getErrorMsg();
00200 }
00201
00202 return false;
00203 }
00204
00205 return true;
00206 }
00207
00208
00209 function getDocentList()
00210 {
00211 $ilinc_crs_id = ilObjiLincClassroom::_lookupiCourseId($this->parent);
00212
00213 $this->ilincAPI->findRegisteredUsersByRole($ilinc_crs_id,true);
00214 $response = $this->ilincAPI->sendRequest();
00215
00216 if (is_array($response->data['users']))
00217 {
00218 return $response->data['users'];
00219 }
00220
00221 return array();
00222 }
00223
00224 function _getDocent($a_ilinc_user_id)
00225 {
00226 global $ilDB, $lng;
00227
00228 $fullname = false;
00229
00230 $q = "SELECT title,firstname,lastname FROM usr_data WHERE ilinc_id = ".$ilDB->quote($a_ilinc_user_id)." LIMIT 1";
00231 $r = $ilDB->query($q);
00232
00233 while ($row = $r->fetchRow(DB_FETCHMODE_OBJECT))
00234 {
00235 $fullname = ilObjiLincClassroom::_setFullname($row->title,$row->firstname,$row->lastname);
00236 }
00237
00238 return $fullname;
00239 }
00240
00241 function _setFullname($a_title = "",$a_firstname = "",$a_lastname = "")
00242 {
00243 $fullname = "";
00244
00245 if ($a_title)
00246 {
00247 $fullname = $a_title." ";
00248 }
00249
00250 if ($a_firstname)
00251 {
00252 $fullname .= $a_firstname." ";
00253 }
00254
00255 if ($a_lastname)
00256 {
00257 return $fullname.$a_lastname;
00258 }
00259 }
00260
00261 function setDocentId($a_ilinc_user_id)
00262 {
00263 $this->docent_id = $a_ilinc_user_id;
00264 }
00265
00266 function getDocentName()
00267 {
00268 if (!$this->docent_name)
00269 {
00270 $this->docent_name = $this->_getDocent($this->docent_id);
00271 }
00272
00273 return $this->docent_name;
00274 }
00275
00276 function getDocentId()
00277 {
00278 return $this->docent_id;
00279 }
00280
00281 function setStatus($a_status)
00282 {
00283 if ($a_status == "Wahr" or $a_status == "1" or $a_status == true)
00284 {
00285 $this->status = "1";
00286 }
00287 else
00288 {
00289 $this->status = "0";
00290 }
00291 }
00292
00293 function getStatus()
00294 {
00295 return $this->status;
00296 }
00297
00298 function getErrorMsg()
00299 {
00300 $err_msg = $this->error_msg;
00301 $this->error_msg = "";
00302
00303 return $err_msg;
00304 }
00305 }
00306 ?>