private $urlpath;
private $urlparams;
- private $att;
+ public $att;
public function __construct(mod_attendance_structure $att, $report = false) {
global $PAGE;
$this->cm = $att->cm;
// This is a report control only if $reports is true and the attendance block can be graded.
- $this->reportcontrol = $report && ($att->grade > 0);
+ $this->reportcontrol = $report;
$this->curdate = $att->pageparams->curdate;
$this->statuses = $att->get_statuses(true, true);
$this->allstatuses = $att->get_statuses(false, true);
- $this->summary = new mod_attendance_summary($att->id, array_keys($this->users), $att->pageparams->startdate, $att->pageparams->enddate);
+ if ($att->pageparams->view == ATT_VIEW_SUMMARY) {
+ $this->summary = new mod_attendance_summary($att->id);
+ } else {
+ $this->summary = new mod_attendance_summary($att->id, array_keys($this->users), $att->pageparams->startdate, $att->pageparams->enddate);
+ }
foreach ($this->users as $key => $user) {
$usersummary = $this->summary->get_taken_sessions_summary_for($user->id);
protected function render_view_controls(attendance_filter_controls $fcontrols) {
$views[ATT_VIEW_ALL] = get_string('all', 'attendance');
$views[ATT_VIEW_ALLPAST] = get_string('allpast', 'attendance');
- if ($fcontrols->reportcontrol) {
+ if ($fcontrols->reportcontrol && $fcontrols->att->grade > 0) {
$views[ATT_VIEW_NOTPRESENT] = get_string('lowgrade', 'attendance');
}
$views[ATT_VIEW_MONTHS] = get_string('months', 'attendance');
$views[ATT_VIEW_WEEKS] = get_string('weeks', 'attendance');
$views[ATT_VIEW_DAYS] = get_string('days', 'attendance');
+ if ($fcontrols->reportcontrol) {
+ $views[ATT_VIEW_SUMMARY] = get_string('summary', 'attendance');
+ }
$viewcontrols = '';
foreach ($views as $key => $sview) {
if ($key != $fcontrols->pageparams->view) {
$table = new html_table();
$table->attributes['class'] = 'generaltable attwidth';
+ if ($reportdata->pageparams->view == ATT_VIEW_SUMMARY) {
+ $table->attributes['class'] .= ' summaryreport';
+ }
// User picture.
$table->head[] = '';
$table->align[] = 'center';
$table->size[] = '1px';
+ if ($reportdata->pageparams->view == ATT_VIEW_SUMMARY) {
+ $table->head[] = get_string('sessionstotal', 'attendance');
+ $table->align[] = 'center';
+ $table->size[] = '1px';
+
+ $table->head[] = get_string('pointsallsessions', 'attendance');
+ $table->align[] = 'center';
+ $table->size[] = '1px';
+
+ $table->head[] = get_string('percentageallsessions', 'attendance');
+ $table->align[] = 'center';
+ $table->size[] = '1px';
+
+ $table->head[] = get_string('maxpossiblepoints', 'attendance');
+ $table->align[] = 'center';
+ $table->size[] = '1px';
+
+ $table->head[] = get_string('maxpossiblepercentage', 'attendance');
+ $table->align[] = 'center';
+ $table->size[] = '1px';
+ }
+
if ($bulkmessagecapability) { // Display the table header for bulk messaging.
// The checkbox must have an id of cb_selector so that the JavaScript will pick it up.
$table->head[] = html_writer::checkbox('cb_selector', 0, false, '', array('id' => 'cb_selector'));
$cellsgenerator = new user_sessions_cells_html_generator($reportdata, $user);
$row->cells = array_merge($row->cells, $cellsgenerator->get_cells(true));
- $usersummary = $reportdata->summary->get_taken_sessions_summary_for($user->id);
+ if ($reportdata->pageparams->view == ATT_VIEW_SUMMARY) {
+ $usersummary = $reportdata->summary->get_all_sessions_summary_for($user->id);
+ } else {
+ $usersummary = $reportdata->summary->get_taken_sessions_summary_for($user->id);
+ }
$row->cells[] = $usersummary->numtakensessions;
$row->cells[] = attendance_format_float($usersummary->takensessionspoints) . ' / ' .
attendance_format_float($usersummary->takensessionsmaxpoints);
$row->cells[] = attendance_format_float($usersummary->takensessionspercentage * 100, false) . '%';
+ if ($reportdata->pageparams->view == ATT_VIEW_SUMMARY) {
+ $row->cells[] = $usersummary->numallsessions;
+ $row->cells[] = attendance_format_float($usersummary->takensessionspoints) . ' / ' .
+ attendance_format_float($usersummary->allsessionsmaxpoints);
+ $row->cells[] = attendance_format_float($usersummary->allsessionspercentage * 100, false) . '%';
+
+ $row->cells[] = attendance_format_float($usersummary->maxpossiblepoints) . ' / ' .
+ attendance_format_float($usersummary->allsessionsmaxpoints);
+ $row->cells[] = attendance_format_float($usersummary->maxpossiblepercentage * 100, false) . '%';
+ }
+
if ($bulkmessagecapability) { // Create the checkbox for bulk messaging.
$row->cells[] = html_writer::checkbox('user'.$user->id, 'on', false, '',
array('class' => 'attendancesesscheckbox'));