From 692353f697d17781f39fce8319ac41f0d15f32d3 Mon Sep 17 00:00:00 2001 From: Dan Marsden Date: Mon, 4 Apr 2016 19:05:53 +1200 Subject: [PATCH] Check group data exists before using group name. --- export.php | 6 +++++- renderer.php | 7 ++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/export.php b/export.php index de8443b..e270487 100644 --- a/export.php +++ b/export.php @@ -110,7 +110,11 @@ if ($formdata = $mform->get_data()) { foreach ($reportdata->sessions as $sess) { $text = userdate($sess->sessdate, get_string('strftimedmyhm', 'attendance')); $text .= ' '; - $text .= $sess->groupid ? $reportdata->groups[$sess->groupid]->name : get_string('commonsession', 'attendance'); + if (!empty($sess->groupid) && empty($reportdata->groups[$sess->groupid])) { + $text .= get_string('deletedgroup', 'attendance'); + } else { + $text .= $sess->groupid ? $reportdata->groups[$sess->groupid]->name : get_string('commonsession', 'attendance'); + } $data->tabhead[] = $text; if (isset($formdata->includeremarks)) { $data->tabhead[] = ''; // Space for the remarks. diff --git a/renderer.php b/renderer.php index 38f9143..fe86450 100644 --- a/renderer.php +++ b/renderer.php @@ -867,7 +867,12 @@ class mod_attendance_renderer extends plugin_renderer_base { } $sesstext .= html_writer::empty_tag('br'); if ($sess->groupid) { - $sesstext .= get_string('group') . ': ' . $reportdata->groups[$sess->groupid]->name; + if (empty($reportdata->groups[$sess->groupid])) { + $sesstext .= get_string('deletedgroup', 'attendance'); + } else { + $sesstext .= get_string('group') . ': ' . $reportdata->groups[$sess->groupid]->name; + } + } else { $sesstext .= get_string('commonsession', 'attendance'); }