Skip to content

Commit 4f78ec7

Browse files
committed
Minor formatting changes (#531)
1 parent da25126 commit 4f78ec7

File tree

2 files changed

+24
-16
lines changed

2 files changed

+24
-16
lines changed

classes/task/email_certificate_task.php

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ public function get_name() {
4848
*/
4949
public function execute() {
5050
global $DB;
51+
5152
$customdata = $this->get_custom_data();
5253

5354
$issueid = $customdata->issueid;
@@ -57,7 +58,7 @@ public function execute() {
5758
FROM {customcert} c
5859
JOIN {customcert_templates} ct ON c.templateid = ct.id
5960
JOIN {course} co ON c.course = co.id
60-
WHERE c.id = :id";
61+
WHERE c.id = :id";
6162

6263
$customcert = $DB->get_record_sql($sql, ['id' => $customcertid]);
6364

@@ -79,12 +80,12 @@ public function execute() {
7980
$coursefullname = format_string($customcert->coursefullname, true, ['context' => $context]);
8081
$certificatename = format_string($customcert->name, true, ['context' => $context]);
8182

82-
// Used to create the email subject.
83-
$info = new \stdClass();
84-
$info->coursename = $courseshortname; // Added for BC, so users who have edited the string don't lose this value.
85-
$info->courseshortname = $courseshortname;
86-
$info->coursefullname = $coursefullname;
87-
$info->certificatename = $certificatename;
83+
// Used to create the email subject.
84+
$info = new \stdClass();
85+
$info->coursename = $courseshortname; // Added for BC, so users who have edited the string don't lose this value.
86+
$info->courseshortname = $courseshortname;
87+
$info->coursefullname = $coursefullname;
88+
$info->certificatename = $certificatename;
8889

8990
// Get the information about the user and the certificate issue.
9091
$userfields = helper::get_all_user_name_fields('u');
@@ -93,7 +94,7 @@ public function execute() {
9394
JOIN {user} u
9495
ON ci.userid = u.id
9596
WHERE ci.customcertid = :customcertid
96-
AND ci.id = :issueid";
97+
AND ci.id = :issueid";
9798
$user = $DB->get_record_sql($sql, ['customcertid' => $customcertid, 'issueid' => $issueid]);
9899

99100
// Create a directory to store the PDF we will be sending.

classes/task/issue_certificates_task.php

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,14 @@ public function execute() {
6060
$sql = "SELECT c.*, ct.id as templateid, ct.name as templatename, ct.contextid, co.id as courseid,
6161
co.fullname as coursefullname, co.shortname as courseshortname
6262
FROM {customcert} c
63-
JOIN {customcert_templates} ct ON c.templateid = ct.id
64-
JOIN {course} co ON c.course = co.id
65-
JOIN {course_categories} cat ON co.category = cat.id
66-
LEFT JOIN {customcert_issues} ci ON c.id = ci.customcertid";
63+
JOIN {customcert_templates} ct
64+
ON c.templateid = ct.id
65+
JOIN {course} co
66+
ON c.course = co.id
67+
JOIN {course_categories} cat
68+
ON co.category = cat.id
69+
LEFT JOIN {customcert_issues} ci
70+
ON c.id = ci.customcertid";
6771

6872
// Add conditions to exclude certificates from hidden courses.
6973
$sql .= " WHERE (c.emailstudents = :emailstudents
@@ -77,6 +81,7 @@ public function execute() {
7781
// Exclude certificates from hidden courses.
7882
$sql .= " AND co.visible = 1 AND cat.visible = 1";
7983
}
84+
8085
// Add condition based on certificate execution period.
8186
if ($certificateexecutionperiod > 0) {
8287
// Include courses with no end date or end date greater than the specified period.
@@ -92,12 +97,12 @@ public function execute() {
9297

9398
// When we get to the end of the list, reset the offset.
9499
set_config('certificate_offset', !empty($customcerts) ? $offset + $certificatesperrun : 0, 'customcert');
100+
95101
if (empty($customcerts)) {
96102
return;
97103
}
98104

99105
foreach ($customcerts as $customcert) {
100-
101106
// Check if the certificate is hidden, quit early.
102107
$cm = get_course_and_cm_from_instance($customcert->id, 'customcert', $customcert->course)[1];
103108
if (!$cm->visible) {
@@ -107,9 +112,11 @@ public function execute() {
107112
// Do not process an empty certificate.
108113
$sql = "SELECT ce.*
109114
FROM {customcert_elements} ce
110-
JOIN {customcert_pages} cp ON cp.id = ce.pageid
111-
JOIN {customcert_templates} ct ON ct.id = cp.templateid
112-
WHERE ct.contextid = :contextid";
115+
JOIN {customcert_pages} cp
116+
ON cp.id = ce.pageid
117+
JOIN {customcert_templates} ct
118+
ON ct.id = cp.templateid
119+
WHERE ct.contextid = :contextid";
113120
if (!$DB->record_exists_sql($sql, ['contextid' => $customcert->contextid])) {
114121
continue;
115122
}

0 commit comments

Comments
 (0)