I would like to hack the code of the certificates program (on my computer, that is) and get it to add the students license number, which then enter on a field on the signup page. How would I do that? Otherwise, I will have to manually fill out, sign and turn in sooooooo many certificates, when it could be simply automated. Any ideas?
When you say that they enter it in a field on the signup page, you mean that it is in custom field of their profile ?
If yes, this subject has already be answered here: https://moodle.org/mod/forum/discuss.php?d=186674
But beware that the first answers given in that thread are for old Moodle versions.
If you are running a recent Moodle version (and a recent version of the certificate addon) it's just a matter of adding a single line to your mod/certificate/type/mytype/certificate.php file (replace mytype with the type name you are using, for instance A4_embedded or letter_non_embedded)
This line should look like
certificate_print_text($pdf, $x + 140, $y + 50, 'L', 'Helvetica', '', 20, $USER->profile['myprofileshortname']);
adjust the 140 and 50 numbers to display the licence number at a suitable place on your certificate (the first number adjust the horizontal position and the second number the vertical position
the 20 number adjust the font size
'Helvetica' adjust the font used (you can change it to 'Times' if you prefer)
'myprofileshortname' should be the short name of the custom profile field used to store the licence number
Thank you, I added it! Great solution!
I would also like to add, just before that, "license #". Do you know how I do that?
Here is what I have...
certificate_print_text($x + 140, $y + 135, 'L', 'Helvetica', 20, add_text->'License #');
certificate_print_text($pdf, $x + 149, $y + 135, 'L', 'Helvetica', '', 20, $USER->profile['Licensenumber']);
The first line is not working, but I counted 9 spaces needed before the number is added, so I have the x-axis spaced correctly, I think. What say you?
Well it's in fact just:
certificate_print_text($x + 140, $y + 135, 'L', 'Helvetica', 20, 'License #');
you can even combine the 2 lines with:
certificate_print_text($x + 140, $y + 135, 'L', 'Helvetica', 20, 'License # ' . $USER->profile['Licensenumber']);
Note the space at the end of 'License # ' so that the licence number is correctly spaced from the label.
Are you sure? It does not seem to work at all with that code...
The code was
certificate_print_text($pdf, $x + 310, $y + 135, 'L', 'Helvetica', '', 12, 'License #', $USER->profile['Licensenumber']);
Thank you so much! I could not have gotten it without you! I really appreciate your help!