@@ -60,10 +60,14 @@ public function execute() {
60
60
$ sql = "SELECT c.*, ct.id as templateid, ct.name as templatename, ct.contextid, co.id as courseid,
61
61
co.fullname as coursefullname, co.shortname as courseshortname
62
62
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 " ;
67
71
68
72
// Add conditions to exclude certificates from hidden courses.
69
73
$ sql .= " WHERE (c.emailstudents = :emailstudents
@@ -77,6 +81,7 @@ public function execute() {
77
81
// Exclude certificates from hidden courses.
78
82
$ sql .= " AND co.visible = 1 AND cat.visible = 1 " ;
79
83
}
84
+
80
85
// Add condition based on certificate execution period.
81
86
if ($ certificateexecutionperiod > 0 ) {
82
87
// Include courses with no end date or end date greater than the specified period.
@@ -92,12 +97,12 @@ public function execute() {
92
97
93
98
// When we get to the end of the list, reset the offset.
94
99
set_config ('certificate_offset ' , !empty ($ customcerts ) ? $ offset + $ certificatesperrun : 0 , 'customcert ' );
100
+
95
101
if (empty ($ customcerts )) {
96
102
return ;
97
103
}
98
104
99
105
foreach ($ customcerts as $ customcert ) {
100
-
101
106
// Check if the certificate is hidden, quit early.
102
107
$ cm = get_course_and_cm_from_instance ($ customcert ->id , 'customcert ' , $ customcert ->course )[1 ];
103
108
if (!$ cm ->visible ) {
@@ -107,9 +112,11 @@ public function execute() {
107
112
// Do not process an empty certificate.
108
113
$ sql = "SELECT ce.*
109
114
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 " ;
113
120
if (!$ DB ->record_exists_sql ($ sql , ['contextid ' => $ customcert ->contextid ])) {
114
121
continue ;
115
122
}
0 commit comments