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

View file

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

View file

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

View file

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

View file

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