From 520d6a2a5d4b92f7362e2feba5c8c054ea7c7603 Mon Sep 17 00:00:00 2001 From: Mark Nelson Date: Mon, 9 Jul 2018 23:45:19 +0800 Subject: [PATCH] #207 No need to use a table/list when displaying only one issue --- classes/output/mobile.php | 9 ++++--- templates/mobile_view_activity_page.mustache | 28 +++++++------------- view.php | 25 ++++++----------- 3 files changed, 24 insertions(+), 38 deletions(-) diff --git a/classes/output/mobile.php b/classes/output/mobile.php index 1e36d63..f8abacc 100644 --- a/classes/output/mobile.php +++ b/classes/output/mobile.php @@ -60,7 +60,11 @@ class mobile { $certificate->introformat, $context->id, 'mod_customcert', 'intro'); // Get any issues this person may have. - $issues = $DB->get_records('customcert_issues', ['userid' => $USER->id, 'customcertid' => $certificate->id]); + $issue = false; + if ($issues = $DB->get_records('customcert_issues', ['userid' => $USER->id, 'customcertid' => $certificate->id], + 'timecreated DESC')) { + $issue = reset($issues); + } $candownload = true; $canmanage = has_capability('mod/customcert:manage', $context); @@ -101,8 +105,7 @@ class mobile { $data = [ 'certificate' => $certificate, 'cmid' => $cm->id, - 'hasissues' => !empty($issues), - 'issues' => array_values($issues), + 'issue' => $issue, 'showgroups' => !empty($groups), 'groups' => array_values($groups), 'canmanage' => $canmanage, diff --git a/templates/mobile_view_activity_page.mustache b/templates/mobile_view_activity_page.mustache index 1d389e2..8488f51 100644 --- a/templates/mobile_view_activity_page.mustache +++ b/templates/mobile_view_activity_page.mustache @@ -50,12 +50,9 @@ "requiredtime": "60" }, "cmid": "25", - "hasissues": "true", - "issues": [ - { - "timecreated": "1528370177" - } - ], + "issue": { + "timecreated": "1528370177" + }, "showgroups": "true", "groups": [ { @@ -84,20 +81,15 @@ {{=<% %>=}}
- <%#hasissues%> + <%#issue%> <%^canmanage%> - - - {{ 'plugin.mod_customcert.receiveddate' | translate }} - - <%#issues%> - - {{ <% timecreated %> | coreToLocaleString }} - - <%/issues%> - + + {{ 'plugin.mod_customcert.receiveddate' | translate }} +
+
{{ <% timecreated %> | coreToLocaleString }}
+
<%/canmanage%> - <%/hasissues%> + <%/issue%> <%#candownload%>