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' and $set->display) { $this->content->text.= $settings[$set->status]->description.': '.$user_summary[$set->status].'
'; } } $this->content->text .= $settings['X']->description.': '.$absence.'
'; $npercent = $user_summary['npercent']; $gpercent = $user_summary['gpercent']; $grade = $user_summary['grade']; $pgrade = $user_summary['pgrade']; $mxgrade = $user_summary['maxgrade']; $this->content->text.= get_string('attendnpercent','block_autoattend').': '.$npercent.' %
'; //$this->content->text.= get_string('attendgrade','block_autoattend').": $grade / $mxgrade
"; $this->content->text.= get_string('attendgrade','block_autoattend').": $grade / $pgrade
"; $this->content->text.= get_string('attendgpercent','block_autoattend').': '.$gpercent.' %
'; $this->content->text.= ''; $this->content->text.= get_string('indetail','block_autoattend').''; } } } // else { $this->content->text = ''; // Guest } $this->content->footer = '
'; if (autoattend_disp_feedback($course->id)) { if ($isteacher or $isassist) { $this->content->footer.= ''; } elseif ($isstudent) { $this->content->footer.= ''; } $this->content->footer.= get_string('feedback','block_autoattend').'
'; } $this->content->footer.= 'Autoattend '.$this->release.''; return $this->content; } // setting of instance block. need config_instance.html function instance_allow_config() { return false; } // setting block. need settings.php function has_config() { return true; } function cron() { global $CFG, $DB; $qry = "SELECT DISTINCT courseid FROM {$CFG->prefix}autoattend_sessions"; $courseids = $DB->get_records_sql($qry); if ($courseids) { foreach ($courseids as $id) { $ret = autoattend_update_sessions($id->courseid); } } return true; } }