Certificate Module for 1.5 Beta

Certificate Module for 1.5 Beta

by David T. Cannon -
Number of replies: 27

I am releasing a beta version of the certificate module for testing.

Warning: This is a pre-release and should not be used on production systems.

  • Requires: acroreader/acrobat, javascript.
  • The date function currently prints the date the certificate is printed, this will be changed soon.
  • Sample artwork is included for demonstration.
  • Please read /doc directory for information on customization.

Download (1.7 mb) here: http://whatalife.com/certificate.zip

Dave.

Average of ratings: -
In reply to David T. Cannon

Re: Certificate Module for 1.5 Beta

by Chardelle Busch -
Picture of Core developers
Okay David,

I don't think it was tooo bad for a first attempt.  But there are some problems.

(Note:  you zipped up several temporary files too)

1.  After adding a certif I got this error when opening it: 

FPDF error: Image file has no extension and no type was specified: /home/training/public_html/mod/certificate/pix/watermarks/

2.  I then deleted the pix folder so I could test it more.  The certif did open, but the lang strings didn't show (just the   )--maybe there is a problem with the "type" code or this could be related to other problems.

3.  The certif did not accept any changes, i.e., the options I chose were not saved (again this might be because of other problems).  If this helps any, when I clicked to edit I got these errors (of course remember this is after deleted the pix)

Warning: opendir(/home/training/public_html/mod/certificate/pix/borders): failed to open dir: No such file or directory in /home/training/public_html/mod/certificate/mod.html on line 57

Warning: ksort() expects parameter 1 to be array, null given in /home/training/public_html/mod/certificate/mod.html on line 70

Warning: array_unshift(): The first argument should be an array in /home/training/public_html/mod/certificate/mod.html on line 71

Warning: opendir(/home/training/public_html/mod/certificate/pix/watermarks): failed to open dir: No such file or directory in /home/training/public_html/mod/certificate/mod.html on line 78

Warning: ksort() expects parameter 1 to be array, null given in /home/training/public_html/mod/certificate/mod.html on line 89

Warning: array_unshift(): The first argument should be an array in /home/training/public_html/mod/certificate/mod.html on line 90

Warning: opendir(/home/training/public_html/mod/certificate/pix/signatures): failed to open dir: No such file or directory in /home/training/public_html/mod/certificate/mod.html on line 94

Warning: ksort() expects parameter 1 to be array, null given in /home/training/public_html/mod/certificate/mod.html on line 105

Warning: array_unshift(): The first argument should be an array in /home/training/public_html/mod/certificate/mod.html on line 106

Warning: opendir(/home/training/public_html/mod/certificate/pix/seals): failed to open dir: No such file or directory in /home/training/public_html/mod/certificate/mod.html on line 112

Warning: ksort() expects parameter 1 to be array, null given in /home/training/public_html/mod/certificate/mod.html on line 123

Warning: array_unshift(): The first argument should be an array in /home/training/public_html/mod/certificate/mod.html on line 124

In reply to Chardelle Busch

Re: Certificate Module for 1.5 Beta

by David T. Cannon -

Hmmmm. I deleted my module. downloaded, and reinstalled and it worked OK.

Deleting the /pix folder will definately blow things up, since there is no error checking yet, and those files are needed.

Be sure you delete previous installation, since the DB schema has changed.

I should also note, This module makes no changes to the existing DB tables. It works independantly of the existing Moodle tables.

I will look into what else might cause this problem.

Dave.

In reply to Chardelle Busch

Re: Certificate Module for 1.5 Beta

by David T. Cannon -

Hmmmm. I deleted my module. downloaded, and reinstalled and it worked OK.

Deleting the /pix folder will definately blow things up, since there is no error checking yet, and those files are needed.

Be sure you delete previous installation, since the DB schema has changed.

I should also note, This module makes no changes to the existing DB tables. It works independantly of the existing Moodle tables.

I will look into what else might cause this problem.

Dave.

In reply to David T. Cannon

Re: Certificate Module for 1.5 Beta

by Chardelle Busch -
Picture of Core developers
You're stuttttering.

Yes, that was it, duh.  I had not deleted the old certificate module first.  I just deleted everything and started over and no error messages.  I'll do some heavy testing tomorrow and let you know how it goes.smile
In reply to Chardelle Busch

Re: Certificate Module for 1.5 Beta

by Ralph Blakeslee -

Is that what is it called? Stuttering?  It usually happens to me when I am answering the phone, drinking my coffee, typing a memo, giving direction to staff, responding to six emails and writing a response to a forum board! surprise

Ralph

In reply to Ralph Blakeslee

Re: Certificate Module for 1.5 Beta

by Chardelle Busch -
Picture of Core developers
Oh Ralph...wink

David, everything looks great. I tested it with the activity locking and it worked fine. I found just one little thing, in mod.html, line 47 should be changed to: $dateoptions[1] = "January 1st, 2000";

I also added a 4th date option, January 1, 2000.

I had a really good idea for another option. Since you have added the fantastic ability to have a certificate show the grade of an activity, wouldn't it be nice to couple that with printing the name of that activity, rather than the course name?

For example, if someone needs to have a printed "certificate" of taking a quiz and their score to give to their supervisor: Joe Smith has completed the Creating Mysql Datatables Test, Grade: 85.

I don't know if you would want to have an added option like Activity Name maybe, and the course would be one option, but I don't know if you would want to list all of the activities in course. Did you figure out how to print the total points from the gradebook?  Maybe if the grade of an activity is added, then it automatically inserts the activity name with the grade?  And if the total grade is an option, then it would print the course name?



In reply to Chardelle Busch

Re: Certificate Module for 1.5 Beta

by David T. Cannon -

That's great everything worked for you.

I did notice that the "lines" border does not allow you to select a color, so I will fix that.

I will add another date format line item. I will also think about how to implement the grade name as mentioned above.

I will start on commenting, error checking, and cleaning things up in the php.

Dave.

In reply to David T. Cannon

Re: Certificate Module for 1.5 Beta

by David T. Cannon -

I should note:

  1. Since I am using this with Activity locking, I have that moduke library referenced. If you are not using the AL module, you can comment out the 2 lines that will cause an error meessage.
  2. After installing, click on settings and turn auto-preview on.

Dave.

In reply to David T. Cannon

Re: Certificate Module for 1.5 Beta

by Chardelle Busch -
Picture of Core developers
Hi David,

I just noticed that the plain seal I had been using (the blue one you've added to this) clashes horribly with the colored borders. Here's a new one that is a more "gold" color, I also changed the image size to match the code.
Attachment Plain.png
In reply to Chardelle Busch

Re: Certificate Module for 1.5 Beta

by Chardelle Busch -
Picture of Core developers
David,

Would you change the spelling of achievement in the language file.

Also, would it be possible to have the certificates open in a new window?

Thx
In reply to Chardelle Busch

Re: Certificate Module for 1.5 Beta

by David T. Cannon -

OK, changed the plain seal, corrected the spelling error.

Should open in a new wimdow be an option? Where would you have it open in a new window? when in the class as a student? For preview?

Dave.

In reply to David T. Cannon

Re: Certificate Module for 1.5 Beta

by Chardelle Busch -
Picture of Core developers
I asked this because when I add a pdf to a course, etc., I always add it in a new window so students can look at it print it save it, whatever, then close that window to get back to what they were doing--this just seems easier for users to do rather than using the back button. 


In reply to Chardelle Busch

Re: Certificate Module for 1.5 Beta

by Chardelle Busch -
Picture of Core developers
By the way David,

Did you see the code that was posted at the very bottom of the original certificate discussion regarding adding a certificate date?
http://moodle.org/mod/forum/discuss.php?d=9766
In reply to David T. Cannon

Re: Certificate Module for 1.5 Beta

by Don Farion -
First off David, thank you so much for all your effort in creating this very usefull version of the certificate module. 

I spent the weekend playing with your beta version and it definitely has possibilities.  If you install the module and turn debug on you will see a number of messages relating to undeclared variables etc.  This may also be related to the fact that the New certificate page seems to hang and takes a long time to load.  You may want to look into this before you go to far down this road.  Once again thanks for all of the time you spend making life easier for us non-programmers.
In reply to Don Farion

Re: Certificate Module for 1.5 Beta

by David T. Cannon -

Good catch. It was mearly alot of lazyiness, not declaring variables.

I patched that up and will release again in another day.

Dave.

In reply to David T. Cannon

Re: Certificate Module for 1.5 Beta

by Chardelle Busch -
Picture of Core developers
Hi David,

Another thing I have noticed is that the certificate does not add a report to the user's activity reports (I tried adding some code taken from the resource mod but couldn't get it to work), and it also does not get the green check from activity locking for being viewed. 

I thought this was a log problem and I did make a change to view.php that made it so the cmid would show up in the logs (it was showing as 0 before), but that didn't help.

change to view.php:          add_to_log($course->id, "certificate", "view", "view.php?id={$cm->id}", $certificate->id, $cm->id);


Code I tried adding to lib to get it to show the views in the activity reports (didn't work-except the Never Seen string shows up, of course)

function certificate_user_outline($course, $user, $mod, $certificate) {
    if ($logs = get_records_select("log", "userid='$user->id' AND module='certificate'
                                           AND action='view' AND info='$certificate->id'", "time ASC")) {

        $numviews = count($logs);
        $lastlog = array_pop($logs);

        $result->info = get_string("numviews", "", $numviews);
        $result->time = $lastlog->time;

        return $result;
    }
    return NULL;
}


function certificate_user_complete($course, $user, $mod, $certificate) {
    global $CFG;

    if ($logs = get_records_select("log", "userid='$user->id' AND module='certificate'
                                           AND action='view' AND info='$certificate->id'", "time ASC")) {
        $numviews = count($logs);
        $lastlog = array_pop($logs);

        $strmostrecently = get_string("mostrecently");
        $strnumviews = get_string("numviews", "", $numviews);

        echo "$strnumviews - $strmostrecently ".userdate($lastlog->time);

    } else {
        print_string("neverseen", "resource");
    }
}

In reply to Chardelle Busch

Re: Certificate Module for 1.5 Beta

by David T. Cannon -

OK Chardelle,

I will add the logging calls, dont know why they were not in there, and will update the download by Monday.

Dave.

In reply to Chardelle Busch

Re: Certificate Module for 1.5 Beta

by David T. Cannon -

change to view.php:          add_to_log($course->id, "certificate", "view", "view.php?id={$cm->id}", $certificate->id, $cm->id);

That should be all ya need for the AL module to notice it, hmmm. Not sure about the braces there though.

Dave.

In reply to David T. Cannon

Re: Certificate Module for 1.5 Beta

by Chardelle Busch -
Picture of Core developers
Thanks David,

I just copied that code from something else but I forget (resource maybe?).  Like I said, the id now shows up, but nothing shows up in the info column in the db--so I thought maybe that is why it isn't showing up as viewed for activity locking?
In reply to Chardelle Busch

Re: Certificate Module for 1.5 Beta

by Chardelle Busch -
Picture of Core developers
Hi David,

Someone has brought to my attention the idea that a student could complete the requirements to get a certificate, then go to their profile, change their name to someone else's, and print out a certificate for them too.  Would it be possible to have an "attempts" option similar to the lesson mod, or quiz, where you could limit the times a user can view a certificate?
In reply to Chardelle Busch

Re: Certificate Module for 1.5 Beta

by David Mack -
Wouldn't this problem be solved by displaying a verifiable certificate id number, rather than limiting the number of times a user can view their own certificate?
In reply to David Mack

Re: Certificate Module for 1.5 Beta

by David T. Cannon -

I have a solution for this, and should post the update some time later tonight.

Dave.

In reply to Chardelle Busch

Re: Certificate Module for 1.5 Beta

by David T. Cannon -

Chardelle,

I am not familiar with the log format. What should show up in the info column?

Dave.

In reply to David T. Cannon

Re: Certificate Module for 1.5 Beta

by Julian Ridden -
Thanks for this great piece of ode guys/gals.

Having a small prop with it.

The actual certificate is working fine. When created all features are workingas they should, and students can see the finished PDF's.

My issue is the preview is not working. Just shows a "page not found" in the preview pane.

Any ideas as to why?
In reply to Julian Ridden

Re: Certificate Module for 1.5 Beta

by David T. Cannon -

Julian,

Have not seen this. Please tell me you server OS/web server. Works fine on my Linux/ Apache, but I have not tested it on Windows.

Dave.