public function get_course_module(event_interface $event) {
        if (!$event->get_course_module()) {
            return null;
        }

        $id = $event->get_course_module()->get('id');
        $name = $event->get_course_module()->get('modname');
        $key = $name . '_' . $id;

        if (!isset($this->coursemodules[$key])) {
            $this->coursemodules[$key] = get_coursemodule_from_instance($name, $id, 0, false, MUST_EXIST);
        }

        return $this->coursemodules[$key];
    }