2 // This file is part of Moodle - http://moodle.org/
4 // Moodle is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
9 // Moodle is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
20 * @package mod_attendance
21 * @copyright 2011 Artem Andreev <andreev.artem@gmail.com>
22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
25 require_once(dirname(__FILE__
).'/../../config.php');
26 require_once(dirname(__FILE__
).'/locallib.php');
28 $pageparams = new mod_attendance_report_page_params();
30 $id = required_param('id', PARAM_INT
);
31 $from = optional_param('from', null
, PARAM_ACTION
);
32 $pageparams->view
= optional_param('view', null
, PARAM_INT
);
33 $pageparams->curdate
= optional_param('curdate', null
, PARAM_INT
);
34 $pageparams->group
= optional_param('group', null
, PARAM_INT
);
35 $pageparams->sort
= optional_param('sort', ATT_SORT_DEFAULT
, PARAM_INT
);
36 $pageparams->page
= optional_param('page', 1, PARAM_INT
);
37 $pageparams->perpage
= get_config('attendance', 'resultsperpage');
39 $cm = get_coursemodule_from_id('attendance', $id, 0, false
, MUST_EXIST
);
40 $course = $DB->get_record('course', array('id' => $cm->course
), '*', MUST_EXIST
);
41 $attrecord = $DB->get_record('attendance', array('id' => $cm->instance
), '*', MUST_EXIST
);
43 require_login($course, true
, $cm);
45 $context = context_module
::instance($cm->id
);
46 require_capability('mod/attendance:viewreports', $context);
48 $pageparams->init($cm);
49 $pageparams->showextrauserdetails
= optional_param('showextrauserdetails', $attrecord->showextrauserdetails
, PARAM_INT
);
50 $pageparams->showsessiondetails
= optional_param('showsessiondetails', $attrecord->showsessiondetails
, PARAM_INT
);
51 $pageparams->sessiondetailspos
= optional_param('sessiondetailspos', $attrecord->sessiondetailspos
, PARAM_TEXT
);
53 $att = new mod_attendance_structure($attrecord, $cm, $course, $context, $pageparams);
55 $PAGE->set_url($att->url_report());
56 $PAGE->set_pagelayout('report');
57 $PAGE->set_title($course->shortname
. ": ".$att->name
.' - '.get_string('report', 'attendance'));
58 $PAGE->set_heading($course->fullname
);
59 $PAGE->set_cacheable(true
);
60 $PAGE->navbar
->add(get_string('report', 'attendance'));
62 $output = $PAGE->get_renderer('mod_attendance');
63 $tabs = new attendance_tabs($att, attendance_tabs
::TAB_REPORT
);
64 $filtercontrols = new attendance_filter_controls($att, true
);
65 $reportdata = new attendance_report_data($att);
67 // Trigger a report viewed event.
68 $event = \mod_attendance\event
\report_viewed
::create(array(
69 'objectid' => $att->id
,
70 'context' => $PAGE->context
,
73 $event->add_record_snapshot('course_modules', $cm);
74 $event->add_record_snapshot('attendance', $attrecord);
77 $title = get_string('attendanceforthecourse', 'attendance').' :: ' .format_string($course->fullname
);
78 $header = new mod_attendance_header($att, $title);
80 // Output starts here.
81 echo $output->header();
82 echo $output->render($header);
83 echo $output->render($tabs);
84 echo $output->render($filtercontrols);
85 echo $output->render($reportdata);
86 echo $output->footer();