From 30c1814ff8c09ace9a18d557b0186905dd386944 Mon Sep 17 00:00:00 2001 From: Dan Marsden Date: Wed, 31 Jan 2018 11:18:11 +1300 Subject: [PATCH] Split out graded and ungraded sessions on students all courses list. --- lang/en/attendance.php | 5 +++-- renderer.php | 37 +++++++++++++++++++++++++------------ version.php | 2 +- 3 files changed, 29 insertions(+), 15 deletions(-) diff --git a/lang/en/attendance.php b/lang/en/attendance.php index acb344a..5853490 100644 --- a/lang/en/attendance.php +++ b/lang/en/attendance.php @@ -74,7 +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['averageattendancegraded'] = 'Average attendance'; $string['calclose'] = 'Close'; $string['caleventcreated'] = 'Calendar event for session successfully created'; $string['caleventdeleted'] = 'Calendar event for session successfully deleted'; @@ -482,7 +482,8 @@ $string['to'] = 'to:'; $string['triggered'] = 'First notified'; $string['tuseremail'] = 'Email'; $string['tusername'] = 'Full name'; -$string['ungraded'] = '(ungraded)'; +$string['graded'] = 'Graded sessions'; +$string['ungraded'] = 'Ungraded sessions'; $string['unknowngroup'] = 'Unknown group'; $string['update'] = 'Update'; $string['usedefaultsubnet'] = 'Use default'; diff --git a/renderer.php b/renderer.php index 90f1c50..446e37d 100644 --- a/renderer.php +++ b/renderer.php @@ -950,7 +950,6 @@ class mod_attendance_renderer extends plugin_renderer_base { $o .= construct_user_data_stat($userdata->summary->get_all_sessions_summary_for($userdata->user->id), $userdata->pageparams->view); } else { - $prevcid = 0; $table = new html_table(); $table->head = array(get_string('course'), get_string('pluginname', 'mod_attendance'), @@ -960,6 +959,8 @@ class mod_attendance_renderer extends plugin_renderer_base { $table->align = array('left', 'left', 'center', 'center', 'center'); $table->colclasses = array('colcourse', 'colatt', 'colsessionscompleted', 'colpointssessionscompleted', 'colpercentagesessionscompleted'); + + $table2 = clone($table); // Duplicate table for ungraded sessions. $totalattendance = 0; $totalpercentage = 0; foreach ($userdata->coursesatts as $ca) { @@ -969,12 +970,7 @@ 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)); - $attendanceurl = html_writer::link($attendanceurl, $ca->attname); - if (empty($ca->attgrade)) { - $attendanceurl .= " ". html_writer::span(get_string('ungraded', 'mod_attendance'), - 'ungraded'); - } - $row->cells[] = $attendanceurl; + $row->cells[] = html_writer::link($attendanceurl, $ca->attname); $usersummary = new stdClass(); if (isset($userdata->summary[$ca->attid])) { $usersummary = $userdata->summary[$ca->attid]->get_all_sessions_summary_for($userdata->user->id); @@ -989,10 +985,14 @@ class mod_attendance_renderer extends plugin_renderer_base { } } - $table->data[] = $row; - if ($usersummary->numtakensessions > 0 && !empty($ca->attgrade)) { - $totalattendance++; - $totalpercentage = $totalpercentage + format_float($usersummary->takensessionspercentage * 100); + if (empty($ca->attgrade)) { + $table2->data[] = $row; + } else { + $table->data[] = $row; + if ($usersummary->numtakensessions > 0) { + $totalattendance++; + $totalpercentage = $totalpercentage + format_float($usersummary->takensessionspercentage * 100); + } } } $row = new html_table_row(); @@ -1011,7 +1011,20 @@ class mod_attendance_renderer extends plugin_renderer_base { $row->cells = array($col, $col2); $table->data[] = $row; - $o .= html_writer::table($table); + if (!empty($table2->data) && !empty($table->data)) { + // Print graded header if both tables are being shown. + $o .= html_writer::div("

".get_string('graded', 'mod_attendance')."

"); + } + if (!empty($table->data)) { + // don't bother printing the table if no sessions are being shown. + $o .= html_writer::table($table); + } + + if (!empty($table2->data)) { + // Don't print this if it doesn't contain any data. + $o .= html_writer::div("

".get_string('ungraded', 'mod_attendance')."

"); + $o .= html_writer::table($table2); + } } return $o; diff --git a/version.php b/version.php index 831f13a..7f2cab9 100644 --- a/version.php +++ b/version.php @@ -23,7 +23,7 @@ */ defined('MOODLE_INTERNAL') || die(); -$plugin->version = 2017120801; +$plugin->version = 2017120802; $plugin->requires = 2017102700; // Requires 3.4 $plugin->release = '3.4.2'; $plugin->maturity = MATURITY_ALPHA;