Print group name on Certificate, Moodle 2.2

Print group name on Certificate, Moodle 2.2

by Grant Carruthers -
Number of replies: 3

Hi all,

I'm having some difficulty in printing the group name onto the Certificate. We are running Moodle 2.2.

Previously we ran 1.9 and I added the following code to the certificate.php file:

//Find current group
$currentgroup = get_current_group($course->id);
$group = get_record('groups', 'id', $currentgroup);
$groupname=$group->name;

along with  
//Print the group name
cert_printtext(70, 345, 'C', 'Helvetica', '', 12, utf8_decode($groupname));

and that worked. However, it doesn't seem to be working in 2.2. I've used this:

//Find group name
$currentgroup=get_current_group($course->id);
$group=$DB->get_record('groups', 'id', $currentgroup);
$groupname=$group->name;

and this:
//Print the group name
certificate_print_text($pdf, $x + 60, $y + 305, 'C', 'Helvetica', '', 12, utf8_decode($groupname));

but I get errors. I'm not a PHP expert, but could anyone help me with this?
Thanks!

Grant Carruthers

Average of ratings: -
In reply to Grant Carruthers

Re: Print group name on Certificate, Moodle 2.2

by Grant Carruthers -

Surely someone must have come across this one before? Perhaps it has something to do with the get_record changing to $DB ->get record in Moodle 2??

Any ideas would be welcomed!

many thanks

Grant

In reply to Grant Carruthers

Re: Print group name on Certificate, Moodle 2.2

by Mark Nelson -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Testers

Hi Grant,

I am just back from a month long holiday in Canada and have a huge backlog of issues to deal with. Sorry if you have been waiting for a response for a while.

Please try "$group = $DB->get_record('groups', array('id' => $currentgroup));" (without quotes) instead.

Regards,

Mark

In reply to Mark Nelson

Re: Print group name on Certificate, Moodle 2.2

by Grant Carruthers -

Hi Mark,

my apologies for the late reply this time. Thank you for that, it's now working perfectly.

In the certificate.php file in the mod/certificate/type/your-type-name folder' I added:

$currentgroup=get_current_group($course->id);
$group = $DB->get_record('groups', array('id' => $currentgroup));
$groupname=$group->name;

around line 80 and then added:

certificate_print_text($pdf, $x + 80, $y + 90, 'L', 'Helvetica', '', 12, utf8_decode($groupname));


 on line 104.

best wishes

Grant