CopyRight (C) 2007 Information Technology Center, Nagoya Institute of Technology, All Rights Reserved.
diff -Naur attendance.org/block_attendance.php attendance/block_attendance.php
--- attendance.org/block_attendance.php 2006-07-14 11:10:36.000000000 +0900
+++ attendance/block_attendance.php 2007-12-05 19:05:19.000000000 +0900
@@ -75,6 +75,10 @@
return $this->content;
}
+ function applicable_formats() {
+ return array('all' => true, 'mod' => false,
+ 'my' => false, 'admin' => false);
+ }
}
?>
diff -Naur attendance.org/lib.php attendance/lib.php
--- attendance.org/lib.php 2006-06-13 11:10:25.000000000 +0900
+++ attendance/lib.php 2007-12-05 18:47:37.000000000 +0900
@@ -330,6 +330,7 @@
$stqry = "select sessdate,ats.description,status,remarks from {$CFG->prefix}attendance_log al ,{$CFG->prefix}attendance_sessions ats where al.attsid = ats.id and ats.courseid = {$course->id} and al.studentid = {$user->id} order by sessdate asc";
$students = get_records_sql($stqry);
//$students = get_records('attendance_sessions', 'courseid', $course->id, 'sessdate asc');
+ if ($students) {
?>
-->
-libdir.'/blocklib.php');
- require_once('lib.php');
-
- define('USER_SMALL_CLASS', 20); // Below this is considered small
- define('USER_LARGE_CLASS', 200); // Above this is considered large
+function del_bom($str) {
+ return (ord($str{0}) == 0xef && ord($str{1}) == 0xbb && ord($str{2}) == 0xbf) ? substr($str, 3) : $str;
+}
+ require_once('../../config.php');
+ require_once($CFG->libdir.'/uploadlib.php');
+ require_once($CFG->libdir.'/blocklib.php');
+ require_once('lib.php');
+
+ define('USER_SMALL_CLASS', 20);// Below this is considered small
+ define('USER_LARGE_CLASS', 200);// Above this is considered large
define('DEFAULT_PAGE_SIZE', 20);
-
- $courseid = required_param('course', PARAM_INT); // Course id
- $group = optional_param('group', -1, PARAM_INT); // Group to show
- $view = optional_param('view', 'weeks', PARAM_ALPHA); // which page to show
- $current = optional_param('current', 0, PARAM_INT);
- $sort = optional_param('sort', 'lastname', PARAM_ALPHA);
-
+
+ $group = optional_param('group', -1, PARAM_INT); // Group to show
+ $view = optional_param('view', 'all', PARAM_ALPHA);// which page to show: default changed to 'all'
+ $current= optional_param('current', 0, PARAM_INT);
+ $sort = optional_param('sort', 'lastname', PARAM_ALPHA);//default changed to 'username'
+ $mode = optional_param('mode', '', PARAM_ALPHA);
+ $courseid = required_param('course', PARAM_INT);// Course id
+
if (! $course = get_record('course', 'id', $courseid)) {
- error('courseidwrong','block_attendance');
+ redirect($CFG->wwwroot.'/blocks/attendance/report.php?course='.$course->id.'&view=all',get_string('courseidwrong','block_attendance').'
'.get_string('wait10sec','block_attendance'),10);
}
-
require_login($course->id);
-
if (! $user = get_record("user", "id", $USER->id) ) {
- error("No such user in this course");
+ redirect($CFG->wwwroot.'/blocks/attendance/report.php?course='.$course->id.'&view=all',get_string('nouserinthiscourse','block_attendance').'
'.get_string('wait10sec','block_attendance'),10);
}
-
-//add info to log
-
- add_to_log($course->id, 'attendance', 'view report', 'blocks/attendance/index.php?id='.$course->id, $user->lastname.' '.$user->firstname);
-
+ switch($mode) {
+ case "upload":
+ if ($course->category) {
+ print_header("$course->shortname: ".get_string('attendance','block_attendance')
+ .' '.get_string('report','block_attendance'),$course->fullname,
+ "
id\">$course->shortname -> ".
+ get_string('uploadattendance','block_attendance'),"","",true," ",navmenu($course));
+ } else {
+ print_header("$course->shortname: ".get_string('attendance','block_attendance'),
+ $course->fullname,get_string('uploadattendance','block_attendance'),"","",true,
+ " ",navmenu($course));
+ }
+ $csv_encode = '/\&\#44/';
+ if (isset($CFG->CSV_DELIMITER)) {
+ $csv_delimiter = '\\' . $CFG->CSV_DELIMITER;
+ $csv_delimiter2 = $CFG->CSV_DELIMITER;
+ if (isset($CFG->CSV_ENCODE)) $csv_encode = '/\&\#' . $CFG->CSV_ENCODE . '/';
+ } else {
+ $csv_delimiter = "\,";
+ $csv_delimiter2 = ",";
+ }
+ $um = new upload_manager('attendance',false,false,null,false,0);
+ if ($um->preprocess_files() && confirm_sesskey()) {
+ $filename = $um->files['attendance']['tmp_name'];
+ $text = "";
+ if ($file = @fopen($filename, "rb")) {
+ while (!feof($file)) {
+ $text .= preg_replace('!\r\n?!',"\n",fread($file, 1024));
+ }
+ fclose($file);
+ } else {
+ redirect($CFG->wwwroot.'/blocks/attendance/report.php?course='.$course->id.'&view=all',get_string('formaterror', 'block_attendance',$filename).'
'.get_string('wait10sec','block_attendance'),10);
+ }
+ $fp = fopen($filename, "w");
+ fwrite($fp,$text);
+ fclose($fp);
+ $fp = fopen($filename, "r");
+ $required = array("username"=>1,"attendance"=>1,"date"=>1);
+ $optional = array("firstname"=>1,"lastname"=>1);
+ $str = fgets($fp,1024);
+ $str = mb_convert_encoding($str, "UTF-8", "sjis-win");
+ $header = split($csv_delimiter, $str);
+ // check for valid field names
+ foreach ($header as $i => $h) {
+ $h = trim($h); $header[$i] = $h; // remove whitespace
+ if (!($required[$h] or $optional[$h])) {
+ redirect($CFG->wwwroot.'/blocks/attendance/report.php?course='.$course->id.'&view=all',get_string('invalidfieldname', 'error', $h).'
'.get_string('wait10sec','block_attendance'),10);
+ }
+ if ($required[$h]) $required[$h] = 0;
+ }
+ foreach ($required as $key => $value) {
+ if ($value) {
+ redirect($CFG->wwwroot.'/blocks/attendance/report.php?course='.$course->id.'&view=all',get_string('fieldrequired', 'error', $key).'
'.get_string('wait10sec','block_attendance'),10);
+ }
+ }
+ // setting up status table
+ $settings = get_settings(0);// assoc array with key:1/2/3/4 -> value:P/A/L/E
+ foreach($settings as $setting) {
+ $stata[$setting->id] = $setting->status;
+ }
+ $linenum = 2;
+ $newadded= 0;
+ $updated = 0;
+ $errors = 0;
+ while (!feof ($fp)) {
+ $str = fgets($fp,1024);
+ $str = mb_convert_encoding($str, "UTF-8", "sjis-win");
+ $line = split($csv_delimiter,$str);
+ if($line[0]=="") break;
+ foreach ($line as $key => $value) {
+ $record[$header[$key]] = preg_replace($csv_encode,$csv_delimiter2,trim($value));
+ if($header[$key]=='date') {
+ $datetime = $record[$header[$key]];// imported date string
+ if(preg_match("/^(\d\d\d\d)\/(\d+)\/(\d+)\s+(\d+):(\d+).*$/", $datetime, $val)) {
+ $datekey = mktime(0, 0, 0, $val[2], $val[3], $val[1]);// for access key on session table
+ $record[$header[$key]] = mktime($val[4], $val[5], 0, $val[2], $val[3], $val[1]);// for internal use
+ } else {
+ $a->key = $header[$key];
+ $a->date = $datetime;
+ echo("
".get_string('formaterror','block_attendance',$a)."");
+ $errors++;
+ continue;
+ }
+ }
+ }
+ if ($record[$header[0]]) {
+ foreach ($record as $name => $value) {
+ if ($required[$name] and !$value) {
+ echo get_string('missingfield', 'error', $name).'
'.get_string('erroronline','error',$linenum).'
'.get_string('processingstops', 'error');
+ $errors++;
+ continue;
+ } else {// normal entry
+ $attendance->{$name} = addslashes($value);
+ }
+ }
+ $linenum++;
+ if ($studentuser = get_record("user","username",$attendance->username)) {
+ if(isset($header['firstname'])) {
+ if(!$studentuser->firstname == $attendance->firstname) {
+ echo("
".get_string('firstnameunmatched','block_assignment',$attendance)."");
+ $errors++;
+ continue;
+ }
+ }
+ if(isset($header['lastname'])) {
+ if(!$studentuser->lastname == $attendance->lastname) {
+ echo("
".get_string('lastnameunmatched','block_assignment',$attendance)."");
+ $errors++;
+ continue;
+ }
+ }
+ } else {
+ echo("
".get_string('notregistered','block_attendance',$attendance)."");
+ $errors++;
+ continue;
+ }
+ if(!$sessions = get_record("attendance_sessions","courseid",$course->id, "sessdate", $datekey)) {
+ echo("
".get_string('datespecifyerror','block_attendance',$attendance)."");
+ $errors++;
+ continue;
+ }
+ // Record is being updated
+ if ($oldlog = get_record("attendance_log","attsid",$sessions->id,"studentid",$studentuser->id)) {
+ $log = $oldlog;
+ $log->status = $stata[$attendance->attendance];
+ $log->remarks = $datetime;
+ if(update_record('attendance_log', $log)) {
+ echo("
".get_string('updated','block_attendance',$attendance)."");
+ $sessions->timetaken = $attendance->date;
+ $sessions->takenby = $USER->id;
+ $sessions->timemodified = time();
+ if(!update_record('attendance_sessions',$sessions)) {
+ echo("
".get_string('updateerror','block_attendance',$attendance)."");
+ $errors++;
+ continue;
+ }
+ $updated++;
+ } else {
+ echo("
".get_string('updateerror','block_attendance',$attendance)."");
+ $errors++;
+ continue;
+ }
+ } else {// Record is being added
+ $log = new Object;
+ $log->attsid = $sessions->id;
+ $log->studentid = $studentuser->id;
+ $log->status = $stata[$attendance->attendance];
+ $log->remarks = $datetime;
+ if (insert_record("attendance_log", $log)) {
+ echo("
".get_string('added','block_attendance',$attendance)."");
+ $sessions->timetaken = $attendance->date;
+ $sessions->takenby = $USER->id;
+ $sessions->timemodified = time();
+ if(!update_record('attendance_sessions', $sessions)) {
+ echo("
".get_string('updateerror','block_attendance',$attendance)."");
+ $errors++;
+ continue;
+ }
+ $newadded++;
+ } else {
+ echo("
".get_string('adderror','block_attendance',$attendance)."");
+ $errors++;
+ continue;
+ }
+ }
+ }
+ unset($attendance);
+ unset($sessions);
+ unset($log);
+ }//end of while loop
+ fclose($fp);
+ echo("
");
+ echo("
".get_string('addedrecords','block_attendance').":$newadded");
+ echo("
".get_string('updatedrecords','block_attendance').":$updated");
+ echo("
".get_string('errorrecords','block_attendance').":$errors");
+ echo("
");
+ redirect($CFG->wwwroot.'/blocks/attendance/report.php?course='.$course->id.'&view=all',get_string('wait10sec','block_attendance'),10);
+ }//endif
+ //at first select upload file
+ print_heading_with_help(get_string('uploadattendance','attendance'), 'uploadattendance');
+ echo '
';
+ print_footer($course);
+ exit;
+ case "download":
+ add_to_log($course->id, 'attendance', 'download attendance data', 'blocks/attendance/index.php?id='.$course->id, $user->lastname.' '.$user->firstname);
+ $courseid = required_param('course', PARAM_INT);
+ if (! $course = get_record('course', 'id', $courseid)) error('courseidwrong','block_attendance');
+ if (! $user = get_record("user", "id", $USER->id) ) error("No such user in this course");
+ if (isteacher($course->id)) {
+ if(!count_records('attendance_sessions', 'courseid', $course->id)) {
+ redirect($CFG->wwwroot.'/blocks/attendance/report.php?course='.$course->id.'&view=all',get_string('wait10sec','block_attendance'),10);
+ } else {
+ $settings = get_settings(0);//attendance id is set with course id 0
+ $students = get_course_students($course->id, "username", "ASC");
+ $where = "courseid={$course->id} AND sessdate <= ".time();
+ if ($students and ($course_sess = get_records_select('attendance_sessions', $where, 'sessdate ASC'))) {
+ header("Content-Type: application/download\n");
+ $downloadfilename = clean_filename($course->shortname.'_attendance_'.date("Y-m-d_H-i-s"));
+ header("Content-Disposition: attachment; filename=\"$downloadfilename.csv\"");
+ echo "username,firstname,lastname,attendance,date\r\n";
+ foreach($students as $student) {
+ $qry = get_records_sql("SELECT alog.id, alog.status, s.sessdate FROM {$CFG->prefix}attendance_log alog JOIN {$CFG->prefix}attendance_sessions s ON alog.attsid=s.id WHERE alog.studentid={$student->id} AND s.courseid={$course->id};");
+ foreach($course_sess as $sessdata) {
+ if ($att = get_record('attendance_log', 'attsid', $sessdata->id, 'studentid', $student->id)) {
+ $str = $student->username.','.$student->firstname.','.$student->lastname.','.$settings[$att->status]->id.','.date("Y/m/d H:i" , $sessdata->sessdate)."\r\n";
+ } else {
+ $str = $student->username.','.$student->firstname.','.$student->lastname.',0,'.date("Y/m/d H:i" , $sessdata->sessdate)."\r\n";
+ }
+ echo mb_convert_encoding(del_bom($str), "sjis-win", "UTF-8");
+ }
+ }
+ } else {
+ echo get_string('nothingtodisplay')."\n";
+ }
+ }
+ }
+ exit;
+ default:
+ add_to_log($course->id, 'attendance', 'view report', 'blocks/attendance/index.php?id='.$course->id, $user->lastname.' '.$user->firstname);
+ break;
+ }//endswitch
/// Print headers
-
if ($course->category) {
- print_header("$course->shortname: ".get_string('attendance','block_attendance') .' ' .get_string('report','block_attendance'), $course->fullname,
- "
id\">$course->shortname -> ".
- get_string('attendance','block_attendance'), "", "", true, " ", navmenu($course));
+ print_header("$course->shortname: ".get_string('attendance','block_attendance') .' ' .get_string('report','block_attendance'),
+ $course->fullname,
+ "
id\">$course->shortname -> ".
+ get_string('attendance','block_attendance'), "", "", true, " ", navmenu($course));
} else {
- print_header("$course->shortname: ".get_string('attendance','block_attendance'), $course->fullname,
- get_string('attendance','block_attendance'), "", "", true, " ", navmenu($course));
+ print_header("$course->shortname: ".get_string('attendance','block_attendance'),
+ $course->fullname,
+ get_string('attendance','block_attendance'), "", "", true, " ", navmenu($course));
}
-
- $currenttab = 'report';
+ $currenttab = 'report';
include('tabs.php');
+ $sort = $sort == 'username' ? 'username' : 'lastname';
- $sort = $sort == 'firstname' ? 'firstname' : 'lastname';
-
- if (isteacher($course->id))
- {
- if(!count_records('attendance_sessions', 'courseid', $course->id)) // no session exists for this course
- {
- redirect($CFG->wwwroot.'/blocks/attendance/add.php?course='.$course->id);
- }
- else // display attendance report
- {
-// if (!$result = get_records('attendance_settings', 'courseid', $course->id, 'id')) {
-// $result = get_records('attendance_settings', 'courseid', 0);
-// }
-// $settings = array();
-// foreach ($result as $res) {
-// $settings[$res->status] = $res;
-// }
+ if (isteacher($course->id)) {
+ if(!count_records('attendance_sessions', 'courseid', $course->id)) {// no session exists for this course
+ redirect($CFG->wwwroot.'/blocks/attendance/report.php?course='.$course->id.'&view=all',get_string('wait10sec','block_attendance'),10);
+ } else {// display attendance report
$settings = get_settings($course->id);
-
- // display group selector
- echo '
'.helpbutton ('report', get_string('help'), 'block_attendance', true, true, '', true).'
';
+// display group selector
+ echo '
| '.helpbutton ('report', get_string('help'), 'block_attendance', true, true, '', true).'';
if ($currentgroup = setup_and_print_groups($course, VISIBLEGROUPS, "report.php?course={$course->id}")) {
- $students = get_group_users($currentgroup, "u.$sort ASC");
+ $students = get_group_users($currentgroup, "u.$sort ASC");
} else {
- $students = get_course_students($course->id, "$sort", "ASC");
+ $students = get_course_students($course->id, "lastname", "ASC");//$sort--->'lastname'
}
- // display date interval selector
+// display date interval selector
$rec = get_record_sql("SELECT MIN(sessdate) AS min, MAX(sessdate) AS max FROM {$CFG->prefix}attendance_sessions WHERE courseid=$course->id", false);
$firstdate = $rec->min;
$lastdate = $rec->max;
$now = time();
- if ($current == 0)
- $current = $now;
+ if ($current == 0) $current = $now;
list(,,,$sday, $wday, $smonth, $syear) = array_values(getdate($rec->min));
- if ($wday == 0)
- $wday = 7;
- $startdate = mktime(0, 0, 0, $smonth, $sday-$wday+1, $syear);
-
- $options["all"] = get_string('alltaken','block_attendance');
- $options['weeks'] = get_string('weeks','block_attendance');
- $options['months'] = get_string('months','block_attendance');
- echo ''.helpbutton ('display', get_string('display','block_attendance'), 'block_attendance', true, false, '', true).get_string('display','block_attendance').': ';
- if (isset($_GET['view'])) //{
- set_current_view($course->id, $_GET['view']);
- $view = get_current_view($course->id);
- popup_form("report.php?course={$course->id}&sort=$sort&view=", $options, 'viewmenu', $view, '');
-
- $out = '';
- $weeks = array();
- if ($view === 'weeks') {
- $startdate = mktime(0, 0, 0, $smonth, $sday-$wday+1, $syear);
- $format = get_string('strftimedm', 'block_attendance');
- for ($i = 1, $monday = $startdate; $monday <= $lastdate; $i++, $monday += ONE_WEEK) {
- if (count_records_select('attendance_sessions', "courseid={$course->id} AND sessdate >= ".$monday." AND sessdate < ".($monday + ONE_WEEK))) {
- $weeks[] = $monday;
- }
- }
- } elseif ($view === 'months') {
- $startdate = mktime(0, 0, 0, $smonth, 1, $syear);
- $format = '%B';
- for ($i = 1, $monday = $startdate; $monday <= $lastdate; $i++, $monday = mktime(0, 0, 0, $smonth-1+$i, 1, $syear)) {
- if (count_records_select('attendance_sessions', "courseid={$course->id} AND sessdate >= ".$monday." AND sessdate < ".mktime(0, 0, 0, $smonth+$i, 1, $syear))) {
- $weeks[] = $monday;
- }
- }
- }
- $found = false;
- for ($i = count($weeks)-1; $i >= 0; $i--) {
- if ($weeks[$i] <= $current && !$found) {
- $found = true;
- $current = $weeks[$i];
- $out = ''.strftime($format, $weeks[$i]).' / '.$out;
-// $out = ''.userdate($weeks[$i], $format).' / '.$out;
- } else {
- $out = "\nid}¤t={$weeks[$i]}&sort=$sort\">".strftime($format, $weeks[$i])." / ".$out;
-// $out = "\nid}¤t={$weeks[$i]}\">".userdate($weeks[$i], $format)." / ".$out;
- }
- }
- echo substr($out, 0, -2)."\n";
-
- if ($view === 'weeks') {
- $where = "courseid={$course->id} AND sessdate >= $current AND sessdate < ".($current + ONE_WEEK);
- } elseif ($view === 'months') {
- $where = "courseid={$course->id} AND sessdate >= $current AND sessdate < ".mktime(0, 0, 0, date("m", $current)+1, 1, date("Y", $current));
- } else {
- $where = "courseid={$course->id} AND sessdate <= ".time();
- }
- if ($students and
- ($course_sess = get_records_select('attendance_sessions', $where, 'sessdate ASC'))) {
-
- $firstname = "id}&sort=firstname\">".get_string('firstname').'';
- $lastname = "id}&sort=lastname\">".get_string('lastname').'';
- if ($CFG->fullnamedisplay == 'lastname firstname') { // for better view (dlnsk)
- $fullnamehead = "$lastname / $firstname";
- } else {
- $fullnamehead = "$firstname / $lastname";
- }
-
- $maxgrade = get_maxgrade($course->id);
-
- $table->head[] = '';
- $table->align[] = '';
- $table->size[] = '1px';
- $table->head[] = $fullnamehead;
- $table->align[] = 'left';
- $table->size[] = '';
- foreach($course_sess as $sessdata) {
- $table->head[] = "id}&sessdate={$sessdata->sessdate}&attsid={$sessdata->id}\">".strftime(get_string('strftimedm', 'block_attendance'), $sessdata->sessdate).'';
- $table->align[] = 'center';
- $table->size[] = '1px';
- }
- for ($i=0; $i<5; $i++) {
- $table->align[] = 'center';
- $table->size[] = '1px';
- }
-
-// foreach($settings as $set) {
-// $table->head[] = $set->acronym;
-// }
+ if ($wday == 0) $wday = 7;
+ $startdate = mktime(0, 0, 0, $smonth, $sday-$wday+1, $syear);
+ $options["all"] = get_string('alltaken','block_attendance');
+ $options['weeks'] = get_string('weeks','block_attendance');
+ $options['months'] = get_string('months','block_attendance');
+ echo ' | '.helpbutton ('display', get_string('display','block_attendance'), 'block_attendance', true, false, '', true).get_string('display','block_attendance').': ';
+ if (isset($_GET['view'])) set_current_view($course->id, $_GET['view']);
+ $view = get_current_view($course->id);
+ popup_form("report.php?course={$course->id}&sort=$sort&view=", $options, 'viewmenu', $view, '');
+ $out = '';
+ $weeks = array();
+ if ($view === 'weeks') {
+ $startdate = mktime(0, 0, 0, $smonth, $sday-$wday+1, $syear);
+ $format = get_string('strftimedm', 'block_attendance');
+ for ($i = 1, $monday = $startdate; $monday <= $lastdate; $i++, $monday += ONE_WEEK) {
+ if (count_records_select('attendance_sessions', "courseid={$course->id} AND sessdate >= ".$monday." AND sessdate < ".($monday + ONE_WEEK))) {
+ $weeks[] = $monday;
+ }
+ }
+ } elseif ($view === 'months') {
+ $startdate = mktime(0, 0, 0, $smonth, 1, $syear);
+ $format = '%B';
+ for ($i = 1, $monday = $startdate; $monday <= $lastdate; $i++, $monday = mktime(0, 0, 0, $smonth-1+$i, 1, $syear)) {
+ if (count_records_select('attendance_sessions', "courseid={$course->id} AND sessdate >= ".$monday." AND sessdate < ".mktime(0, 0, 0, $smonth+$i, 1, $syear))) $weeks[] = $monday;
+ }
+ }
+ $found = false;
+ for ($i = count($weeks)-1; $i >= 0; $i--) {
+ if ($weeks[$i] <= $current && !$found) {
+ $found = true;
+ $current = $weeks[$i];
+ $out = ''.strftime($format, $weeks[$i]).' / '.$out;
+ } else {
+ $out = "\nid}¤t={$weeks[$i]}&sort=$sort\">".strftime($format, $weeks[$i])." / ".$out;
+ }
+ }
+ echo ' | '.substr($out, 0, -2).' | ';
+ echo '\n";
+ echo ' |
'."\n";
+ if ($view === 'weeks') {
+ $where = "courseid={$course->id} AND sessdate >= $current AND sessdate < ".($current + ONE_WEEK);
+ } elseif ($view === 'months') {
+ $where = "courseid={$course->id} AND sessdate >= $current AND sessdate < ".mktime(0, 0, 0, date("m", $current)+1, 1, date("Y", $current));
+ } else {
+ $where = "courseid={$course->id} AND sessdate <= ".time();
+ }
+ if ($students and ($course_sess = get_records_select('attendance_sessions', $where, 'sessdate ASC'))) {
+ $firstname = "
id}&sort=firstname\">".get_string('firstname').'';
+ $lastname = "
id}&sort=lastname\">".get_string('lastname').'';
+ $fullnamehead = ($CFG->fullnamedisplay == 'lastname firstname') ? "$lastname / $firstname" : "$firstname / $lastname";
+ $maxgrade = get_maxgrade($course->id);
+ $table->head[] = '';
+ $table->align[] = '';
+ $table->size[] = '1px';
+ $table->head[] = '';/*$fullnamehead;*/
+ $table->align[] = 'left';
+ $table->size[] = '';
+ foreach($course_sess as $sessdata) {
+ $table->head[] = "
id}&sessdate={$sessdata->sessdate}&attsid={$sessdata->id}\">".strftime(get_string('strftimedm', 'block_attendance'), $sessdata->sessdate).'';
+ $table->align[] = 'center';
+ $table->size[] = '1px';
+ }
+ for ($i=0; $i<5; $i++) {
+ $table->align[] = 'center';
+ $table->size[] = '1px';
+ }
array_push($table->head, $settings['P']->acronym, $settings['A']->acronym, $settings['L']->acronym, $settings['E']->acronym);
- $table->head[] = get_string('grade').' / '.$maxgrade;
-
- $table->align[] = 'right';
- $table->size[] = '1px';
- $table->head[] = '%';
-
- foreach($students as $student) {
- $table->data[$student->id][] = print_user_picture($student->id, $course->id, $student->picture, 20, true, true);
-// $table->data[$student->id][] = "
wwwroot}/user/view.php?id={$student->id}&course={$course->id}\">".fullname($student).'';
- $table->data[$student->id][] = "
id}&student={$student->id}\">".fullname($student).'';
- $qry = get_records_sql("SELECT alog.id, alog.status, s.sessdate FROM {$CFG->prefix}attendance_log alog JOIN {$CFG->prefix}attendance_sessions s ON alog.attsid=s.id WHERE alog.studentid={$student->id} AND s.courseid={$course->id};");
- foreach($course_sess as $sessdata) {
- if ($att = get_record('attendance_log', 'attsid', $sessdata->id, 'studentid', $student->id)) {
- $table->data[$student->id][] = $settings[$att->status]->acronym; //get_string("{$att->status}acronym",'block_attendance');
- } else {
- $table->data[$student->id][] = '-';
- }
- }
- $table->data[$student->id][] = get_attendance($student->id,$course->id,'P');
- $table->data[$student->id][] = get_attendance($student->id,$course->id,'A');
- $table->data[$student->id][] = get_attendance($student->id,$course->id,'L');
- $table->data[$student->id][] = get_attendance($student->id,$course->id,'E');
- $table->data[$student->id][] = get_grade($student->id,$course->id); //.' ('.get_percent($student->id,$course->id).'%)';
- $table->data[$student->id][] = sprintf("%0.2f", get_percent($student->id,$course->id)).'%';
- }
- echo '
';
- print_table($table);
- } else {
- print_heading(get_string('nothingtodisplay'), 'center');
- }
-
- echo get_string('status','block_attendance').':
';
- foreach($settings as $set) {
- echo $set->acronym.' - '.$set->description.'
';
- }
- }
- }
- print_footer($course);
-?>
\ ファイル末尾に改行がありません
+ $table->head[] = get_string('grade').' / '.$maxgrade;
+ $table->align[] = 'right';
+ $table->size[] = '1px';
+ $table->head[] = '%';
+ foreach($students as $student) {
+ $table->data[$student->id][] = print_user_picture($student->id, $course->id, $student->picture, 20, true, true);
+// $table->data[$student->id][] = "
wwwroot}/user/view.php?id={$student->id}&course={$course->id}\">".fullname($student).'';
+ $table->data[$student->id][] = "
id}&student={$student->id}\">".fullname($student).'';
+ $qry = get_records_sql("SELECT alog.id, alog.status, s.sessdate FROM {$CFG->prefix}attendance_log alog JOIN {$CFG->prefix}attendance_sessions s ON alog.attsid=s.id WHERE alog.studentid={$student->id} AND s.courseid={$course->id};");
+ foreach($course_sess as $sessdata) {
+ if ($att = get_record('attendance_log', 'attsid', $sessdata->id, 'studentid', $student->id)) {
+ $table->data[$student->id][] = $settings[$att->status]->acronym; //get_string("{$att->status}acronym",'block_attendance');
+ } else {
+ $table->data[$student->id][] = '-';
+ }
+ }
+ $table->data[$student->id][] = get_attendance($student->id,$course->id,'P');
+ $table->data[$student->id][] = get_attendance($student->id,$course->id,'A');
+ $table->data[$student->id][] = get_attendance($student->id,$course->id,'L');
+ $table->data[$student->id][] = get_attendance($student->id,$course->id,'E');
+ $table->data[$student->id][] = get_grade($student->id,$course->id); //.' ('.get_percent($student->id,$course->id).'%)';
+ $table->data[$student->id][] = sprintf("%0.2f", get_percent($student->id,$course->id)).'%';
+ }
+ echo '
';
+ print_table($table);
+ } else {
+ print_heading(get_string('nothingtodisplay'), 'center');
+ }
+ echo get_string('status','block_attendance').':
';
+ foreach($settings as $set) echo $set->acronym.' - '.$set->description.'
';
+ }
+ }
+ print_footer($course);
+?>