From 0e1e4491096b846c2a74f0a416169dd6b21fea29 Mon Sep 17 00:00:00 2001 From: Dan Marsden Date: Thu, 18 Jan 2018 12:01:59 +1300 Subject: [PATCH] Exclude ungraded attendance activities from student all courses average. --- lang/en/attendance.php | 2 ++ renderer.php | 24 +++++++++++++++++++----- styles.css | 4 ++++ 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/lang/en/attendance.php b/lang/en/attendance.php index f9e0370..acb344a 100644 --- a/lang/en/attendance.php +++ b/lang/en/attendance.php @@ -74,6 +74,7 @@ If "Set unmarked at end of session" any students who have not marked their atten $string['automarktask'] = 'Check for attendance sessions that require auto marking'; $string['autorecorded'] = 'system auto recorded'; $string['averageattendance'] = 'Average attendance'; +$string['averageattendancegraded'] = 'Average attendance excluding ungraded'; $string['calclose'] = 'Close'; $string['caleventcreated'] = 'Calendar event for session successfully created'; $string['caleventdeleted'] = 'Calendar event for session successfully deleted'; @@ -481,6 +482,7 @@ $string['to'] = 'to:'; $string['triggered'] = 'First notified'; $string['tuseremail'] = 'Email'; $string['tusername'] = 'Full name'; +$string['ungraded'] = '(ungraded)'; $string['unknowngroup'] = 'Unknown group'; $string['update'] = 'Update'; $string['usedefaultsubnet'] = 'Use default'; diff --git a/renderer.php b/renderer.php index cd6f845..a62286f 100644 --- a/renderer.php +++ b/renderer.php @@ -943,7 +943,12 @@ class mod_attendance_renderer extends plugin_renderer_base { $attendanceurl = new moodle_url('/mod/attendance/view.php', array('id' => $ca->cmid, 'studentid' => $userdata->user->id, 'view' => ATT_VIEW_ALL)); - $row->cells[] = html_writer::link($attendanceurl, $ca->attname); + $attendanceurl = html_writer::link($attendanceurl, $ca->attname); + if (empty($ca->attgrade)) { + $attendanceurl .= " ". html_writer::span(get_string('ungraded', 'mod_attendance'), + 'ungraded'); + } + $row->cells[] = $attendanceurl; $usersummary = new stdClass(); if (isset($userdata->summary[$ca->attid])) { $usersummary = $userdata->summary[$ca->attid]->get_all_sessions_summary_for($userdata->user->id); @@ -959,16 +964,25 @@ class mod_attendance_renderer extends plugin_renderer_base { } $table->data[] = $row; - if ($usersummary->numtakensessions > 0) { + if ($usersummary->numtakensessions > 0 && !empty($ca->attgrade)) { $totalattendance++; $totalpercentage = $totalpercentage + format_float($usersummary->takensessionspercentage * 100); } } $row = new html_table_row(); - $average = format_float($totalpercentage / $totalattendance).'%'; - $col = new html_table_cell(get_string('averageattendance', 'mod_attendance')); + if (empty($totalattendance)) { + $average = '-'; + } else { + $average = format_float($totalpercentage / $totalattendance).'%'; + } + + $col = new html_table_cell(get_string('averageattendancegraded', 'mod_attendance')); $col->attributes['class'] = 'averageattendance'; - $row->cells = array($col, '', '', '', $average); + $col->colspan = 4; + + $col2 = new html_table_cell($average); + $col2->style = 'text-align: center'; + $row->cells = array($col, $col2); $table->data[] = $row; $o .= html_writer::table($table); diff --git a/styles.css b/styles.css index 5aa997a..979f9fc 100644 --- a/styles.css +++ b/styles.css @@ -190,6 +190,10 @@ font-size: x-large; text-align: center; } +.path-mod-attendance .ungraded { + font-size: smaller; + font-style: italic; +} #page-mod-attendance-sessions .statusgroup .statusdesc { margin-right: 12px; }