Event is not triggered

Event is not triggered

by Tara Meyer -
Number of replies: 0

Hello everyone, 

I want to create a new event that inherits from course_module_created and supplies the content. I need the content for further processing, which takes place in lib.php. 


This is my events.php in db 

<?php

defined('MOODLE_INTERNAL') || die();

$observers = array(
        array(
          'eventname' => '\mod_testevent\event\course_module_created',
          'includefile' => '/mod/testevent/lib.php',
          'callback'    => 'event_module_created_call_back',
        )
      );

This is my course_module_created.php in classes/event

<?php
/**
 * Event to be triggered when a new course module is created.
 *
 * @package    mod_testevent
 * @copyright  2013 Ankit Agarwal
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later.
 */
namespace mod_testevent\event;
defined('MOODLE_INTERNAL') || die();

/**
 * The mod_page course module viewed event class.
 *
 * @package    mod_testevent
 * @since      Moodle 2.6
 * @copyright  2013 Ankit Agarwal
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */

class course_module_created extends \core\event\course_module_created {

    public static final function create_from_cm1($cm, $modcontext = null) {
        if (empty($modcontext)) {
            $modcontext = \context_module::instance($cm->id);
        }
        $event = static::create(array(
            'context'  => $modcontext,
            'objectid' => $cm->id,
            'other'    => array(
                'modulename' => $cm->modname,
                'instanceid' => $cm->instance,
                'name'       => $cm->name,
                'content'    => $cm->content,
            )
        ));
        return $event;
    }
}

In the lib.php I want to access the content. 

Thanks in advance

Average of ratings: -