dirroot.'/blocks/autoattend/locallib.php');
class block_autoattend extends block_base
{
function init()
{
global $CFG;
if (empty($plugin)) $plugin = new stdClass();
include($CFG->dirroot.'/blocks/autoattend/version.php');
//
$this->title = get_string('pluginname', 'block_autoattend');
$this->version = $plugin->version;
$this->release = $plugin->release;
}
function get_content()
{
global $CFG, $USER, $DB;
if ($this->content != NULL) {
return $this->content;
}
$courseid = optional_param('course', 0, PARAM_INTEGER);
$classid = optional_param('class', 0, PARAM_INTEGER);
if ($courseid==0) $courseid = $this->page->course->id;
if ($courseid!=0) {
$course = $DB->get_record('course', array('id'=>$courseid));
if (!$course) {
print_error('courseidwrong', 'block_autoattend');
}
}
else {
return '';
}
$this->content = new stdClass();
$this->content->items = array();
$this->content->icons = array();
$this->content->footer = '';
$this->content->text = '';
//
$context = jbxl_get_course_context($course->id);
$isstudent = false;
$isassist = false;
$isteacher = jbxl_is_teacher($USER->id, $context);
if (!$isteacher) {
$isassist = jbxl_is_assistant($USER->id, $context);
if (!$isassist) $isstudent = jbxl_is_student($USER->id, $context);
}
if ($isteacher or $isassist) { // Teacher
//
$this->content->text = ''.get_string('takemanualattend','block_autoattend').'
';
$this->content->text.= ''.get_string('students_list','block_autoattend').'
';
$this->content->text.= ''.get_string('report','block_autoattend').'
';
if ($isteacher) {
//$this->content->text.= ''.
// get_string('class_division','block_autoattend').'
';
//
if ($this->version < 2014051100) {
$this->content->text.= ''.
get_string('repairdb','block_autoattend').'
';
}
}
}
//
elseif ($isstudent) {
//
$user_summary = autoattend_get_user_summary($USER->id, $course->id);
if(!$user_summary) { //autoattend not generated yet
$this->content->text.= get_string('attendnotstarted','block_autoattend');
}
else { //autoattend taken
$classinfo = autoattend_get_user_class($USER->id, $course->id);
$this->content->text.= get_string('classname','block_autoattend').': '.$classinfo->name.'
';
//
if ($classinfo->classid>=0) { // !出欠から除外
$absence = 0;
$settings = autoattend_get_grade_settings($course->id);
foreach($settings as $set) {
//if ($set->status=='X' or $set->status=='Y') {
if ($set->status=='X') {
$absence+= $user_summary[$set->status];
}
else if ($set->status!='Y') {
$this->content->text.= $settings[$set->status]->description.': '.$user_summary[$set->status].'
';
}
}
$this->content->text .= $settings['X']->description.': '.$absence.'
';
$percent = $user_summary['percent'];
$grade = $user_summary['grade'];
$mxgrade = $user_summary['maxgrade'];
$this->content->text.= get_string('attendpercent','block_autoattend').': '.$percent.' %
';
$this->content->text.= get_string('attendgrade','block_autoattend').": $grade / $mxgrade
";
$this->content->text.= '';
$this->content->text.= get_string('indetail','block_autoattend').'';
}
}
}
//
else {
$this->content->text = ''; // Guest
}
$this->content->footer = '