libdir.'/blocklib.php'); require_once('lib.php'); // define('DEFAULT_PAGE_SIZE', 15); $courseid = required_param('course', PARAM_INTEGER); // Course id $attsid = required_param('attsid', PARAM_INTEGER); $classid = optional_param('class', 0, PARAM_INTEGER); $attend = optional_param('attend', 'A', PARAM_ALPHA); // A: All, Z: X or Y $sort = optional_param('sort', 'lastname', PARAM_ALPHA); if (($formdata = data_submitted()) and !confirm_sesskey()) { print_error('invalidsesskey'); } $urlparams['course'] = $courseid; $urlparams['attsid'] = $attsid; $urlparams['class'] = $classid; $urlparams['attend'] = $attend; if ($sort) $urlparams['sort'] = $sort; $this_url = new moodle_url('/blocks/autoattend/updateAttendance.php', $urlparams); $PAGE->set_url($this_url); $wwwBlock = $CFG->wwwroot.'/blocks/autoattend'; $wwwMyURL = $wwwBlock.'/updateAttendance.php'; $course = $DB->get_record('course', array('id'=>$courseid)); if (!$course) { print_error('courseidwrong', 'block_autoattend'); } require_login($course->id); $context = get_context_instance(CONTEXT_COURSE, $course->id); $isassist = false; $isteacher = jbxl_is_teacher($USER->id, $context); if (!$isteacher) { $isassist = jbxl_is_assistant($USER->id, $context); if (!$isassist) { print_error('notaccessstudent', 'block_autoattend'); } } $user = $DB->get_record('user', array('id'=>$USER->id)); if (!$user) { print_error('nosuchuser', 'block_autoattend'); } /////////////////////////////////////////////////////////////////////////////// // function updateAttendance_make_header(&$table, $settings, $url_options, $start, $end) { global $CFG, $wwwMyURL; $firstname = ''.get_string('firstname').''; $lastname = '' .get_string('lastname').''; if ($CFG->fullnamedisplay=='lastname firstname') { // for better view (dlnsk) $fullnamehead = $lastname.' / '.$firstname; } else { $fullnamehead = $firstname.' / '.$lastname; } // $i = 0; foreach($settings as $set) { $cell = $i + 4; $status = get_string($set->status.'acronym', 'block_autoattend'); $tabhead[] = "$status"; $i++; } unset($table->head); unset($table->align); unset($table->size); unset($table->wrap); $table->head [] = '#'; $table->align[] = 'center'; $table->size [] = '20px'; $table->head [] = ''; $table->align[] = ''; $table->size [] = '20px'; $table->head [] = $fullnamehead; $table->align[] = 'left'; $table->size [] = '120px'; $table->wrap [2]= 'nowrap'; $table->head [] = get_string('classname', 'block_autoattend'); $table->align[] = 'center'; $table->size [] = '60px'; $table->wrap [] = 'nowrap'; foreach ($tabhead as $hd) { $table->head [] = $hd; $table->align[] = 'center'; $table->size [] = '20px'; $table->wrap [] = 'nowrap'; } $table->head [] = get_string('callmethod', 'block_autoattend'); $table->align[] = 'center'; $table->size [] = '60px'; $table->wrap [] = 'nowrap'; //$table->head [] = get_string('calleddate', 'block_autoattend'); //$table->align[] = 'center'; //$table->size [] = '40px'; //$table->wrap [] = 'nowrap'; $table->head [] = get_string('calledtime', 'block_autoattend'); $table->align[] = 'center'; $table->size [] = '60px'; $table->wrap [] = 'nowrap'; $table->head [] = get_string('ipaddress', 'block_autoattend'); $table->align[] = 'center'; $table->size [] = '80px'; $table->wrap [] = 'nowrap'; $table->head [] = get_string('remarks', 'block_autoattend'); $table->align[] = 'center'; $table->size [] = '80px'; $table->wrap [] = 'nowrap'; return; } function updateAttendance_show_table($course, $students, $sessdata, $settings, $attsid, $attend, $classid) { global $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); $table->data[$student->id][] = $OUTPUT->user_picture($student->user, $pic_options); $table->data[$student->id][] = ''.$student->fullname.''; $table->data[$student->id][] = $student->classname; foreach($settings as $set) { $checked = $set->status==$status ? 'checked' : ''; $table->data[$student->id][] = ''; } $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); //$table->data[$student->id][] = strftime(get_string('strftimecalled', 'block_autoattend'), $att->calledtime + $TIME_OFFSET); if ($sessndate===$calleddate) { //$table->data[$student->id][] = '
'.$calledtime.'
'; $table->data[$student->id][] = $calledtime; } else { //$table->data[$student->id][] = '
'.$calledtime.' ('.$calleddate.')
'; $table->data[$student->id][] = $calledtime.' ('.$calleddate.')'; } } // if ($att) { $ipaddr = $att->ipaddress ? $att->ipaddress : get_string('novalue', 'block_autoattend'); //$ipurl = jbxl_get_ipresolv_url($ipaddr); $ipurl = autoattend_get_ipresolv_url($ipaddr); if ($ipurl) $table->data[$student->id][] = "$ipaddr"; else $table->data[$student->id][] = $ipaddr; } else { $table->data[$student->id][] = get_string('novalue', 'block_autoattend'); } // $remarks = $att ? $att->remarks : ''; $input = ''; $prvvl1 = ''; $prvvl2 = ''; $table->data[$student->id][] = $input.$prvvl1.$prvvl2; // if ($i%DEFAULT_PAGE_SIZE==0) { updateAttendance_make_header($table, $settings, $url_options, $i-DEFAULT_PAGE_SIZE, $i); //echo '
'; echo html_writer::table($table); //echo '


'; unset($table->data); } } } } // if ($i%DEFAULT_PAGE_SIZE!=0 or $i==0) { updateAttendance_make_header($table, $settings, $url_options, $i-$i%DEFAULT_PAGE_SIZE, $i); //echo '
'; echo html_writer::table($table); //echo '


'; } return; } /////////////////////////////////////////////////////////////////////////////// // //autoattend_update_sessions($courseid); autoattend_update_session($courseid, $attsid); // Print Header if ($course->category) { $title = get_string('updatesessionattend','block_autoattend').' '.get_string('autoattend','block_autoattend'); } else { $title = $course->shortname.': '.get_string('autoattend','block_autoattend'); } $PAGE->set_title($title); $PAGE->set_heading($course->fullname); $PAGE->set_cacheable(true); $PAGE->set_button(' '); $PAGE->set_headingmenu(navmenu($course)); echo $OUTPUT->header(); // $currenttab = 'attendance'; include('tabs.php'); $sessdata = $DB->get_record('autoattend_sessions', array('id'=>$attsid)); if (!$sessdata) { print_error('reqinfomiss', 'block_autoattend', $wwwBlock.'/index.php?course='.$courseid); } $sort = ($sort=='firstname' ? 'firstname' : 'lastname'); $students = autoattend_get_attend_students($course->id, $sessdata->classid, $context, $sort); $settings = autoattend_get_grade_settings($course->id); // // Display Attendance Table if ($students) { $totalmember = autoattend_count_attend_students($courseid, $classid, $context); $sessdata->classid = $classid; $attcount = autoattend_count_class_students($sessdata, $courseid, $context, "status<>'Y' AND status<>'X'"); // $classes = autoattend_get_session_classes($courseid); $url_options_base = '?course='.$courseid.'&attsid='.$attsid.'&sort='.$sort; $url_options_attend = $url_options_base.'&class='.$classid; $url_options_class = $url_options_base.'&attend='.$attend; include('updateAttendance.html'); } else { echo $OUTPUT->heading(get_string('nothingtodisplay')); } echo $OUTPUT->footer($course);