From 5068770c31215a2ab4ddb3ea12b5a91bf4bcb576 Mon Sep 17 00:00:00 2001 From: Matheus Garcia Date: Thu, 6 Jun 2019 16:22:28 -0300 Subject: [PATCH] =?UTF-8?q?Adicionando=20evento=20de=20cria=C3=A7=C3=A3o?= =?UTF-8?q?=20de=20certificado?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- classes/event/certificate_created.php | 32 +++++++++++++++++++++++++++ lib.php | 14 ++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 classes/event/certificate_created.php diff --git a/classes/event/certificate_created.php b/classes/event/certificate_created.php new file mode 100644 index 0000000..adb94b3 --- /dev/null +++ b/classes/event/certificate_created.php @@ -0,0 +1,32 @@ +. + +/** + * This page lists all the instances of certificate in a particular course + * + * @package mod + * @subpackage certificate + * @copyright Mark Nelson + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +namespace mod_certificate\event; + +defined('MOODLE_INTERNAL') || die(); + +class certificate_created extends \core\event\base { +} diff --git a/lib.php b/lib.php index dda5309..743142c 100644 --- a/lib.php +++ b/lib.php @@ -348,6 +348,7 @@ function certificate_get_post_actions() { */ function certificate_cron () { global $DB; + $sql = "select distinct cm.id as cmid, c.*, ce.id as certificateid, ce.name as certificatename from {certificate} ce inner join {course} c on c.id = ce.course @@ -379,6 +380,19 @@ function certificate_cron () { (certificate_get_course_time($course->id) >= ($certificate->requiredtime * 60))) { echo " generating issue certificate for {$student->firstname} {$student->lastname}..."; $certrecord = certificate_get_issue($course, $student, $certificate, $cm); + + $context = context_module::instance($cm->id); + + $event = \mod_certificate\event\certificate_created::create(array( + 'objectid' => $certrecord->id, + 'context' => $context, + 'other' => $certrecord) + ); + //$event->add_record_snapshot('course_modules', $this->cm); + //$event->add_record_snapshot('attendance_sessions', $session); + //$event->add_record_snapshot('attendance_log', $record); + $event->trigger(); + echo " Done! Certificate {$certrecord->code} generated!\n"; } else { echo " {$student->firstname} {$student->lastname} has not required course time. Skiped!\n";