#203 Don't show 'Awarded on' date to managers

This commit is contained in:
Mark Nelson 2018-06-19 19:10:08 +08:00
parent f7587a5d22
commit eee14ade58
3 changed files with 20 additions and 13 deletions

View file

@ -67,7 +67,8 @@ class mobile {
$issues = $DB->get_records('customcert_issues', ['userid' => $USER->id, 'customcertid' => $certificate->id]); $issues = $DB->get_records('customcert_issues', ['userid' => $USER->id, 'customcertid' => $certificate->id]);
$candownload = true; $candownload = true;
if ($certificate->requiredtime && !has_capability('mod/customcert:manage', $context)) { $canmanage = has_capability('mod/customcert:manage', $context);
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; $candownload = false;
} }
@ -100,6 +101,7 @@ class mobile {
'groups' => array_values($groups), 'groups' => array_values($groups),
'hasissues' => !empty($issues), 'hasissues' => !empty($issues),
'issues' => array_values($issues), 'issues' => array_values($issues),
'canmanage' => $canmanage,
'candownload' => $candownload, 'candownload' => $candownload,
'fileurl' => $fileurl, 'fileurl' => $fileurl,
'showreport' => $showreport, 'showreport' => $showreport,

View file

@ -90,16 +90,18 @@
</a> </a>
<%/showreport%> <%/showreport%>
<%#hasissues%> <%#hasissues%>
<ion-list> <%^canmanage%>
<ion-list-header class="text-center"> <ion-list>
{{ 'plugin.mod_customcert.receiveddate' | translate }} <ion-list-header class="text-center">
</ion-list-header> {{ 'plugin.mod_customcert.receiveddate' | translate }}
<%#issues%> </ion-list-header>
<ion-item class="text-center"> <%#issues%>
{{ <% timecreated %> | coreToLocaleString }} <ion-item class="text-center">
</ion-item> {{ <% timecreated %> | coreToLocaleString }}
<%/issues%> </ion-item>
</ion-list> <%/issues%>
</ion-list>
<%/canmanage%>
<%/hasissues%> <%/hasissues%>
<%#candownload%> <%#candownload%>
<ion-item> <ion-item>

View file

@ -37,12 +37,14 @@ require_login($course, false, $cm);
$context = context_module::instance($cm->id); $context = context_module::instance($cm->id);
require_capability('mod/customcert:view', $context); require_capability('mod/customcert:view', $context);
$canmanage = has_capability('mod/customcert:manage', $context);
// Initialise $PAGE. // Initialise $PAGE.
$pageurl = new moodle_url('/mod/customcert/view.php', array('id' => $cm->id)); $pageurl = new moodle_url('/mod/customcert/view.php', array('id' => $cm->id));
\mod_customcert\page_helper::page_setup($pageurl, $context, format_string($customcert->name)); \mod_customcert\page_helper::page_setup($pageurl, $context, format_string($customcert->name));
// Check if the user can view the certificate based on time spent in course. // Check if the user can view the certificate based on time spent in course.
if ($customcert->requiredtime && !has_capability('mod/customcert:manage', $context)) { if ($customcert->requiredtime && !$canmanage) {
if (\mod_customcert\certificate::get_course_time($course->id) < ($customcert->requiredtime * 60)) { if (\mod_customcert\certificate::get_course_time($course->id) < ($customcert->requiredtime * 60)) {
$a = new stdClass; $a = new stdClass;
$a->requiredtime = $customcert->requiredtime; $a->requiredtime = $customcert->requiredtime;
@ -85,7 +87,8 @@ if (empty($action)) {
// If the current user has been issued a customcert generate HTML to display the details. // If the current user has been issued a customcert generate HTML to display the details.
$issuelist = ''; $issuelist = '';
if ($issues = $DB->get_records('customcert_issues', array('userid' => $USER->id, 'customcertid' => $customcert->id))) { $issues = $DB->get_records('customcert_issues', array('userid' => $USER->id, 'customcertid' => $customcert->id));
if ($issues && !$canmanage) {
$table = new html_table(); $table = new html_table();
$table->class = 'generaltable'; $table->class = 'generaltable';
$table->head = array(get_string('receiveddate', 'customcert')); $table->head = array(get_string('receiveddate', 'customcert'));