function get_content() { global $CFG; global $COURSE; global $USER; if ($this->content != null) { return $this->content; } $this->content = new stdClass(); if (mapleta_get_role($COURSE->id) == 'UNSET') { $this->content->text = ''; $this->content->footer = ''; return $this->content; } if (!mapleta_ws_ping()) { $this->content->text = '<div class="info"><font color="red">' . get_string('mapleta_not_available', 'block_mapleta_course_tools') . '</font></div><br/>'; $this->content->footer = '<div class="info">' . get_string('contact_sys_admin', 'block_mapleta_course_tools') . '</div><br/>'; return $this->content; } $course_mapping = mapleta_get_record('mapleta_course_map', 'courseid', $COURSE->id); if ($COURSE->format != 'site' && !$course_mapping) { if (mapleta_is_administrator($COURSE->id) || mapleta_is_teacher($COURSE->id)) { $this->content->footer = '<div class="info"><a href="' . $CFG->wwwroot . '/mod/mapleta/course_mapping.php?id=' . $COURSE->id . '&action=create">' . get_string('map_the_course', 'block_mapleta_course_tools') . '</a></div>'; $this->content->text = '<div class="info"><font color="red">' . get_string('course_is_not_mapped', 'block_mapleta_course_tools') . '</font></div><br/>'; } } else { if (mapleta_is_administrator($COURSE->id)) { if ($COURSE->format != 'site') { $params = "wsActionID=classHome&wsClassId={$course_mapping->classid}&wsCourseId={$course_mapping->courseid}"; $this->content->text = '<div class="info"><a href="' . $CFG->wwwroot . '/mod/mapleta/launcher_form.php?' . $params . '" onclick="this.target=\'mapleta\'; return openpopup(\'/mod/mapleta/launcher_form.php?' . $params . '\', \'mapleta\', \'menubar=0,location=0,scrollbars,status,resizable,width=1024,height=800\', 0);">' . get_string('class_homepage', 'block_mapleta_course_tools') . '</a></div><br/><hr>'; // . '<a href="'.$CFG->wwwroot.'/mod/mapleta/grade.php">Grade</a>'; $this->content->footer = '<div class="info"><a href="' . $CFG->wwwroot . '/mod/mapleta/course_mapping.php?id=' . $COURSE->id . '&action=delete">' . get_string('remove_course_mapping', 'block_mapleta_course_tools') . '</a></div>'; } else { $params = "wsActionID=systemHome&wsClassId=-1&wsCourseId={$COURSE->id}"; $this->content->footer = '<a href="' . $CFG->wwwroot . '/mod/mapleta/launcher_form.php?' . $params . '" onclick="this.target=\'mapleta\'; return openpopup(\'/mod/mapleta/launcher_form.php?' . $params . '\', \'mapleta\', \'menubar=0,location=0,scrollbars,status,resizable,width=1024,height=800\', 0);">' . get_string('system_homepage', 'block_mapleta_course_tools') . '</a>'; } } else { if (mapleta_is_teacher($COURSE->id) && $COURSE->format != 'site') { $params = "wsActionID=classHome&wsClassId={$course_mapping->classid}&wsCourseId={$course_mapping->courseid}"; $this->content->text = '<div class="info"><a href="' . $CFG->wwwroot . '/mod/mapleta/launcher_form.php?' . $params . '" onclick="this.target=\'mapleta\'; return openpopup(\'/mod/mapleta/launcher_form.php?' . $params . '\', \'mapleta\', \'menubar=0,location=0,scrollbars,status,resizable,width=1024,height=800\', 0);">' . get_string('class_homepage', 'block_mapleta_course_tools') . '</a></div><br/><hr>'; $this->content->footer = '<div class="info"><a href="' . $CFG->wwwroot . '/mod/mapleta/course_mapping.php?id=' . $COURSE->id . '&action=delete">' . get_string('remove_course_mapping', 'block_mapleta_course_tools') . '</a></div>'; } else { if (mapleta_is_proctor($COURSE->id) && $COURSE->format != 'site') { $params = "wsActionID=proctorTools&wsClassId={$course_mapping->classid}&wsCourseId={$course_mapping->courseid}"; $this->content->text = '<div class="info"><a href="' . $CFG->wwwroot . '/mod/mapleta/launcher_form.php?' . $params . '" onclick="this.target=\'mapleta\'; return openpopup(\'/mod/mapleta/launcher_form.php?' . $params . '\', \'mapleta\', \'menubar=0,location=0,scrollbars,status,resizable,width=1024,height=800\', 0);">' . get_string('proctor_tools', 'block_mapleta_course_tools') . '</a></div><br/>'; $this->content->footer = ''; } else { if (mapleta_is_student($COURSE->id) && $COURSE->format != 'site') { $params = "wsActionID=gradeBook&wsClassId={$course_mapping->classid}&wsCourseId={$course_mapping->courseid}&showStudents=true&actionID=4&uid={$USER->username}"; $this->content->text = '<div class="info"><a href="' . $CFG->wwwroot . '/mod/mapleta/launcher_form.php?' . $params . '" onclick="this.target=\'mapleta\'; return openpopup(\'/mod/mapleta/launcher_form.php?' . $params . '\', \'mapleta\', \'menubar=0,location=0,scrollbars,status,resizable,width=1024,height=800\', 0);">' . get_string('gradebook', 'block_mapleta_course_tools') . '</a></div><br/>'; $this->content->footer = ''; } else { $this->content->text = ''; $this->content->footer = ''; } } } } } return $this->content; }
function mapleta_ws_connect_to_class($courseId, $classId) { global $USER, $CFG; $url= $CFG->mapleta_protocol.'://'.$CFG->mapleta_server.'/'.$CFG->mapleta_context.RES_WS_CONNECT; $firstname = mapleta_xmlencode($USER->firstname); $lastname = mapleta_xmlencode($USER->lastname); $username = mapleta_xmlencode($USER->username); $email = mapleta_xmlencode($USER->email); $idnumber = mapleta_xmlencode($USER->idnumber); $role = mapleta_xmlencode(mapleta_get_role($courseId)); $classId = mapleta_xmlencode($classId); $courseId = mapleta_xmlencode($courseId); $signature = mapleta_ws_signature(); $request = "<Request> <firstName>$firstname</firstName> <middleName></middleName> <lastName>$lastname</lastName> <userLogin>$username</userLogin> <userEmail>$email</userEmail> <studentId>$idnumber</studentId> <userRole>$role</userRole> <classId>$classId</classId> <courseId>$courseId</courseId> $signature </Request>"; $xml_response= mapleta_do_xml_post_request($url, $request); $status= new mapleta_status_response(); $out = mapleta_get_response_from_xml($xml_response, 'mapleta_status_response', $status); $array_response= $out->list; return $status; }
require_once("../../config.php"); require_once("lib.php"); global $COURSE, $CFG, $USER; require_login($COURSE->id); $params = array(); foreach ( $_GET as $name => $value ) { $params[$name]=mapleta_xmlencode($value); } $firstname = mapleta_xmlencode($USER->firstname); $lastname = mapleta_xmlencode($USER->lastname); $username = mapleta_xmlencode($USER->username); $email = mapleta_xmlencode($USER->email); $idnumber = mapleta_xmlencode($USER->idnumber); $role = mapleta_xmlencode(mapleta_get_role($params["wsCourseId"])); $params['wsFirstName']=$firstname; $params['wsMiddleName']=''; $params['wsLastName']=$lastname; $params['wsUserLogin']=$username; $params['wsUserEmail']=$email; $params['wsStudentId']=$idnumber; $params['wsUserRole']=$role; mapleta_ws_launch($params); ?>