/** * Inserts final user data when a certificate is created. * * @param stdClass $course * @param stdClass $certificate * @param stdClass $certrecord * @param stdClass $cm */ function certificate_issue($course, $certificate, $certrecord, $cm) { global $USER, $DB; if ($certificate->printgrade) { if ($certificate->printgrade == 1) { $grade = certificate_print_course_grade($course); } else { if ($certificate->printgrade > 1) { $grade = certificate_print_mod_grade($course, $certificate->printgrade); } } if ($certificate->gradefmt == 1) { $certrecord->reportgrade = $grade->percentage; } if ($certificate->gradefmt == 2) { $certrecord->reportgrade = $grade->points; } if ($certificate->gradefmt == 3) { $certrecord->reportgrade = $grade->letter; } } $date = certificate_generate_date($certificate, $course); $certrecord->certdate = $date; $DB->update_record('certificate_issues', $certrecord); certificate_email_teachers($course, $certificate, $certrecord, $cm); certificate_email_others($course, $certificate, $certrecord, $cm); }
function certificate_date_format($type, $certrecord) { global $certificate; if ($certrecord) { $certdate = $certrecord->{$type}; } else { $certdate = certificate_generate_date($certificate, $course); } $datestrings = array("%DD", "%dd", "%ss", "%MS", "%YY", "%yy", "%mm", "%MM"); $datereplace = array(date('d', $certdate), date('j', $certdate), date('S', $certdate), userdate($certdate, "%B"), strftime('%Y', $certdate), strftime('%y', $certdate), date('n', $certdate), date('m', $certdate)); $certificatedate = str_replace($datestrings, $datereplace, $certificate->datefmt); return $certificatedate; }
<?php if (!defined('MOODLE_INTERNAL')) { die('Direct access to this script is forbidden.'); /// It must be included from view.php in mod/tracker } // Date formatting - can be customized if necessary $certificatedate = ''; if ($certrecord->certdate > 0) { $certdate = $certrecord->certdate; } else { $certdate = certificate_generate_date($certificate, $course); } if ($certificate->printdate > 0) { if ($certificate->datefmt == 1) { $certificatedate = str_replace(' 0', ' ', strftime('%B %d, %Y', $certdate)); } if ($certificate->datefmt == 2) { $certificatedate = date('F jS, Y', $certdate); } if ($certificate->datefmt == 3) { $certificatedate = str_replace(' 0', '', strftime('%d %B %Y', $certdate)); } if ($certificate->datefmt == 4) { $certificatedate = strftime('%B %Y', $certdate); } if ($certificate->datefmt == 5) { $timeformat = get_string('strftimedate'); $certificatedate = userdate($certdate, $timeformat); } }
function certificate_issue($course, $certificate, $certrecord, $cm) { if ($certificate->printgrade > 0) { if ($certificate->printgrade == 1) { $grade = certificate_print_course_grade($course); } else { if ($certificate->printgrade > 1) { $grade = certificate_print_mod_grade($course, $certificate->printgrade); } } if ($certificate->gradefmt == 1) { $certrecord->reportgrade = addslashes($grade->percentage); } if ($certificate->gradefmt == 2) { $certrecord->reportgrade = addslashes($grade->points); } if ($certificate->gradefmt == 3) { $certrecord->reportgrade = addslashes($grade->letter); } } $date = certificate_generate_date($certificate, $course); $certrecord->certdate = $date; update_record('certificate_issues', addslashes_object($certrecord)); certificate_email_teachers($course, $certificate, $certrecord, $cm); certificate_email_others($course, $certificate, $certrecord, $cm); }