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); if (! $course = get_record('course', 'id', $courseid)) { error(get_string('courseidwrong','block_autoattend')); } require_login($course->id); if (! $user = get_record("user", "id", $USER->id) ) { error(get_string('nosuchuser','block_autoattend')); } // add info to log add_to_log($course->id, 'autoattend', 'view report', 'index.php?id='.$course->id); // Print headers if ($course->category) { print_header("$course->shortname: ".get_string('autoattend','block_autoattend') .' '. get_string('report','block_autoattend'), $course->fullname, "id\">$course->shortname -> ". get_string('autoattend','block_autoattend'), "", "", true, " ", navmenu($course)); } else { print_header("$course->shortname: ".get_string('autoattend','block_autoattend'), $course->fullname, get_string('autoattend','block_autoattend'), "", "", true, " ", navmenu($course)); } $currenttab = 'report'; include('tabs.php'); print_simple_box_start('center', '98%', '', 5, 'generalbox', 'notice'); $sort = $sort == 'firstname' ? 'firstname' : 'lastname'; if (isteacher($course->id)) { if(!count_records('autoattend_sessions', 'courseid', $course->id)) { // no session exists for this course redirect($CFG->wwwroot.'/blocks/autoattend/add.php?course='.$course->id); } else { $settings = autoattend_get_settings($course->id); // display group selector echo '
'.helpbutton ('report', get_string('help'), 'block_autoattend', true, true, '', true). '
'; if ($currentgroup = setup_and_print_groups($course, VISIBLEGROUPS, "report.php?course={$course->id}")) { $students = get_group_users($currentgroup, "u.$sort ASC"); } else { $students = get_course_students($course->id, "$sort", "ASC"); } // display date interval selector $rec = get_record_sql("SELECT MIN(sessdate) AS min, MAX(sessdate) AS max FROM {$CFG->prefix}autoattend_sessions WHERE courseid=$course->id", false); $firstdate = $rec->min; $lastdate = $rec->max; $now = time(); 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_autoattend'); $options['weeks'] = get_string('weeks', 'block_autoattend'); $options['months'] = get_string('months', 'block_autoattend'); echo '
'.get_string('display','block_autoattend').': '; // view is all or week or month if (isset($_GET['view'])) { autoattend_set_current_view($course->id, $_GET['view']); } $view = autoattend_get_current_view($course->id); popup_form("report.php?course={$course->id}&sort=$sort&view=", $options, 'viewmenu', $view, ''); print '

'; $out = ''; $weeks = array(); if ($view === 'weeks') { $startdate = mktime(0, 0, 0, $smonth, $sday-$wday+1, $syear); $format = get_string('strftimedm', 'block_autoattend'); for ($i = 1, $monday = $startdate; $monday <= $lastdate; $i++, $monday += ONE_WEEK) { if (count_records_select('autoattend_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'; $monday = $startdate; for ($i=1; $monday<=$lastdate; $i++, $monday=mktime(0, 0, 0, $smonth-1+$i, 1, $syear)) { if (count_records_select('autoattend_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}&current={$weeks[$i]}&sort=$sort\">". strftime($format, $weeks[$i])." / ".$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(); $where = "courseid={$course->id}"; } if ($students and ($course_sess = get_records_select('autoattend_sessions', $where, 'sessdate, starttime 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 = autoattend_get_maxgrade($course->id); $table->head [] = ''; $table->align[] = ''; $table->size [] = '1px'; $table->head [] = $fullnamehead; $table->align[] = 'left'; $table->size [] = ''; $table->wrap [1]= 'nowrap'; foreach($course_sess as $sessdata) { $table->head [] = "id} &sessdate={$sessdata->sessdate}&attsid={$sessdata->id}\">". strftime(get_string('strftimedm', 'block_autoattend'), $sessdata->sessdate).''; $table->align[] = 'center'; $table->size [] = '1px'; } for ($i=0; $i<5; $i++) { $table->align[] = 'center'; $table->size [] = '1px'; } array_push($table->head, get_string('Pacronym', 'block_autoattend'), get_string('Lacronym', 'block_autoattend'), get_string('Eacronym', 'block_autoattend'), get_string('Xacronym', 'block_autoattend'), get_string('Yacronym', 'block_autoattend')); $table->head [] = get_string('grade','block_autoattend').'/'.$maxgrade; $table->align[] = 'right'; $table->size [] = '1px'; $table->head [] = '%'; $table->align[] = 'right'; $table->size [] = '1px'; // $table->head [] = $fullnamehead; $table->align[] = 'left'; $table->size [] = ''; $table->wrap [1]= 'nowrap'; foreach($students as $student) { $table->data[$student->id][] = print_user_picture($student->id, $course->id, $student->picture, 20, true, true); $table->data[$student->id][] = "id} &student={$student->id}\">".fullname($student).''; foreach($course_sess as $sessdata) { if ($att = get_record('autoattend_students', 'attsid', $sessdata->id, 'studentid', $student->id)) { $table->data[$student->id][] = get_string($att->status.'acronym','block_autoattend'); } else { //$table->data[$student->id][] = '-'; $table->data[$student->id][] = get_string('novalue','block_autoattend'); } } $table->data[$student->id][] = autoattend_get_status_num($student->id, $course->id, 'P'); $table->data[$student->id][] = autoattend_get_status_num($student->id, $course->id, 'L'); $table->data[$student->id][] = autoattend_get_status_num($student->id, $course->id, 'E'); $table->data[$student->id][] = autoattend_get_status_num($student->id, $course->id, 'X'); $table->data[$student->id][] = autoattend_get_status_num($student->id, $course->id, 'Y'); $table->data[$student->id][] = autoattend_get_grade($student->id,$course->id); $table->data[$student->id][] = sprintf("%0.1f", autoattend_get_percent($student->id,$course->id)).'%'; $table->data[$student->id][] = "id} &student={$student->id}\">".fullname($student).''; } echo '
'; print_table($table); } else { print_heading(get_string('nothingtodisplay'), 'center'); } echo '

'; echo '  '.get_string('status','block_autoattend').':
'; foreach($settings as $set) { $status = get_string($set->status.'acronym', 'block_autoattend'); $desc = get_string($set->status.'acronymfull', 'block_autoattend'); echo '    '.$status.' - '.$desc.'
'; } } } print_simple_box_end(); print_footer($course); ?>