Diploma / certificate

Diploma / certificate

by Hugo Salgado -
Number of replies: 60
Hi.
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

Average of ratings: -
In reply to Hugo Salgado

Re: Diploma / certificate

by Bryan Williams -

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. 

In reply to Bryan Williams

Re: Diploma / certificate

by Hugo Salgado -
My idea is to generate a pdf with a custom logo, title and signature. The name of the student and course will be obtained from the database.
Thanks for your feedback!

In reply to Bryan Williams

Re: Diploma / certificate

by David Lamotte -
Rather than create another seperate module, why not integrate the Certificate function into the grade book ?

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
In reply to Hugo Salgado

Re: Diploma / certificate

by Martin Dougiamas -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
Good on you, Hugo. "certificate" seems a good name.

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.  smile
In reply to Martin Dougiamas

Re: Diploma / certificate

by Hugo Salgado -
Ok, so lets go with the details smile

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

In reply to Hugo Salgado

Re: Diploma / certificate

by Martin Dougiamas -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
I definitely think it should be an activity module.  The reason is that you might want different certificates for different reasons.  This will allow you to place the certificate anywhere within the course.

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.  wink

So if you get a basic module done we can start linking it up properly.  big grin
In reply to Martin Dougiamas

Re: Diploma / certificate

by Andrea Bicciolo -

Certificates, activity locking and conditional activities would be great added value! . If you ever need testing count me on smile. For certificates would be very nice to have a custom, automated, optional final grade printed on it, along with  signatures and custom graphics.

In reply to Martin Dougiamas

Re: Diploma / certificate

by Bryan Williams -
This sounds like an ideal plan. Hope that provisions are made for courses that don't end with a grade, rather just completion of a final activity.
In reply to Hugo Salgado

Re: Diploma / certificate

by Paul Evans -
Is there anywhere I can grab a cp of what you have so far to play with Hugo?

Maybe I can help out as I need one of these.
In reply to Paul Evans

Re: Diploma / certificate

by Hugo Salgado -
I think that my work isn't mature enough to be included in the
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

In reply to Hugo Salgado

Re: Diploma / certificate

by Paul Evans -
>cvs, but i can send you a copy by email of what i've done, if this >can help you for an emergency

Yes please: pevans@catholic.org

It's not an emergency until next month smile, but it will be one less thing for me to write. Thanks very much.
In reply to Paul Evans

Re: Diploma / certificate

by Robert Lefebvre -
Hello Paul,

Would you please send me a copy also?

Thank you
In reply to Robert Lefebvre

Re: Diploma / certificate

by Paul Evans -
I haven't rx'd it yet from Hugo as I suppose he is busy.

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.



In reply to Paul Evans

Re: Diploma / certificate

by Chris Byrnes -

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.

In reply to Chris Byrnes

Re: Diploma / certificate

by Hugo Salgado -
Hello Chris.
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

In reply to Hugo Salgado

Re: Diploma / certificate

by Paul Evans -
I have been trying out Hugo's early efforts and I'm *very* happy with it.

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?
In reply to Hugo Salgado

Re: Diploma / certificate

by Marilyn Fleming -

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.

In reply to Hugo Salgado

Re: Diploma / certificate

by Jay S -
Do you know of anyone who has linked the certificate to the final grade.

Also can you link the certificate to more than one activity
In reply to Hugo Salgado

Re: Diploma / certificate

by Jordan Ilott -
I have recently been hired to develop this for Moodle, along with adding a bit of information to the user registration.  I'm just finalizing my plans for the project.  I'll keep everyone posted.
In reply to Jordan Ilott

Re: Diploma / certificate

by Jordan Ilott -

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

In reply to Jordan Ilott

Re: Diploma / certificate

by Jordan Ilott -

I guess you might want my email address to send me that.  It's been one of those days.  smile

jordanilott@shaw.ca

In reply to Jordan Ilott

Re: Diploma / certificate

by Hugo Salgado -
I asked today to Martin for an account on the CVS repository, and that's working.

I will put tonight (in about 5 hours) my module and i'll post here the instructions.

Thanks for your interest in my module smile

Hugo

In reply to Jordan Ilott

Re: Diploma / certificate

by Jay S -
That is great news. When is a realistic release date.

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.
In reply to Jay S

Re: Diploma / certificate

by Matt Grimm -
I have patched in support for a static completion date, but I'm something of a newbie when it comes to development for Moodle. I've followed the coding guidelines to the best of my knowledge, but I don't know the procedure for posting my code to the forums.

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.
In reply to Hugo Salgado

Re: Diploma / certificate

by Hugo Salgado -
Ok, the first version is up in the CVS, in contrib/certificate

Hugo.

In reply to Hugo Salgado

Re: Diploma / certificate

by W Page -
Hello Hugo!

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
Attachment certif_display_01.gif
In reply to W Page

Re: Diploma / certificate

by Hugo Salgado -
  • 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
Ok, good idea.


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

In reply to Hugo Salgado

Re: Diploma / certificate

by Chardelle Busch -
Picture of Core developers

Hi Hugo,

I installed your certificate module today.  It is really neat.  A couple of comments:

  1. 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?
  2. Would there be any way to add the date to the certificate?  That would be really cool.
  3. 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

In reply to Chardelle Busch

Re: Diploma / certificate

by Chris Byrnes -

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

In reply to Chris Byrnes

Re: Diploma / certificate

by Floyd Collins -

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.

In reply to Floyd Collins

Re: Diploma / certificate

by Hugo Salgado -
Yes, my plan right now is to store both signature images individually, one for
each "certificate".
But i think that the image format must be png. Jpeg is for photographs, and png for drawings... so...

Hugo

In reply to Hugo Salgado

Re: Diploma / certificate

by Chardelle Busch -
Picture of Core developers

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 smile.

Chardelle

Attachment certif.gif
In reply to Chris Byrnes

Re: Diploma / certificate

by Chardelle Busch -
Picture of Core developers

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

In reply to Chardelle Busch

Re: Diploma / certificate

by Chris Byrnes -

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!

In reply to Chris Byrnes

Re: Diploma / certificate

by Chardelle Busch -
Picture of Core developers

Hi Chris,

Thanks, that change takes out the 0.  And no hassles!  That's what testing is all aboutsmile.

Chardelle

In reply to Chardelle Busch

Re: Diploma / certificate

by Chardelle Busch -
Picture of Core developers
Here is an icon for the certificate module if anyone is interested.
Attachment certificate.gif
Average of ratings: Useful (1)
In reply to Chardelle Busch

Re: Diploma / certificate

by Martin Dougiamas -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
I've put this icon into CVS, Hugo!
In reply to Martin Dougiamas

Re: Diploma / certificate

by Hugo Salgado -
Thanks Martin.
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
In reply to Hugo Salgado

Re: Diploma / certificate

by Chardelle Busch -
Picture of Core developers

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

In reply to Chardelle Busch

Re: Diploma / certificate

by Nicolas Martignoni -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators
Hi Chardelle,

Here is a border.png file a little smaller (228 Ko).

Cheers
Nicolas
Attachment border.png
In reply to Hugo Salgado

Re: Diploma / certificate

by Nicolas Martignoni -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators
Hi Hugo,

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
In reply to Nicolas Martignoni

Re: Diploma / certificate

by Chardelle Busch -
Picture of Core developers

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

Attachment certifblock.gif
In reply to Hugo Salgado

Re: Diploma / certificate

by Chris Byrnes -

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

In reply to Chris Byrnes

Re: Diploma / certificate

by Chardelle Busch -
Picture of Core developers

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.smile  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

In reply to Chardelle Busch

Re: Diploma / certificate

by Chris Byrnes -

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

Attachment cert.jpg
In reply to Chris Byrnes

Re: Diploma / certificate

by W Page -
Hi Everyone!!

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. wink  Or, does Hugo plan to do it??

Chris  do you have time to make up an Instruction Guide for this hack of a hack.

WP1
In reply to W Page

Re: Diploma / certificate

by Chris Byrnes -

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

In reply to Hugo Salgado

Re: Diploma / certificate

by Ruben Fonseca -

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

In reply to Ruben Fonseca

Re: Diploma / certificate

by Jay S -
I downloaded the certificate zip. I'm reading the readme file and it is out of date.

It refers to files that do not exist, such as db/postgres7.sql and .php.

Is there a newer file I am unaware of.
In reply to Ruben Fonseca

Re: Diploma / certificate

by Sean Pearson -

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

In reply to Hugo Salgado

Re: Diploma / certificate

by Corvin Adkins -
is this script/extension available anymore? if so where? I am looking for something like this.
In reply to Corvin Adkins

Re: Diploma / certificate

by Stuart Mealor -
Hi Corvin

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