-
Notifications
You must be signed in to change notification settings - Fork 0
/
deprecatedlib.php
248 lines (214 loc) · 8.14 KB
/
deprecatedlib.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
<?php
// This file is part of the Certificate module for Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Deprecated certificate functions.
*
* @package mod_certificate
* @copyright Mark Nelson <markn@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
/**
* Prepare to be print the date -- defaults to time.
*
* @deprecated since certificate version 2012052501
* @param stdClass $certificate
* @param stdClass $course
* @return string the date
*/
function certificate_generate_date($certificate, $course) {
debugging('certificate_generate_date is deprecated, please use certificate_get_date instead which will
return a date in a human readable format.', DEBUG_DEVELOPER);
global $DB, $USER;
// Set certificate date to current time, can be overwritten later
$date = time();
if ($certificate->printdate == '2') {
// Get the enrolment end date
$sql = "SELECT MAX(c.timecompleted) as timecompleted
FROM {course_completions} c
WHERE c.userid = :userid
AND c.course = :courseid";
if ($timecompleted = $DB->get_record_sql($sql, array('userid' => $USER->id, 'courseid' => $course->id))) {
if (!empty($timecompleted->timecompleted)) {
$date = $timecompleted->timecompleted;
}
}
} else if ($certificate->printdate > 2) {
if ($modinfo = certificate_get_mod_grade($course, $certificate->printdate, $USER->id)) {
$date = $modinfo->dategraded;
}
}
return $date;
}
/**
* Prepare to print the course grade.
*
* @deprecated since certificate version 2012052501
* @param stdClass $course
* @return mixed
*/
function certificate_print_course_grade($course){
debugging('certificate_print_course_grade is deprecated, please use certificate_get_grade instead. Ideally
you should be using certificate_get_grade in your certificate type which will either get the course
or module grade depending on your certificate settings.', DEBUG_DEVELOPER);
global $USER, $DB;
if ($course_item = grade_item::fetch_course_item($course->id)) {
$grade = new grade_grade(array('itemid'=>$course_item->id, 'userid'=>$USER->id));
$course_item->gradetype = GRADE_TYPE_VALUE;
$coursegrade = new stdClass;
$coursegrade->points = grade_format_gradevalue($grade->finalgrade, $course_item, true, GRADE_DISPLAY_TYPE_REAL, $decimals=2);
$coursegrade->percentage = grade_format_gradevalue($grade->finalgrade, $course_item, true, GRADE_DISPLAY_TYPE_PERCENTAGE, $decimals=2);
$coursegrade->letter = grade_format_gradevalue($grade->finalgrade, $course_item, true, GRADE_DISPLAY_TYPE_LETTER, $decimals=0);
return $coursegrade;
}
return false;
}
/**
* Prepare to print an activity grade.
*
* @deprecated since certificate version 2012052501
* @param stdClass $course
* @param int $moduleid
* @return mixed
*/
function certificate_print_mod_grade($course, $moduleid){
debugging('certificate_print_mod_grade is deprecated, please use certificate_get_mod_grade instead. Ideally
you should be using certificate_get_grade in your certificate type which will either get the course
or module grade depending on your certificate settings.', DEBUG_DEVELOPER);
global $USER;
return certificate_get_mod_grade($course, $moduleid, $USER->id);
}
/**
* Prepare to print an outcome.
*
* @deprecated since certificate version 2012052501
* @param stdClass $course
* @param int $moduleid
* @return mixed
*/
function certificate_print_outcome($course, $id) {
debugging('certificate_print_outcome is deprecated, please use certificate_get_outcome instead', DEBUG_DEVELOPER);
return certificate_get_outcome($certificate, $course);
}
/**
* Creates rectangles for line border for A4 size paper.
*
* @deprecated since certificate version 2012052501
* @param stdClass $pdf
* @param stdClass $certificate
* @return null
*/
function draw_frame($pdf, $certificate) {
debugging('draw_frame is deprecated, please use certificate_draw_frame instead', DEBUG_DEVELOPER);
certificate_draw_frame($pdf, $certificate);
}
/**
* Creates rectangles for line border for letter size paper.
*
* @deprecated since certificate version 2012052501
* @param stdClass $pdf
* @param stdClass $certificate
* @return null
*/
function draw_frame_letter($pdf, $certificate) {
debugging('draw_frame_letter is deprecated, please use certificate_draw_frame_letter instead', DEBUG_DEVELOPER);
certificate_draw_frame_letter($pdf, $certificate);
}
/**
* Prints border images from the borders folder in PNG or JPG formats.
*
* @deprecated since certificate version 2012052501
* @param stdClass $pdf;
* @param stdClass $certificate
* @param int $x x position
* @param int $y y position
* @param int $w the width
* @param int $h the height
* @return null
*/
function print_border($pdf, $certificate, $x, $y, $w, $h) {
debugging('print_watermark is deprecated, please use certificate_print_image instead', DEBUG_DEVELOPER);
certificate_print_image($pdf, $certificate, CERT_IMAGE_BORDER, $x, $y, $w, $h);
}
/**
* Prints watermark images.
*
* @deprecated since certificate version 2012052501
* @param stdClass $pdf;
* @param stdClass $certificate
* @param int $x x position
* @param int $y y position
* @param int $w the width
* @param int $h the height
* @return null
*/
function print_watermark($pdf, $certificate, $x, $y, $w, $h) {
debugging('print_watermark is deprecated, please use certificate_print_image instead', DEBUG_DEVELOPER);
certificate_print_image($pdf, $certificate, CERT_IMAGE_WATERMARK, $x, $y, $w, $h);
}
/**
* Prints signature images or a line.
*
* @deprecated since certificate version 2012052501
* @param stdClass $pdf
* @param stdClass $certificate
* @param int $x x position
* @param int $y y position
* @param int $w the width
* @param int $h the height
* @return null
*/
function print_signature($pdf, $certificate, $x, $y, $w, $h) {
debugging('print_signature is deprecated, please use certificate_print_image instead', DEBUG_DEVELOPER);
certificate_print_image($pdf, $certificate, CERT_IMAGE_SIGNATURE, $x, $y, $w, $h);
}
/**
* Prints seal images.
*
* @deprecated since certificate version 2012052501
* @param stdClass $pdf;
* @param stdClass $certificate
* @param int $x x position
* @param int $y y position
* @param int $w the width
* @param int $h the height
* @return null
*/
function print_seal($pdf, $certificate, $x, $y, $w, $h) {
debugging('print_seal is deprecated, please use certificate_print_image instead', DEBUG_DEVELOPER);
certificate_print_image($pdf, $certificate, CERT_IMAGE_SEAL, $x, $y, $w, $h);
}
/**
* Sends text to output given the following params.
*
* @deprecated since certificate version 2012052501
* @param stdClass $pdf
* @param int $x horizontal position
* @param int $y vertical position
* @param char $align L=left, C=center, R=right
* @param string $font any available font in font directory
* @param char $style ''=normal, B=bold, I=italic, U=underline
* @param int $size font size in points
* @param string $text the text to print
* @return null
*/
function cert_printtext($pdf, $x, $y, $align, $font, $style, $size, $text) {
static $hasbeenwarned = false;
if (!$hasbeenwarned) {
debugging('cert_printtext is deprecated, please use certificate_print_text instead', DEBUG_DEVELOPER);
}
$hasbeenwarned = true;
certificate_print_text($pdf, $x, $y, $align, $font, $style, $size, $text);
}