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;
 }
Esempio n. 2
0
function mapleta_get_role($courseId) {
	if(mapleta_is_administrator($courseId)) {
		return 'ADMINISTRATOR';
	}
	if(mapleta_is_teacher($courseId)) {
		return 'INSTRUCTOR';
	}
	if(mapleta_is_proctor($courseId)) {
		return 'PROCTOR';
	}
	if(mapleta_is_student($courseId)) {
		return 'STUDENT';
	}
	return 'UNSET';
}
Esempio n. 3
0
		    			"<span id='mapleta-config'>" .
		    			"<font color='red'>" .
		    			"The course mapping cannot be deleted<br>" .
		    			"because there are Maple T.A. assignments still referenced from this course. <br>" .
		    			"Please remove all Maple T.A. assignment references and try again. <br>" .
		    			"</font>" .
		    			"</span>" .
		    			"</center>";
		    }

			
			echo "</form>";
		} else { // Not admin or teacher
			print_error('not_authorized_for_action', 'mapleta', $errorURL);
		}
	} else if($action == "dodelete") {
		if(mapleta_is_administrator($id) || mapleta_is_teacher($id)) {
			if (mapleta_delete_records("mapleta_course_map", "id", $course_mapping->id)) {
				echo "<br/><center><strong>Mapping for course $course->fullname has been deleted.</strong></center><br/>";
			} else {
				print_error('error_deleting_mapping', 'mapleta', $errorURL);
			}
		} else { // Not admin or teacher
			print_error('not_authorized_for_action', 'mapleta', $errorURL);
		}
	} else {
		echo "<br/><center><strong>Course $course->fullname has been mapped to Maple TA class '".$course_mapping->classname."'.</strong></center><br/>";
	}

?>