#207 No need to use a table/list when displaying only one issue
This commit is contained in:
parent
f63d61d164
commit
520d6a2a5d
3 changed files with 24 additions and 38 deletions
|
@ -60,7 +60,11 @@ class mobile {
|
||||||
$certificate->introformat, $context->id, 'mod_customcert', 'intro');
|
$certificate->introformat, $context->id, 'mod_customcert', 'intro');
|
||||||
|
|
||||||
// Get any issues this person may have.
|
// 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;
|
$candownload = true;
|
||||||
$canmanage = has_capability('mod/customcert:manage', $context);
|
$canmanage = has_capability('mod/customcert:manage', $context);
|
||||||
|
@ -101,8 +105,7 @@ class mobile {
|
||||||
$data = [
|
$data = [
|
||||||
'certificate' => $certificate,
|
'certificate' => $certificate,
|
||||||
'cmid' => $cm->id,
|
'cmid' => $cm->id,
|
||||||
'hasissues' => !empty($issues),
|
'issue' => $issue,
|
||||||
'issues' => array_values($issues),
|
|
||||||
'showgroups' => !empty($groups),
|
'showgroups' => !empty($groups),
|
||||||
'groups' => array_values($groups),
|
'groups' => array_values($groups),
|
||||||
'canmanage' => $canmanage,
|
'canmanage' => $canmanage,
|
||||||
|
|
|
@ -50,12 +50,9 @@
|
||||||
"requiredtime": "60"
|
"requiredtime": "60"
|
||||||
},
|
},
|
||||||
"cmid": "25",
|
"cmid": "25",
|
||||||
"hasissues": "true",
|
"issue": {
|
||||||
"issues": [
|
"timecreated": "1528370177"
|
||||||
{
|
},
|
||||||
"timecreated": "1528370177"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"showgroups": "true",
|
"showgroups": "true",
|
||||||
"groups": [
|
"groups": [
|
||||||
{
|
{
|
||||||
|
@ -84,20 +81,15 @@
|
||||||
{{=<% %>=}}
|
{{=<% %>=}}
|
||||||
<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>
|
||||||
<%#hasissues%>
|
<%#issue%>
|
||||||
<%^canmanage%>
|
<%^canmanage%>
|
||||||
<ion-list>
|
<ion-item>
|
||||||
<ion-list-header class="text-center">
|
{{ 'plugin.mod_customcert.receiveddate' | translate }}
|
||||||
{{ 'plugin.mod_customcert.receiveddate' | translate }}
|
<br />
|
||||||
</ion-list-header>
|
<div class="timerewarded">{{ <% timecreated %> | coreToLocaleString }}</div>
|
||||||
<%#issues%>
|
</ion-item>
|
||||||
<ion-item class="text-center">
|
|
||||||
{{ <% timecreated %> | coreToLocaleString }}
|
|
||||||
</ion-item>
|
|
||||||
<%/issues%>
|
|
||||||
</ion-list>
|
|
||||||
<%/canmanage%>
|
<%/canmanage%>
|
||||||
<%/hasissues%>
|
<%/issue%>
|
||||||
<%#candownload%>
|
<%#candownload%>
|
||||||
<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 %>'}]">
|
||||||
|
|
25
view.php
25
view.php
|
@ -124,35 +124,26 @@ if (!$downloadown && !$downloadissue) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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 = '';
|
$issuehtml = '';
|
||||||
$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) {
|
if ($issues && !$canmanage) {
|
||||||
$table = new html_table();
|
// Get the most recent issue (there should only be one).
|
||||||
$table->class = 'generaltable';
|
$issue = reset($issues);
|
||||||
$table->head = array(get_string('receiveddate', 'customcert'));
|
$issuestring = get_string('receiveddate', 'customcert') . ': ' . userdate($issue->timecreated);
|
||||||
$table->align = array('left');
|
$issuehtml = $OUTPUT->box($issuestring);
|
||||||
$table->attributes = array('style' => 'width:20%; margin:auto');
|
|
||||||
|
|
||||||
foreach ($issues as $issue) {
|
|
||||||
$row = array();
|
|
||||||
$row[] = userdate($issue->timecreated);
|
|
||||||
$table->data[$issue->id] = $row;
|
|
||||||
}
|
|
||||||
|
|
||||||
$issuelist = html_writer::table($table) . "<br />";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the button to download the customcert.
|
// Create the button to download the customcert.
|
||||||
$linkname = get_string('getcustomcert', 'customcert');
|
$linkname = get_string('getcustomcert', 'customcert');
|
||||||
$link = new moodle_url('/mod/customcert/view.php', array('id' => $cm->id, 'downloadown' => true));
|
$link = new moodle_url('/mod/customcert/view.php', array('id' => $cm->id, 'downloadown' => true));
|
||||||
$downloadbutton = new single_button($link, $linkname);
|
$downloadbutton = new single_button($link, $linkname, 'post', true);
|
||||||
$downloadbutton = html_writer::tag('div', $OUTPUT->render($downloadbutton), array('style' => 'text-align:center'));
|
$downloadbutton = $OUTPUT->render($downloadbutton);
|
||||||
|
|
||||||
// Output all the page data.
|
// Output all the page data.
|
||||||
echo $OUTPUT->header();
|
echo $OUTPUT->header();
|
||||||
echo $OUTPUT->heading(format_string($customcert->name));
|
echo $OUTPUT->heading(format_string($customcert->name));
|
||||||
echo $intro;
|
echo $intro;
|
||||||
echo $issuelist;
|
echo $issuehtml;
|
||||||
echo $downloadbutton;
|
echo $downloadbutton;
|
||||||
if (isset($reporttable)) {
|
if (isset($reporttable)) {
|
||||||
echo $OUTPUT->heading(get_string('listofissues', 'customcert'), 3);
|
echo $OUTPUT->heading(get_string('listofissues', 'customcert'), 3);
|
||||||
|
|
Loading…
Reference in a new issue