I'm a programmer that recently started learning about moodle.
I need to create a "diploma" or "certificate" generation add-on to moodle
for a local course that is being driven in moodle.
I've been reading the code and learning how to hack it to insert this new
option, but i would like also to contribute to this community with this
tool (in the case it would be useful to you).
Any ideas, about how to start and develop it following the standards
and being generic enough to make it integrate smoothly into moodle?
Thanks and i hope that my work will be useful.
Hugo
Hugo,
This is very timely for me. I have a situation right now that could use this feature. I was intending to connect the certificate/diploma generating feature to a custom PHP registration form that is being created, with an admin interface. What might be ideal is to create this feature as a Moodle module, which could be hidden until the completion of the course. At that point, students simply create their own certificate/diploma if they have completed requirements. If the page generated is in landscape view, like a real diploma, that would be nice. Should have a way for admin to add their logo and maybe a seal graphic if desired.
Thanks for your feedback!
-- Art
On another system that we use, the Gradebook is used to calculate the students marks based on a number of criteria. The teacher allocates marks for each assessment event and when the student passes they are eligible to print out a letter stating that they have completed the course. If they reach a higher mark they can also print out a certificate.
The teacher determines if the student is allowed to print their own certificates or if the teacher is the only one that can print them out for presentation at an awards ceremony.
I would imagine the best way to do this in Moodle would be to link to a template that is combined with the students name etc to generate a PDF ( in Open Office perhaps). Idealy there would be a number of certificates defined, similar to a calculated column.
David
That would be fantastic!
~Peter
You should definitely get started with a manual version of the module that allows the teacher to define a certificate, and allows the students to print or download certificates, and get all that part working nicely. Just that will be a huge contribution and very useful for many people already, since they can use "hide/show" to restrict access manually, or perhaps your module will contain a date before which students can't use it.
Some ideas:
- a pure HTML-based certificate using CSS to style it for printing
- an image-based version, where you could allow the teacher to upload an image, then use GD to scale it to a reasonable size, and HTML imagemaps to allow the teacher to click in the image to tell Moodle where to put the names etc, and finally use GD to insert the names.
- A PDF version would also be a very good idea (I recommend FPDF for this).
Once this much is working to everyone's satisfaction, we can think about how to "unlock" the module automatically. The best way I can think of will be to use the upcoming framework for dependent activities (which doesn't exist just yet but needs to since it opens up a lot of things).
For coding, see the coding guidelines, and there is a template for starting a new module. You can always ask questions here in this forum too.

The generation of the pdf is already done. It's a php script that uses a public domain library (http://sourceforge.net/projects/pdf-php)
Actually, my solution simply hacks the "grades.php" script in moodle, adding one column with a link to this script, giving the student name via a cgi parameter.
I've read the template for starting a new module, but i'm not sure that this feature should be a module. As i understand, a module is a "activity" that you put in a specified time. But the certificate i think is related to a final grade in the course.
I think that this feature should be an extension of "grades.php" and "grade.php". From the plural point of view, the teacher has the rights to check or uncheck the certificate for every student. And from the student point of view (grade.php), he/she could download the pdf.
Another section of the teacher allows him to customize the signature, title and text of the certificate.
Am i correct?
Thanks,
Hugo
I'm also thinking about the "activity locking" or "conditional activities" work upcoming. This will allow you to "lock" an activity until a given condition is met in another activity - providing more flexibility.
So, for a final certificate, the certificate would not be unlocked until a certain grade in another final activity is achieved (eg an assignment or journal or quiz), and this in turn might not become available until a previous activity was done, and so on.
Finally, the grades system is due a revamp too - it needs to be changed from a "caclulate on the fly by pulling in data" model, to a "modules push data into a central table" model, which allows calculated columns, arbitrary columns, external linking etc etc. So don't get too comfy with the current setup.
So if you get a basic module done we can start linking it up properly.
Certificates, activity locking and conditional activities would be great added value! . If you ever need testing count me on . For certificates would be very nice to have a custom, automated, optional final grade printed on it, along with signatures and custom graphics.
Maybe I can help out as I need one of these.
cvs, but i can send you a copy by email of what i've done, if this can
help you for an emergency
I would prefer not to start a collaborative programming effort yet,
until i could deliver a initial simple version.
Hugo
Yes please: pevans@catholic.org
It's not an emergency until next month
Would you please send me a copy also?
Thank you
I have some code lying around I wrote for a GIS project which generates pdf's, but it is not at all suitable for use with a web-server which may get busy. That and it's in python not php.
Hello all,
i am trying to add this functionality in as well but i am only in planning stage when i can across this post.
i have been trying to use the fpdf class to create basic ones as i start, but with no luck sure it can create basic pdf's and email them out to reciepients but i dont think it can create a pdf that any of us would be proud of easily, e.g lack of html support.
Hugo what is the plans for your certificate?
it would be handy to be able to set up a templates for certificates in the themes folder and associate the certificates to a course? if possible just thinking big.
My plan is a bit more modest.
Now i have an "activity module" version. The teacher
can place it in his course in any date (and hide it until he wants).
Then, when its visible, the student can click on it and download a
pdf with his/her name and the name of the course.
My next version (on which i'll be working tonight) will contain the
teacher's side of the diploma. In this section, the teacher will see the list
of the students and he could check or uncheck the students who deserves
or not the diploma.
The layout of the diploma is fixed. It has a title, fixed lines of text, and
the name of the student and course as variables.
I leave a pdf here, if you want to see it
http://www.vulcano.cl/cquiroz.pdf
Hugo
It's proving to be easy to modify to suit my needs; been playing with the layout etc. tonight.
Hugo:
Is it possible for you to use vulcano.cl to keep posting a tarball every once in a while?
Hugo,
This looks great. Could I get a copy too? Since a lot of people seem to be interested, maybe you could attach it to a forum post. Then everybody would quit pestering you for individual copies.
Also can you link the certificate to more than one activity
Hugo,
I would like to collaborate with you on this. If you would be able to send me what you've got, I'll decide if it would suit my client. Hopefully we will be able to come up with something that will benefit the community. My client has a few other unique customizations that he has requested, but I am also on a timeline. Hopefully you would be able to send me this soon.
Thank you.
Jordan
I guess you might want my email address to send me that. It's been one of those days.
jordanilott@shaw.ca
I will put tonight (in about 5 hours) my module and i'll post here the instructions.
Thanks for your interest in my module

Hugo
PS
Could you incorparte a static date of completion. This is so that the user can print the certificate multiple times, but can only have one date. This will insure that they do not have 8 copies with different dates. The reason this is important, is that the student could say that they have taken the course 8 times.
All it really took was creating a new table called "[prefix]certificate_stats", with the following structure:
CREATE TABLE `certificate_stats` (
`id` int(10) unsigned NOT NULL auto_increment,
`certificateid` int(10) unsigned NOT NULL default '0',
`userid` int(10) unsigned NOT NULL default '0',
`timeseen` int(10) unsigned NOT NULL default '0',
PRIMARY KEY (`id`)
) TYPE=MyISAM COMMENT='Static certificate view times';
And then adding the following lines above the PDF creation code in "view.php":
// Generate or load existing completion date
if (record_exists("certificate_stats", "certificateid", $course->id, "userid", $USER->id)) {
$view_time = get_field("certificate_stats", "timeseen", "certificateid", $course->id, "userid", $USER->id);
} else {
$view_time = time();
insert_record("certificate_stats", array("certificateid" => $course->id, "userid" => $USER->id, "timeseen" => $view_time), false);
}
You can then print the completion date onto the certificate using the "$view_time" variable.
Hugo.
Moodlers should be able to download the "Certificate" mod at the following location in the morning.
http://moodle.org/download.php/modules/certificate.zip
WP1
Very nice mod.
Installed the mod today on v1.3.1. Install went well with no errors.
The problems I noted were
- the display of HTML code if the name of the corse had HTML code included on the Course Settings page. (See attached image.)
- No Settings window for the "Certificate" module on the "Modules" page in "Administration.
- No "Installation Guide" or "How To" document
BTW, where does the "fonts" folder go to. Should it be placed in the "lang" directory or be maintained in the "certificate" directory inside of the "mod" directory?
I also changed the phrase "This Diploma has been conferred for" to "This Diploma has been conferred on" which is not really an error but a matter of language. I did this in the "certificate.php" file which is in the "lang/en" directory.
WP1

- the display of HTML code if the name of the corse had HTML code included on the Course Settings page. (See attached image.)
i realized that problem... i didn't know that a course name could contain html formatting, but i'll work on this.
- No Settings window for the "Certificate" module on the "Modules" page in "Administration.
That's true. I will put in there a signature's upload section.
- No "Installation Guide" or "How To" document
BTW, where does the "fonts" folder go to. Should it be placed in the "lang" directory or be maintained in the "certificate" directory inside of the "mod" directory?
Inside the mod/certificate directory. The only directory you have to move outside of mod is "lang/".
I also changed the phrase "This Diploma has been conferred for" to "This Diploma has been conferred on" which is not really an error but a matter of language. I did this in the "certificate.php" file which is in the "lang/en" directory.
Yes! that's the place.
Thanks for your feedback.
Hugo
Hi Hugo,
I installed your certificate module today. It is really neat. A couple of comments:
- I made a new simple box border to replace your border since the png file you have is gigantic!!! Is there any way you can make it a smaller file? Also, does it have to be a png?
- Would there be any way to add the date to the certificate? That would be really cool.
- I replaced the right signature png with a shape to look like a seal (not the animal, like a stamped seal), but the shape comes up a little squished--its not that big of a deal, but maybe the sizing throws things off a bit?
Thanks for this module--there are a lot of business users looking for something like this.
Chardelle
Hello Chardelle,
you need this code:
Question 1.
you do not need to use PNGs all you need to do is cange this code:
$pdf->addPngFromFile('borde.png',25,20,800,550);
$pdf->addPngFromFile('signature.png',480,125,200,100);
$pdf->addPngFromFile('signature2.png',150,120,200,100);
if you want to use a jpeg change addPngFromFile to addJpegFromFile
Question 2.
$completion_date = date ("dS of F Y", mktime ());
$pdf->ezText("Date Issued: $completion_date",10,array('justification'=>'centre'));
Question 3.
around line 18 you will find this code
$pdf->addPngFromFile('signature2.png',150,120,200,100);
200 = the width of the image
100 = the length of the image
i hope this helps
Chris
Hugo,
I take it that at this time the certification is customized for one teacher and one teacher only?? So lets say Mr. Smith has a cert for his students, then the signature for the cert would say Mr. Wall if that is what the signature1.png file says. If so is there plans to make the module flexible for all teachers to customize there own certifications.
each "certificate".
But i think that the image format must be png. Jpeg is for photographs, and png for drawings... so...
Hugo
Hi Everyone,
Here is a picture of my printer-friendly certificate (made very quickly so a little rough). The date has been added!! I tried using a gif instead of a png but it didn't work. These images were exported into Ping 24--to make the smallest possible size that still looks okay. The entire file is only about 30k .
Chardelle

Very nice Chardelle!
Hi Chris,
I just tested the certificate today and the date came up as:
August 01st, 2004
I can't tell what the code means, so not sure how to fix it. Can you tell me how to either take the 0 out or take the st(th) out?
Thank you
see if this does it:
change:
$completion_date = date ("F dS, Y", mktime ());
to
$completion_date = date ("F jS, Y", mktime ());
try that and let me know
sorry about the hassel!
Hi Chris,
Thanks, that change takes out the 0. And no hassles! That's what testing is all about.
Chardelle
I hope that this weekend could deliver a new version, with the upload
of signature images, and a control chart of what students can download
the certificate.
Hugo
Hello Hugo,
I was wondering if you have been able to include the "control" of who can get the certificate?
I don't know if this will be of help to you, but have you seen Bernard's "Activity Linking" code which opens up an activity based on whether or not a particular resource has been viewed? For example, it might be used to force a student to take a quiz, or fill out a survey before the certificate would become available. http://moodle.org/mod/forum/discuss.php?d=8336
Thank you,
Chardelle
Here is a border.png file a little smaller (228 Ko).
Cheers
Nicolas

Here is a french translation of the "lang" file. To be put (if you want) in "lang/fr/".
Cheers and thanks for your work!
Nicolas
Hi Nicolas,
The new border png is great--we will need to get that into CVS to replace the other one (as well as your translation).
Also, to update my previous post. Thanks to Bernard Boucher, the certificate can now be "blocked" from access until either a quiz or lesson has been completed, or a resource has been viewed. See the image to see what it looks like in a course. The link is dimmed and clicking on it brings up a message such as: "You must complete the quiz before you can...." Once the quiz is passed, the link is no longer dimmed. See this thread: http://moodle.org/mod/forum/discuss.php?d=11811 to find out more.
Chardelle

Very nice Chardelle,
I hope i helped, just a question, is your border a graphic or is it coded? because if you are looking about file size the border you have is easily coded if you would like me to do that for you!
let me know always will to help (when i actually know wat is going on)
regards,
chris
Hi Chris,
Yes, getting the date put in is really helpful, thanks. As for the border, yes I just made a graphic file. I am not too worried about the size now, this image is only about 6k, but actually it might be very good to be able to have just a basic "box" border around a certificate using code. In fact, you could probably come up with something that looks better than the one I did. That way we wouldn't have to make our own image of a border--but would we be able to change the color of the border?
Thanks,
Chardelle
Hello Everyone,
just some code that might be usefull. it adds 3 lines creating a border around the page. attached is a jpeg of the pdf i have ceated for our statement of attainments.
If you are viewing your certificate landscape
$pdf = new Cezpdf('a4','landscape');
$pdf->setStrokeColor('0','0','0.5'); /* this is in RGB colour mode and values can only be between 0 -> 1 */
$pdf->setLineStyle(1); /* (1) is the thickness of the line if you change this you will need to change the size of the other rectangles */
$pdf->rectangle(25,25,791.89,545.28);
$pdf->setLineStyle(2);
$pdf->rectangle(27.5,27.5,786.89,540.28);
$pdf->setLineStyle(1);
$pdf->rectangle(30,30,781.89,535.28);
If you are viewing your certificate portrait
$pdf = new Cezpdf('a4','portrait');
$pdf->setStrokeColor('0.51','0','0.5'); /* this is in RGB colour mode and values can only be between 0 -> 1 */
$pdf->setLineStyle(1); /* (1) is the thickness of the line if you change this you will need to change the size of the other rectangles */
$pdf->rectangle(25,25,545.28,791.89);
$pdf->setLineStyle(2);
$pdf->rectangle(27.5,27.5,540.28,786.89);
$pdf->setLineStyle(1);
$pdf->rectangle(30,30,535.28,781.89);
also Chardelle you cant display gif's at the moment with this class you can only display png's and jpegs - the code for this is posted above
best of luck,
Chris

Sooner or later we non-programmers or "baby" programmers are going to have to ask one of the MoodleMaster programmers to create a Resource GUI for this fabulous certificate script.
Chris do you have time to make up an Instruction Guide for this hack of a hack.
WP1
Um where do I start,
This is the first thing ive ever known about in these forums...lol
Basically you can find indepth detail from http://sourceforge.net/forum/?group_id=45168
the only problem is it does take them a long time to reply if they reply at all, the classes readme pdf is attached because there is lots of great little functions and things you can do with the class.
As for the border hack.
I am using this function for a different application but in the view.php file that you recieve in the mod download
line 65:
$pdf = new Cezpdf('a4','landscape'); /*this sets the size and orientation of the page/paper for the pdf document */
for the hack in my last post replace line 68 - $pdf->addPngFromFile('borde.png',25,20,800,550);
with
$pdf->setStrokeColor('0','0','0.5'); /* this is in RGB colour mode and values can only be between 0 -> 1 */
$pdf->setLineStyle(1); /* (1) is the thickness of the line if you change this you will need to change the size of the other rectangles */
$pdf->rectangle(25,25,791.89,545.28);
$pdf->setLineStyle(2);
$pdf->rectangle(27.5,27.5,786.89,540.28);
$pdf->setLineStyle(1);
$pdf->rectangle(30,30,781.89,535.28);
if you want to find out more try and have allok at the attached pdf - but i like helping out people because this community has helped me out so much so fire the questions straight at me.hope i answered your question wp1
Regards,
chris
Hugo and all,
Are there any updates on this? I just wanted to know if this feature was still in progress or not.
thnx,
Ruben
It refers to files that do not exist, such as db/postgres7.sql and .php.
Is there a newer file I am unaware of.
I have a couple of questions.
1. Does anybody know how to attach different certificates based upon each quiz instead of having one certificate for the entire course?
2. How can I pass the quiz id in the certificate link that calls the view.php page for the certificate? This would allow me to have custom text for each certificate based upon the quiz that they took.
Thanks
We use a Certificate for numerous Moodle courses.
Try the Certificate module plugin which we have found to be the most reliable and flexible:
http://moodle.org/mod/data/view.php?d=13&rid=683
Stu
this module is not available anymore, is there a version for moodle 2.3 ?
Here is the link to the new certificate module plugin http://moodle.org/plugins/view.php?plugin=mod_certificate