Browse Source

Add summary report (#66)

MOODLE_31_STABLE
Antonio Carlos Mariani 9 years ago
parent
commit
8d6fc482af
  1. 4
      classes/page_with_filter_controls.php
  2. 1
      lang/en/attendance.php
  3. 1
      locallib.php
  4. 10
      renderables.php
  5. 47
      renderer.php
  6. 14
      styles.css

4
classes/page_with_filter_controls.php

@ -124,6 +124,10 @@ class mod_attendance_page_with_filter_controls {
$this->startdate = 0;
$this->enddate = 0;
break;
case ATT_VIEW_SUMMARY:
$this->startdate = 1;
$this->enddate = 1;
break;
}
}

1
lang/en/attendance.php

@ -260,6 +260,7 @@ $string['strftimedmyw'] = '%d.%m.%y (%a)';
$string['strftimehm'] = '%H:%M'; // Line added to allow display of time.
$string['strftimeshortdate'] = '%d.%m.%Y';
$string['studentid'] = 'Student ID';
$string['summary'] = 'Summary';
$string['takeattendance'] = 'Take attendance';
$string['takensessions'] = 'Taken sessions';
$string['tempaddform'] = 'Add temporary user';

1
locallib.php

@ -33,6 +33,7 @@ define('ATT_VIEW_MONTHS', 3);
define('ATT_VIEW_ALLPAST', 4);
define('ATT_VIEW_ALL', 5);
define('ATT_VIEW_NOTPRESENT', 6);
define('ATT_VIEW_SUMMARY', 7);
define('ATT_SORT_LASTNAME', 1);
define('ATT_SORT_FIRSTNAME', 2);

10
renderables.php

@ -128,7 +128,7 @@ class attendance_filter_controls implements renderable {
private $urlpath;
private $urlparams;
private $att;
public $att;
public function __construct(mod_attendance_structure $att, $report = false) {
global $PAGE;
@ -138,7 +138,7 @@ class attendance_filter_controls implements renderable {
$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;
@ -440,7 +440,11 @@ class attendance_report_data implements renderable {
$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);

47
renderer.php

@ -176,12 +176,15 @@ class mod_attendance_renderer extends plugin_renderer_base {
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) {
@ -852,6 +855,9 @@ class mod_attendance_renderer extends plugin_renderer_base {
$table = new html_table();
$table->attributes['class'] = 'generaltable attwidth';
if ($reportdata->pageparams->view == ATT_VIEW_SUMMARY) {
$table->attributes['class'] .= ' summaryreport';
}
// User picture.
$table->head[] = '';
@ -903,6 +909,28 @@ class mod_attendance_renderer extends plugin_renderer_base {
$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'));
@ -918,12 +946,27 @@ class mod_attendance_renderer extends plugin_renderer_base {
$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'));

14
styles.css

@ -17,7 +17,7 @@
}
.path-mod-attendance .attfiltercontrols {
margin-bottom: 10px;
margin-bottom: 10px !important;
margin-right:auto;
margin-left:auto;
}
@ -165,3 +165,15 @@
.path-mod-attendance .attendancestatus-A {
color: red;
}
.path-mod-attendance .summaryreport .c5 {
background-color: #EAEAEA;
}
.path-mod-attendance .summaryreport .c6 {
background-color: #EAEAEA;
}
.path-mod-attendance .summaryreport .c7 {
background-color: #EAEAEA;
}

Loading…
Cancel
Save