#207 Changed download button between managers and non-managers on mobile

Also minor changes to 'notissued' string and fixed reference to
non-existent string 'notissuedyet'.
This commit is contained in:
Mark Nelson 2018-07-10 14:23:27 +08:00
parent f3cff401b5
commit 2500fada80
5 changed files with 41 additions and 22 deletions

View file

@ -66,16 +66,16 @@ class mobile {
$issue = reset($issues); $issue = reset($issues);
} }
$candownload = true; $requiredtimemet = true;
$canmanage = has_capability('mod/customcert:manage', $context); $canmanage = has_capability('mod/customcert:manage', $context);
if ($certificate->requiredtime && !$canmanage) { if ($certificate->requiredtime && !$canmanage) {
if (\mod_customcert\certificate::get_course_time($certificate->course) < ($certificate->requiredtime * 60)) { if (\mod_customcert\certificate::get_course_time($certificate->course) < ($certificate->requiredtime * 60)) {
$candownload = false; $requiredtimemet = false;
} }
} }
$fileurl = ""; $fileurl = "";
if ($candownload) { if ($requiredtimemet) {
$fileurl = new \moodle_url('/mod/customcert/mobile/pluginfile.php', ['certificateid' => $certificate->id, $fileurl = new \moodle_url('/mod/customcert/mobile/pluginfile.php', ['certificateid' => $certificate->id,
'userid' => $USER->id]); 'userid' => $USER->id]);
$fileurl = $fileurl->out(true); $fileurl = $fileurl->out(true);
@ -109,7 +109,7 @@ class mobile {
'showgroups' => !empty($groups), 'showgroups' => !empty($groups),
'groups' => array_values($groups), 'groups' => array_values($groups),
'canmanage' => $canmanage, 'canmanage' => $canmanage,
'candownload' => $candownload, 'requiredtimemet' => $requiredtimemet,
'fileurl' => $fileurl, 'fileurl' => $fileurl,
'showreport' => $showreport, 'showreport' => $showreport,
'hasrecipients' => !empty($recipients), 'hasrecipients' => !empty($recipients),

View file

@ -45,6 +45,7 @@ $addons = [
['getcustomcert', 'customcert'], ['getcustomcert', 'customcert'],
['listofissues', 'customcert'], ['listofissues', 'customcert'],
['nothingtodisplay', 'moodle'], ['nothingtodisplay', 'moodle'],
['notissued', 'customcert'],
['pluginname', 'customcert'], ['pluginname', 'customcert'],
['receiveddate', 'customcert'], ['receiveddate', 'customcert'],
['requiredtimenotmet', 'customcert'], ['requiredtimenotmet', 'customcert'],

View file

@ -115,7 +115,7 @@ $string['nocustomcerts'] = 'There are no certificates for this course';
$string['noimage'] = 'No image'; $string['noimage'] = 'No image';
$string['norecipients'] = 'No recipients'; $string['norecipients'] = 'No recipients';
$string['notemplates'] = 'No templates'; $string['notemplates'] = 'No templates';
$string['notissued'] = 'Not issued'; $string['notissued'] = 'Not awarded';
$string['notverified'] = 'Not verified'; $string['notverified'] = 'Not verified';
$string['options'] = 'Options'; $string['options'] = 'Options';
$string['page'] = 'Page {$a}'; $string['page'] = 'Page {$a}';

View file

@ -209,7 +209,7 @@ function customcert_user_complete($course, $user, $mod, $customcert) {
echo userdate($issue->timecreated); echo userdate($issue->timecreated);
echo $OUTPUT->box_end(); echo $OUTPUT->box_end();
} else { } else {
print_string('notissuedyet', 'customcert'); print_string('notissued', 'customcert');
} }
} }

View file

@ -33,7 +33,7 @@
* showgroups * showgroups
* groups * groups
* canmanage * canmanage
* candownload * requiredtimemet
* hasrecipients * hasrecipients
* recipients * recipients
* fileurl * fileurl
@ -62,7 +62,7 @@
} }
], ],
"canmanage": "true", "canmanage": "true",
"candownload": "true", "requiredtimemet": "true",
"fileurl": "http://yoursite.com/mod/customcert/mobile/pluginfile.php?id=4", "fileurl": "http://yoursite.com/mod/customcert/mobile/pluginfile.php?id=4",
"showreport": "true", "showreport": "true",
"hasrecipients": "true", "hasrecipients": "true",
@ -81,28 +81,46 @@
{{=<% %>=}} {{=<% %>=}}
<div> <div>
<core-course-module-description description="<% certificate.intro %>" component="mod_customcert" componentId="<% cmid %>"></core-course-module-description> <core-course-module-description description="<% certificate.intro %>" component="mod_customcert" componentId="<% cmid %>"></core-course-module-description>
<%#issue%>
<%^canmanage%> <%^canmanage%>
<%#requiredtimemet%>
<ion-item> <ion-item>
<ion-grid>
<ion-row>
<ion-col col-6 class="text-left">
{{ 'plugin.mod_customcert.receiveddate' | translate }} {{ 'plugin.mod_customcert.receiveddate' | translate }}
<br /> <br />
<div class="timerewarded">{{ <% timecreated %> | coreToLocaleString }}</div> <div class="timerewarded">
</ion-item> <%#issue%>
<%/canmanage%> {{ <% timecreated %> | coreToLocaleString }}
<%/issue%> <%/issue%>
<%#candownload%> <%^issue%>
{{ 'plugin.mod_customcert.notissued' | translate }}
<%/issue%>
</div>
</ion-col>
<ion-col col-6 class="text-right">
<button ion-button icon-only clear [core-download-file]="{fileurl: '<% fileurl %>', timemodified: '<% currenttimestamp %>'}" moduleId="<% cmid %>" courseId="<% certificate.course %>" component="mod_customcert">
<ion-icon name="download"></ion-icon>
</button>
</ion-col>
</ion-row>
</ion-grid>
</ion-item>
<%/requiredtimemet%>
<%^requiredtimemet%>
<ion-item>
<p>{{ 'plugin.mod_customcert.requiredtimenotmet' | translate: {$a: { requiredtime: <% certificate.requiredtime %>} } }}</p>
</ion-item>
<%/requiredtimemet%>
<%/canmanage%>
<%#canmanage%>
<ion-item> <ion-item>
<button ion-button block core-course-download-module-main-file moduleId="<% cmid %>" courseId="<% certificate.course %>" component="mod_customcert" [files]="[{fileurl: '<% fileurl %>', timemodified: '<% currenttimestamp %>'}]"> <button ion-button block core-course-download-module-main-file moduleId="<% cmid %>" courseId="<% certificate.course %>" component="mod_customcert" [files]="[{fileurl: '<% fileurl %>', timemodified: '<% currenttimestamp %>'}]">
<ion-icon name="download" item-start></ion-icon> <ion-icon name="download" item-start></ion-icon>
{{ 'plugin.mod_customcert.getcustomcert' | translate }} {{ 'plugin.mod_customcert.getcustomcert' | translate }}
</button> </button>
</ion-item> </ion-item>
<%/candownload%> <%/canmanage%>
<%^candownload%>
<ion-item>
<p>{{ 'plugin.mod_customcert.requiredtimenotmet' | translate: {$a: { requiredtime: <% certificate.requiredtime %>} } }}</p>
</ion-item>
<%/candownload%>
<%#showreport%> <%#showreport%>
<ion-item> <ion-item>
{{ 'plugin.mod_customcert.listofissues' | translate }} {{ 'plugin.mod_customcert.listofissues' | translate }}