From 4e147131c7979699e9530d8cda2fbe212245f7c3 Mon Sep 17 00:00:00 2001 From: Dan Marsden Date: Fri, 2 Jul 2021 19:12:48 +1200 Subject: [PATCH] Improve error checking when a status item was deleted. --- lang/en/attendance.php | 1 + renderhelpers.php | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lang/en/attendance.php b/lang/en/attendance.php index 9ee7e19..80debd0 100644 --- a/lang/en/attendance.php +++ b/lang/en/attendance.php @@ -599,6 +599,7 @@ $string['tuseremail'] = 'Email'; $string['tusername'] = 'Full name'; $string['ungraded'] = 'Ungraded sessions'; $string['unknowngroup'] = 'Unknown group'; +$string['unknownstatus'] = 'Unknown status id: {$a}'; $string['update'] = 'Update'; $string['uploadattendance'] = 'Upload attendance by CSV'; $string['usedefaultsubnet'] = 'Use default'; diff --git a/renderhelpers.php b/renderhelpers.php index b1478b1..c5754e1 100644 --- a/renderhelpers.php +++ b/renderhelpers.php @@ -68,7 +68,12 @@ class user_sessions_cells_generator { $this->construct_existing_status_cell($this->reportdata->statuses[$statusid]->acronym . " ({$points}/{$maxpoints})"); } else { - $this->construct_hidden_status_cell($this->reportdata->allstatuses[$statusid]->acronym); + if (!empty($this->reportdata->allstatuses[$statusid] && isset($this->reportdata->allstatuses[$statusid]->acronym))) { + $statusac = $this->reportdata->allstatuses[$statusid]->acronym; + } else { + $statusac = get_string('unknownstatus', 'mod_attendance', $statusid); + } + $this->construct_hidden_status_cell($statusac); } if ($remarks) { $this->construct_remarks_cell($this->reportdata->sessionslog[$this->user->id][$sess->id]->remarks);