diff --git a/classes/output/mobile.php b/classes/output/mobile.php index 5e480c7..e4d3eda 100644 --- a/classes/output/mobile.php +++ b/classes/output/mobile.php @@ -44,9 +44,10 @@ class mobile { global $OUTPUT, $DB, $USER; $args = (object) $args; + $versionname = $args->appversioncode >= 3950 ? 'latest' : 'ionic3'; $cmid = $args->cmid; - $groupid = empty($args->group) ? 0 : $args->group; // By default, group 0. + $groupid = empty($args->group) ? 0 : (int) $args->group; // By default, group 0. // Capabilities check. $cm = get_coursemodule_from_id('customcert', $cmid); @@ -114,6 +115,7 @@ class mobile { 'showreport' => $showreport, 'hasrecipients' => !empty($recipients), 'recipients' => array_values($recipients), + 'numrecipients' => count($recipients), 'currenttimestamp' => time() ]; @@ -121,11 +123,13 @@ class mobile { 'templates' => [ [ 'id' => 'main', - 'html' => $OUTPUT->render_from_template('mod_customcert/mobile_view_activity_page', $data), + 'html' => $OUTPUT->render_from_template("mod_customcert/mobile_view_activity_page_$versionname", $data), ], ], 'javascript' => '', - 'otherdata' => '' + 'otherdata' => [ + 'group' => $groupid, + ] ]; } diff --git a/templates/mobile_view_activity_page.mustache b/templates/mobile_view_activity_page_ionic3.mustache similarity index 100% rename from templates/mobile_view_activity_page.mustache rename to templates/mobile_view_activity_page_ionic3.mustache diff --git a/templates/mobile_view_activity_page_latest.mustache b/templates/mobile_view_activity_page_latest.mustache new file mode 100644 index 0000000..6018c2e --- /dev/null +++ b/templates/mobile_view_activity_page_latest.mustache @@ -0,0 +1,169 @@ +{{! + This file is part of Moodle - http://moodle.org/ + + Moodle is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Moodle is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Moodle. If not, see . +}} +{{! + @template mod_customcert/mobile_view_activity_page + + The main page to view the custom certificate activity + + Classes required for JS: + * None + + Data attibutes required for JS: + * All data attributes are required + + Context variables required for this template: + * certificate + * cmid + * hasissues + * issues + * showgroups + * groups + * canmanage + * requiredtimemet + * hasrecipients + * recipients + * fileurl + * showreport + * currenttimestamp + + Example context (json): + { + "certificate": { + "id": "1", + "course": "2", + "name": "A rad certificate name!", + "intro": "A certificate", + "requiredtime": "60" + }, + "cmid": "25", + "issue": { + "timecreated": "1528370177" + }, + "showgroups": "true", + "groups": [ + { + "id": "2", + "selected": "false", + "name": "Group A" + } + ], + "canmanage": "true", + "requiredtimemet": "true", + "fileurl": "http://yoursite.com/mod/customcert/mobile/pluginfile.php?id=4", + "showreport": "true", + "hasrecipients": "true", + "recipients": [ + { + "id": "2", + "issueid": "3", + "displayname": "Michaelangelo (Mickey)", + "fileurl": "http://yoursite.com/mod/customcert/mobile/pluginfile.php?id=4", + "timecreated": "1528370177" + } + ], + "currenttimestamp": "1528370177" + } +}} +{{=<% %>=}} + + +<%^canmanage%> + <%#requiredtimemet%> + + + {{ 'plugin.mod_customcert.receiveddate' | translate }} +
+
+ <%#issue%> + {{ <% timecreated %> | coreToLocaleString }} + <%/issue%> + <%^issue%> + {{ 'plugin.mod_customcert.notissued' | translate }} + <%/issue%> +
+
+
+ + + +
+
+ <%/requiredtimemet%> + <%^requiredtimemet%> + + +

{{ 'plugin.mod_customcert.requiredtimenotmet' | translate: {$a: { requiredtime: <% certificate.requiredtime %>} } }}

+
+
+ <%/requiredtimemet%> +<%/canmanage%> +<%#canmanage%> + + + {{ 'plugin.mod_customcert.getcustomcert' | translate }} + +<%/canmanage%> +<%#showreport%> + + + {{ 'plugin.mod_customcert.listofissues' | translate: { $a: <% numrecipients %> } }} + + + <%#showgroups%> + + {{ 'plugin.mod_customcert.selectagroup' | translate }} + + <%#groups%> + <% name %> + <%/groups%> + + + <%/showgroups%> + <%#hasrecipients%> + <%#recipients%> + + + <% displayname %> +
+
{{ <% timecreated %> | coreToLocaleString }}
+
+
+ + + + <%#canmanage%> + + + + <%/canmanage%> +
+
+ <%/recipients%> + <%/hasrecipients%> + <%^hasrecipients%> + + + {{ 'plugin.mod_customcert.nothingtodisplay' | translate }} + + + <%/hasrecipients%> +<%/showreport%> +