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 = '".$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" => (string) $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 return true;
00176 }
00177
00184 function delete()
00185 {
00186 $this->ilincAPI->removeClass($this->id);
00187 $response = $this->ilincAPI->sendRequest();
00188
00189 if ($response->isError())
00190 {
00191 if (!$response->getErrorMsg())
00192 {
00193 $this->error_msg = "err_delete_classroom";
00194 }
00195 else
00196 {
00197 $this->error_msg = $response->getErrorMsg();
00198 }
00199
00200 return false;
00201 }
00202
00203 return true;
00204 }
00205
00206
00207 function getDocentList()
00208 {
00209 $ilinc_crs_id = ilObjiLincClassroom::_lookupiCourseId($this->parent);
00210
00211 $this->ilincAPI->findRegisteredUsersByRole($ilinc_crs_id,true);
00212 $response = $this->ilincAPI->sendRequest();
00213
00214 if (is_array($response->data['users']))
00215 {
00216 return $response->data['users'];
00217 }
00218
00219 return array();
00220 }
00221
00222 function _getDocent($a_ilinc_user_id)
00223 {
00224 global $ilDB, $lng;
00225
00226 $fullname = false;
00227
00228 $q = "SELECT title,firstname,lastname FROM usr_data WHERE ilinc_id = '".$a_ilinc_user_id."' LIMIT 1";
00229 $r = $ilDB->query($q);
00230
00231 while ($row = $r->fetchRow(DB_FETCHMODE_OBJECT))
00232 {
00233 $fullname = ilObjiLincClassroom::_setFullname($row->title,$row->firstname,$row->lastname);
00234 }
00235
00236 return $fullname;
00237 }
00238
00239 function _setFullname($a_title = "",$a_firstname = "",$a_lastname = "")
00240 {
00241 $fullname = "";
00242
00243 if ($a_title)
00244 {
00245 $fullname = $a_title." ";
00246 }
00247
00248 if ($a_firstname)
00249 {
00250 $fullname .= $a_firstname." ";
00251 }
00252
00253 if ($a_lastname)
00254 {
00255 return $fullname.$a_lastname;
00256 }
00257 }
00258
00259 function setDocentId($a_ilinc_user_id)
00260 {
00261 $this->docent_id = $a_ilinc_user_id;
00262 }
00263
00264 function getDocentName()
00265 {
00266 if (!$this->docent_name)
00267 {
00268 $this->docent_name = $this->_getDocent($this->docent_id);
00269 }
00270
00271 return $this->docent_name;
00272 }
00273
00274 function getDocentId()
00275 {
00276 return $this->docent_id;
00277 }
00278
00279 function setStatus($a_status)
00280 {
00281 if ($a_status == "Wahr")
00282 {
00283 $this->status = true;
00284 }
00285 else
00286 {
00287 $this->status = false;
00288 }
00289 }
00290
00291 function getStatus()
00292 {
00293 return $this->status;
00294 }
00295
00296 function getErrorMsg()
00297 {
00298 $err_msg = $this->error_msg;
00299 $this->error_msg = "";
00300
00301 return $err_msg;
00302 }
00303 }
00304 ?>