Need to modify certificate text

Need to modify certificate text

by Bob Jeffery -
Number of replies: 15

Hi, Chardelle -

I'm a new moodle user (v 1.8) and have built a business video training course with practice quizes and a final quiz that generates your certificate upon the student passing.  I need to put different text in the "has completed the course" field and probably do it in two lines.  I don't know much about php coding but have tried unsuccessfully to find the so-called "statement" that tags the text "has completed the course".  I presume that I can modify it after I locate it.  So, where is the secret place I need to go to?  Or is there something else I need to do?  If I need to substitute two lines, is there a special character I need to use or do I use something like an HTML code such as <br> for line break?

Lastly, I'd also like to add on the certificate the name of the organization that the student works for.  So, I'd have to add a new field somehow and link it back to where the student initially enrolled and had imput that information.

I appreciate you help.  Thank you.

Bob

Average of ratings: -
In reply to Bob Jeffery

Re: Need to modify certificate text

by Chardelle Busch -
Picture of Core developers
Hi Bob,

I've just updated the certificate docs--you should find everything you need to know there: http://docs.moodle.org/en/Certificate_module#Customizing
In reply to Chardelle Busch

Re: Need to modify certificate text

by Bob Jeffery -

Hi, Chardelle -

Thanks for the info on customizing.  I went through my files and added text as outlined.  However, when I tried to run my moodle (as administrator), I was able to only get to the cover page with the available courses after logging in.  If I clicked on my course, I got a blank background.  Eventually, I copied, on my hard drive, all the files in my certificate directory and then deleted that directory.  Now, I can actually log in to see my course (again as administrator) and see the topic outline and all the lessons as I scroll down.  However, when I switch to "editing on", I can see only the topic outline.  All the lessons are hidden and inaccessible.  With "editing off", I can see the lessons again but am unable to edit, of course.  I feel as if I screwed up something but I have absolutely no idea where.  Any suggestions?

By the way, I did try Certificate Fat in between installations of your Certificate.  But I deleted Certificate Fat before reinstalling yours the second time.  That's the only thing that I can think of that may have changed a setting in some way.   I appreciate your feedback.

Bob

In reply to Bob Jeffery

Re: Need to modify certificate text

by Chardelle Busch -
Picture of Core developers
Well--that's goofy. I suggest first to uninstall and re-install. Make sure after you uninstall that all certificate tables have been deleted from your db--the FAT version is old and it's hard to say what problems it can cause in 1.9.

Then, for customizations, I suggest:

1. Try it on a local testing install first, if possible.
2. In Administration>>Server set debugging to maximum (to show any coding error messages).
3. After each change to the code (for example, after adding a new lang string to the certificate lang file), go to your course page and click on a certificate to test.

In reply to Chardelle Busch

Re: Need to modify certificate text

by Bob Jeffery -

With the help of a friend, I was finally able to restore my moodle back to its pre-hack point and will try to install the certificate again.  I'll update soon. Thnx.

In reply to Bob Jeffery

Re: Need to modify certificate text

by Bob Jeffery -

Chardelle -

I was able to generate a certificate with the added lines and formatting without problem now.  I think my moodle DB had been corrupted somehow with FAT Certificate, even though I thought I uninstalled it.  Those two certificate plug-ins don't mix at all!!

However, here's the more urgent problem.  I'm having difficulty sending out to the student the email with certificate attachment.  After the student passes the quiz and clicks on the Certificate activity, it goes to a page with a button "Review Your Certificate".  When clicking on that, it comes back with this error:

EPDF error: Unable to create output file: home/profitup/lms/uploaddata/3/moddata/certificate/1/13/

No email gets sent out.  I've checked in the "Issue Options" section on the edit page and I have "Yes" for "Save Certificate" and "Email" for "Delivery Options".  I don't know if it's something with just this plug-in or something that is more global in nature, because I'm also having a problem sending out email with another plug-in, Quiz Email Notification.  I've checked with that plug-in's developer and he's at a loss to know what might be causing it.  Any ideas?  I appreciate you time.  Thanks.

Bob

In reply to Bob Jeffery

Re: Need to modify certificate text

by Clinton Randolph -

Bob,

If the name of your course has any "/" in it, the pdf file cannot be created.  I had the same problem.  The course name has to follow standard file name convention rules.

In reply to Bob Jeffery

Re: Need to modify certificate text

by Chardelle Busch -
Picture of Core developers
Like Clinton mentions, you may be having problems with the filename (the name of the certificate cannot have any slashes), and if the file isn't saved, it can't be emailed. A clean filename function was recently added, please check the top of the lib.php file and see if it is the latest code:
<?php //$Id: lib.php,v 1.21.2.16 2008/06/27 17:47:56 crbusch Exp $

If not, then update and see if that fixes it. As for emailing, do other emails go out such as when a user enrolls in a course? Do you have debugging on when you attempt an email and see any errors? It's possible the Quiz email notification is using outdated code (I've also just recently had to update the email teachers function)--or, if it runs off of cron (the certificate emailing does not rely on cron) then perhaps your site's cron is not set up properly--if forum posts go out (they also run off of cron) then you can know your cron job is okay.

In reply to Chardelle Busch

Re: Need to modify certificate text

by Bob Jeffery -
Chardelle & Clinton -
I have no "/" (slash) or any other non-standard characters in the name. And yes I do have the email set to "save".

I did check the lib.php and my latest version is:
<?php //$Id: lib.php,v 1.3.2.9 2008/06/23 16:07:54 crbusch Exp $
The latest one you mention is:
<?php //$Id: lib.php,v 1.21.2.16 2008/06/27 17:47:56 crbusch Exp $
That one is for moodle v 1.9, not moodle v 1.8.
Are you suggesting that I substitute this lib.php for the one I'm currently using, even though it's for a different moodle version?

Regarding your question about other emails going out: Yes, when a new user (student) enrolls, an email does go out to that user's email address.
I ran debugging to see what message gets generated after a student completes the quiz and tries to get their certificate. This is the message that results:

Notice: Undefined variable: filesafe in /home/profitup/public_html/lms/mod/certificate/view.php on line 127

Warning: fopen(/home/profitup/lms/uploaddata/3/moddata/certificate/1/19/) [function.fopen]: failed to open stream: Is a directory in /home/profitup/public_html/lms/lib/fpdf/fpdf.php on line 1046
FPDF error: Unable to create output file: /home/profitup/lms/uploaddata/3/moddata/certificate/1/19/

I appreciate your follow-up. Thanks.
Bob
In reply to Bob Jeffery

Re: Need to modify certificate text

by Chardelle Busch -
Picture of Core developers
Thanks for debugging Bob. Yikes--my bad.

Yes you have the correct up-to-date lib. However, I forgot a line of code when updating the view.php file blush. It is correct now in cvs--you can wait awhile to download the latest file-- or you can add the line yourself in view.php at line 127 add the line in red:

$filesafe = clean_filename($certificate->name.'.pdf');
$file = $CFG->dataroot.'/'.$course->id.'/moddata/certificate/'.$certificate->id.'/'.$USER->id.'/'.$filesafe;



In reply to Chardelle Busch

Re: Need to modify certificate text

by Bob Jeffery -
Thanks, Chardelle, for the extra line code for the view.php file.
IT WORKS!! big grin
One small glitch remaining, however. When the student completes the quiz and clicks on the "Get Certificate" button, the following message appears (even though the Certificate does indeed get emailed out):

Warning: Cannot modify header information - headers already sent by (output started at
/home/profitup/public_html/lms/lib/moodlelib.php:3513) in
/home/profitup/public_html/lms/lib/fpdf/fpdf.php on line 1022
FPDF error: Some data has already been output to browser, can't send PDF file

It would be nice if the message were a bit more positive, like, "Congratulations! Your Certificate of Achievement will be emailed to you shortly."

Any idea on what is going on here? But it feels good to know we're getting closer!

Bob

In reply to Bob Jeffery

Re: Need to modify certificate text

by Chardelle Busch -
Picture of Core developers
I don't have that version of moodlelib.php handy, could you post the aforementioned line from that file for me (line 3513).


In reply to Chardelle Busch

Re: Need to modify certificate text

by Bob Jeffery -
Here are the lines from both files:

moodleliv.php

3513 if (filetype($fullfile) == 'dir') {
3514 $size += get_directory_size($fullfile, $excludefile);


fpdf.php

1019 function _dochecks()
1020 {
1021 //Check for locale-related bug
1022 if(1.1==1)
1023 $this->Error('Don\'t alter the locale before including class file');
In reply to Bob Jeffery

Re: Need to modify certificate text

by Chardelle Busch -
Picture of Core developers
Hi Bob,

I revived an old 1.8.2+ test server and I can't duplicate this error message thoughtful.

Normally, the window that opens with this message would open the certificate pdf. My only suggestion is to maybe upgrade either to the latest stable 1.8 or to 1.9.

By the way, I also tested this with slashes, symbols in both the certificate name and the course name and had no problems.
In reply to Bob Jeffery

Re: Need to modify certificate text

by Stelios Tserkezis -
TCPDF error: Could not include font definition file
Please help. What does is this error message say????
In reply to Stelios Tserkezis

Re: Need to modify certificate text

by Chardelle Busch -
Picture of Core developers
I've just verified that the Unicode landscape type works in 1.9.
What is the certificate version number you are using?