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 = '<a href="' . $CFG->wwwroot . '/blocks/autoattend/index.php?course=' . $course->id . '&class=' . $classid . '&from=home">' . get_string('takemanualattend', 'block_autoattend') . '</a><br />'; $this->content->text .= '<a href="' . $CFG->wwwroot . '/blocks/autoattend/class_division.php?course=' . $course->id . '&class=' . $classid . '&from=home">' . get_string('students_list', 'block_autoattend') . '</a><br />'; $this->content->text .= '<a href="' . $CFG->wwwroot . '/blocks/autoattend/report.php?course=' . $course->id . '&class=' . $classid . '&from=home&view=months&refresh=1">' . get_string('report', 'block_autoattend') . '</a><br />'; if ($isteacher) { //$this->content->text.= '<a href="'.$CFG->wwwroot.'/blocks/autoattend/class_division.php?course='.$course->id.'">'. // get_string('class_division','block_autoattend').'</a><br />'; // if ($this->version < 2014051100) { $this->content->text .= '<a href="' . $CFG->wwwroot . '/blocks/autoattend/repairDB.php?course=' . $course->id . '">' . get_string('repairdb', 'block_autoattend') . '</a><br />'; } } } 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 . '<br />'; // 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] . '<br />'; } } } $this->content->text .= $settings['X']->description . ': ' . $absence . '<br />'; $percent = $user_summary['percent']; $grade = $user_summary['grade']; $mxgrade = $user_summary['maxgrade']; $this->content->text .= get_string('attendpercent', 'block_autoattend') . ': ' . $percent . ' %<br />'; $this->content->text .= get_string('attendgrade', 'block_autoattend') . ": {$grade} / {$mxgrade}<br />"; $this->content->text .= '<a href="' . $CFG->wwwroot . '/blocks/autoattend/index.php?course=' . $course->id . '&class=' . $classid . '">'; $this->content->text .= get_string('indetail', 'block_autoattend') . '</a>'; } } } else { $this->content->text = ''; // Guest } $this->content->footer = '<hr />'; if (autoattend_disp_feedback($course->id)) { if ($isteacher or $isassist) { $this->content->footer .= '<a href="https://el.mml.tuis.ac.jp/moodle/mod/feedback/view.php?id=528" target="_blank">'; } elseif ($isstudent) { $this->content->footer .= '<a href="https://el.mml.tuis.ac.jp/moodle/mod/feedback/view.php?id=529" target="_blank">'; } $this->content->footer .= get_string('feedback', 'block_autoattend') . '</a><br />'; } $this->content->footer .= '<a href="' . get_string('wiki_url', 'block_autoattend') . '" target="_blank"><i>Autoattend ' . $this->release . '</i></a>'; return $this->content; }
function updateAttendance_show_table($course, $students, $sessdata, $settings, $attsid, $attend, $classid, $name_pattern, $order, $isteacher) { global $CFG, $DB, $OUTPUT, $wwwBlock, $TIME_OFFSET; $url_options = '?course=' . $course->id . '&class=' . $classid . '&attend=' . $attend . '&attsid=' . $attsid; $sessndate = strftime(get_string('strftimedmshort', 'block_autoattend'), $sessdata->sessdate + $TIME_OFFSET); $table = new html_table(); $i = 0; foreach ($students as $student) { $classinfo = autoattend_get_user_class($student->id, $course->id, true); // ID Only if ($classinfo->classid == $classid or $classid == 0 or $classid == NON_CLASSID and $classinfo->classid == 0) { // $att = $DB->get_record('autoattend_students', array('attsid' => $attsid, 'studentid' => $student->id)); if ($att) { $status = $att->status; $called = $att->called; } else { $status = 'Y'; $called = 'D'; } if ($attend == 'A' or $attend == 'Z' and ($status == 'X' or $status == 'Y') or $attend == $status) { $i++; $table->data[$student->id][] = $i; $pic_options = array('size' => 20, 'link' => true, 'alttext' => true, 'courseid' => $course->id, 'popup' => true); $username = jbxl_get_user_name($student->id, $name_pattern); $table->data[$student->id][] = $OUTPUT->user_picture($student->user, $pic_options); $table->data[$student->id][] = '<a href="' . $wwwBlock . '/index.php?course=' . $course->id . '&student=' . $student->id . '" target="_blank">' . $username . '</a>'; if ($CFG->output_idnumber) { if (empty($student->idnumber)) { $table->data[$student->id][] = '-'; } else { $table->data[$student->id][] = $student->idnumber; } } $table->data[$student->id][] = $student->classname; foreach ($settings as $set) { $checked = $set->status == $status ? 'checked' : ''; $table->data[$student->id][] = '<input name="statusid' . $student->id . '" ' . 'type="radio" value="' . $set->status . '" ' . $checked . ' />'; } $table->data[$student->id][] = get_string($called . 'methodfull', 'block_autoattend'); // if (!$att or $att->status === 'X' or $att->status === 'Y') { $table->data[$student->id][] = get_string('novalue', 'block_autoattend'); } else { $calleddate = strftime(get_string('strftimedmshort', 'block_autoattend'), $att->calledtime + $TIME_OFFSET); $calledtime = strftime(get_string('strftimehmshort', 'block_autoattend'), $att->calledtime + $TIME_OFFSET); if ($sessndate === $calleddate) { $table->data[$student->id][] = $calledtime; } else { $table->data[$student->id][] = $calledtime . ' (' . $calleddate . ')'; } } // if ($att) { $ipaddr = $att->ipaddress ? $att->ipaddress : get_string('novalue', 'block_autoattend'); $ipurl = autoattend_get_ipresolv_url($ipaddr); if ($ipurl) { $table->data[$student->id][] = "<a href={$ipurl} target=_blank>{$ipaddr}</a>"; } else { $table->data[$student->id][] = $ipaddr; } } else { $table->data[$student->id][] = get_string('novalue', 'block_autoattend'); } // $remarks = $att ? $att->remarks : ''; $input = '<input type="text" name="remarks' . $student->id . '" size="20" maxlength="40" value="' . $remarks . '" />'; $prvvl1 = '<input type="hidden" name="prvstatusid' . $student->id . '" value="' . $status . '" />'; $prvvl2 = '<input type="hidden" name="prvremarks' . $student->id . '" value="' . $remarks . '" />'; $table->data[$student->id][] = $input . $prvvl1 . $prvvl2; // if ($i % PAGE_ROW_SIZE == 0) { updateAttendance_make_header($table, $settings, $url_options, $i - PAGE_ROW_SIZE, $i, $name_pattern, $order); echo '<div align="center" style="overflow-x: auto;">'; // スクロールしません echo html_writer::table($table); echo '<div align="center">'; updateAttendance_show_button($isteacher); echo '</div>'; echo '</div><br />'; unset($table->data); } } } } // if ($i % PAGE_ROW_SIZE != 0 or $i == 0) { updateAttendance_make_header($table, $settings, $url_options, $i - $i % PAGE_ROW_SIZE, $i, $name_pattern, $order); echo '<div align="center" style="overflow-x: auto;">'; echo html_writer::table($table); echo '<div align="center">'; updateAttendance_show_button($isteacher); echo '</div>'; echo '</div>'; } return; }
function autoattend_get_user_summary($userid, $courseid) { global $CFG, $DB; require_once 'jbxl/jbxl_moodle_tools.php'; $ntime = time(); $class = autoattend_get_user_class($userid, $courseid); $stqry = "SELECT * FROM {$CFG->prefix}autoattend_students std" . " RIGHT JOIN (SELECT * FROM {$CFG->prefix}autoattend_sessions WHERE courseid={$courseid}) ses" . " ON ses.id=std.attsid AND std.studentid={$userid} AND (ses.classid=" . $class->classid . " OR ses.classid=0)" . " ORDER BY ses.sessdate, ses.starttime ASC"; $attitems = $DB->get_records_sql($stqry); if (!$attitems) { return false; } $summary = array(); $summary['userid'] = $userid; $summary['courseid'] = $courseid; $summary['attitems'] = $attitems; $complete = 0; if ($attitems) { foreach ($attitems as $att) { if (!empty($att->status) && $att->status != 'Y') { $complete++; } } } $summary['complete'] = $complete; // 出席コマ数(早退,遅刻を含む) $summary['settings'] = autoattend_get_grade_settings($courseid); $maxgrade = 0; $mingrade = 0; foreach ($summary['settings'] as $set) { $summary[$set->status] = 0; foreach ($summary['attitems'] as $att) { if ($set->status == $att->status) { // 出席の状態をカウント if ($att->status == 'Y') { if ($ntime > $att->endtime) { $summary['X']++; } //else $summary['Y']++; } else { $summary[$set->status]++; } } } if ($set->grade > $maxgrade) { $maxgrade = $set->grade; } if ($set->grade < $mingrade) { $mingrade = $set->grade; } } $sessnum = autoattend_count_sessions($courseid, $class->classid); $summary['Y'] = $sessnum - $summary['P'] - $summary['L'] - $summary['E'] - $summary['X']; // $summary['grade'] = autoattend_get_grade($userid, $courseid); $summary['maxgrade'] = $maxgrade * $sessnum; $summary['mingrade'] = $mingrade * $sessnum; $summary['leccount'] = $sessnum; // $gradelevel = $summary['maxgrade'] - $summary['mingrade']; if ($gradelevel != 0) { $percent = 100 * ($summary['grade'] - $summary['mingrade']) / $gradelevel; $summary['percent'] = sprintf('%0.1f', $percent); } else { $summary['percent'] = ' - '; } $summary['classid'] = $class->classid; $summary['classname'] = $class->name; return $summary; }
function class_division_show_table($students, $courseid, $classid, $name_pattern, $order, $classes, $newclassid) { global $CFG, $wwwBlock, $OUTPUT; $url_options = '?course=' . $courseid . '&class=' . $classid; // if (empty($order) or $order == 'ASC') { $order = 'DESC'; } else { $order = 'ASC'; } // $table = new html_table(); $i = 0; $n = 0; foreach ($students as $student) { $classinfo = autoattend_get_user_class($student->id, $courseid); if ($classinfo->classid == $classid or $classid == 0 or $classid == NON_CLASSID and $classinfo->classid == 0 or $classid == VALID_CLASSID and $classinfo->classid >= 0) { $i++; $table->data[$student->id][] = $i; $username = jbxl_get_user_name($student->id, $name_pattern); $pic_options = array('size' => 20, 'link' => true, 'alttext' => true, 'courseid' => $courseid, 'popup' => true); $table->data[$student->id][] = $OUTPUT->user_picture($student, $pic_options); $table->data[$student->id][] = '<a href="' . $wwwBlock . '/index.php?course=' . $courseid . '&student=' . $student->id . '" target="_blank">' . $username . '</a>'; if ($CFG->output_idnumber) { if (empty($student->idnumber)) { $idnum = ' - '; } else { $idnum = $student->idnumber; } $table->data[$student->id][] = $idnum; } $table->data[$student->id][] = $classinfo->name; $table->data[$student->id][] = '<input type="checkbox" name="changeclass' . $student->id . '" value="1" />'; // if ($i % PAGE_ROW_SIZE == 0) { echo '<div align="center">'; class_division_make_header($table, $url_options, $i - PAGE_ROW_SIZE, $i, $name_pattern, $order); echo html_writer::table($table); class_division_submit_button($classes, $newclassid, $n); $n++; echo '</div><br />'; //echo '</div>'; unset($table->data); } } } if ($i % PAGE_ROW_SIZE != 0 or $i == 0) { echo '<div align="center">'; class_division_make_header($table, $url_options, $i - $i % PAGE_ROW_SIZE, $i, $name_pattern, $order); echo html_writer::table($table); class_division_submit_button($classes, $newclassid, $n); echo '</div>'; } return; }
if ($group->name == autoattend_get_session_classname($existingclass->id)) { // Class exists $newclassid = $existingclass->id; $createclass = false; } } } // Create class if ($createclass) { $newclassid = autoattend_insert_session_class($course->id, $group->name); } // $newclassid, id of the class to join users (created or existing) // Join group members to class $students = groups_get_members($group->id); foreach ($students as $student) { $userclass = autoattend_get_user_class($student->id, $course->id, true); if ($userclass->classid != $newclassid) { $userclass->classid = $newclassid; if ($userclass->id != 0) { $DB->update_record('autoattend_classifies', $userclass); } else { $userclass->id = $DB->insert_record('autoattend_classifies', $userclass); } } } } } } } else { if (isset($formdata->updateclass)) { $exist_flag = false;
$courseid = required_param('course', PARAM_INTEGER); $urlparams['course'] = $courseid; $PAGE->set_url('/blocks/autoattend/semiautobutton.php', $urlparams); $wwwBlock = $CFG->wwwroot . '/blocks/autoattend'; $wwwMyURL = $wwwBlock . '/semiautobutton.php'; $course = $DB->get_record('course', array('id' => $courseid)); if (!$course) { print_error('courseidwrong', 'block_autoattend'); } require_login($course->id); $context = jbxl_get_course_context($course->id); $isstudent = jbxl_is_student($USER->id, $context); // for Student if ($isstudent) { $userid = $USER->id; $classinfo = autoattend_get_user_class($userid, $course->id); // if ($classinfo->classid >= 0) { $ntime = time(); $sessions = autoattend_get_nowopen_sessions($course->id, $userid, 'S', $ntime); // get semiauto sessions if ($sessions) { foreach ($sessions as $session) { $session = autoattend_update_session_state($courseid, $session, $ntime, false); // not regist student if ($session->classid == 0 or $session->classid == $classinfo->classid) { $student = $DB->get_record('autoattend_students', array('attsid' => $session->id, 'studentid' => $userid)); if (empty($student)) { $student = autoattend_add_user_insession($session->id, $userid); } if ($student and $student->status == 'Y') {