libdir.'/blocklib.php'); require_once('lib.php'); // define('DEFAULT_PAGE_SIZE', 15); define('DEFAULT_ROW_SIZE', 15); $courseid = required_param('course', PARAM_INTEGER); // Course ID $classid = optional_param('class', 0, PARAM_INTEGER); // Class ID $viewmode = optional_param('viewmode', 'all', PARAM_ALPHA); // View mode ('all', 'months', 'weeks') $current = optional_param('current', 0, PARAM_INTEGER); // shown date or time $sort = optional_param('sort', 'lastname', PARAM_ALPHA); $refresh = optional_param('refresh', '0', PARAM_INTEGER); // refresh sessions $action = optional_param('action', '', PARAM_ALPHA); if (($formdata = data_submitted()) and !confirm_sesskey()) { print_error('invalidsesskey'); } $sort = ($sort=='firstname' ? 'firstname' : 'lastname'); $urlparams['course'] = $courseid; if ($classid) $urlparams['class'] = $classid; if ($viewmode) $urlparams['viewmode'] = $viewmode; if ($current) $urlparams['current'] = $current; if ($sort) $urlparams['sort'] = $sort; if ($action) $urlparams['action'] = $action; if ($classid<0) $classid = 0; $PAGE->set_url('/blocks/autoattend/report.php', $urlparams); $wwwBlock = $CFG->wwwroot.'/blocks/autoattend'; $wwwMyURL = $wwwBlock.'/report.php'; $course = $DB->get_record('course', array('id'=>$courseid)); if (!$course) { print_error('courseidwrong', 'block_autoattend'); } require_login($course->id); $user = $DB->get_record('user', array('id'=>$USER->id)); if (!$user) { print_error('nosuchuser', 'block_autoattend'); } // add info to log //add_to_log($course->id, 'autoattend', 'view report', $wwwMyURL); // $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); // DownLoad (Excel or Text Format) if ($isteacher or $isassist) { $classes = autoattend_get_session_classes($course->id); if($action=='excel') { autoattend_download('xls', $course->id, $classes, $classid, $viewmode, $current); die(); } else if($action=='text') { autoattend_download('txt', $course->id, $classes, $classid, $viewmode, $current); die(); } } ///////////////////////////////////////////////////// if ($refresh) { autoattend_update_sessions($courseid); } // Print header if ($course->category) { $title = $course->shortname.': '.get_string('autoattend','block_autoattend').' '.get_string('report','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 = 'report'; include('tabs.php'); ////////////////////////////////////////////////////////////////////////////////////////////// // function report_make_header(&$table, $course_sess, $classes, $url_options) { global $CFG, $TIME_OFFSET; $wwwBlock = $CFG->wwwroot.'/blocks/autoattend'; $wwwMyURL = $wwwBlock.'/report.php'; $firstname = ''.get_string('firstname').''; $lastname = '' .get_string('lastname').''; if ($CFG->fullnamedisplay == 'lastname firstname') { // for better view (dlnsk) $fullnamehead = "$lastname / $firstname"; } else { $fullnamehead = "$firstname / $lastname"; } unset($table->head); unset($table->align); unset($table->size); unset($table->wrap); // Header $table->head [] = ''; $table->align[] = ''; $table->size [] = '20px'; $table->wrap [] = 'nowrap'; $table->head [] = $fullnamehead; $table->align[] = 'left'; $table->size [] = '140px'; $table->wrap [] = 'nowrap'; if ($classes) { $table->head [] = get_string('classname','block_autoattend'); $table->align[] = 'center'; $table->size [] = '80px'; $table->wrap [] = 'nowrap'; } $table->head [] = get_string('attendgradeshort','block_autoattend'); $table->align[] = 'center'; $table->size [] = '20px'; $table->wrap [] = 'nowrap'; $table->head [] = '%'; $table->align[] = 'center'; $table->size [] = '40px'; $table->wrap [] = 'nowrap'; for ($i=0; $i<5; $i++) { $table->align[] = 'center'; $table->size [] = '20px'; $table->wrap [] = 'nowrap'; } 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')); if (!empty($course_sess)) { $i = 0; $j = 0; foreach($course_sess as $sessdata) { $i++; $j++; $table->head [] = ''. strftime(get_string('strftimedmshort','block_autoattend'), $sessdata->sessdate+$TIME_OFFSET).''; $table->align[] = 'center'; $table->size [] = '40px'; $table->wrap [] = 'nowrap'; if ($i%DEFAULT_ROW_SIZE==0) { $j++; $table->head [] = $fullnamehead; $table->align[] = 'left'; $table->size [] = '180px'; $table->wrap [] = 'nowrap'; } } } return; } // function report_show_table($course, $students, $course_sess, $classes, $url_options) { global $DB, $OUTPUT, $wwwBlock; $table = new html_table(); $i = 0; foreach($students as $student) { $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.''; $user_summary = autoattend_get_user_summary($student->id, $course->id); if ($classes) $table->data[$student->id][] = $user_summary['classname']; $table->data[$student->id][] = $user_summary['grade']; $table->data[$student->id][] = $user_summary['percent'].'%'; $table->data[$student->id][] = $user_summary['P']; $table->data[$student->id][] = $user_summary['L']; $table->data[$student->id][] = $user_summary['E']; $table->data[$student->id][] = $user_summary['X']; $table->data[$student->id][] = $user_summary['Y']; $j = 0; foreach($course_sess as $sessdata) { $j++; $att = $DB->get_record('autoattend_students', array('attsid'=>$sessdata->id, 'studentid'=>$student->id)); if ($att and ($sessdata->classid==$student->classid or $sessdata->classid==0)) { $table->data[$student->id][] = get_string($att->status.'acronym','block_autoattend'); } else { $table->data[$student->id][] = get_string('novalue','block_autoattend'); } if ($j%DEFAULT_ROW_SIZE==0) { $table->data[$student->id][] = ''.$student->fullname.''; } } // if ($i%DEFAULT_PAGE_SIZE==0) { report_make_header($table, $course_sess, $classes, $url_options); echo '