Browse Source

Adicionando evento de criação de certificado

master
Matheus Garcia 6 years ago
parent
commit
5068770c31
  1. 32
      classes/event/certificate_created.php
  2. 14
      lib.php

32
classes/event/certificate_created.php

@ -0,0 +1,32 @@
<?php
// This file is part of the Certificate module for Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* This page lists all the instances of certificate in a particular course
*
* @package mod
* @subpackage certificate
* @copyright Mark Nelson <markn@moodle.com>
* @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 {
}

14
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";

Loading…
Cancel
Save