protected function plugin_extend_coursemodule_validation($data) {
        $errors = array();

        $callbacks = get_plugins_with_function('coursemodule_validation', 'lib.php');
        foreach ($callbacks as $type => $plugins) {
            foreach ($plugins as $plugin => $pluginfunction) {
                // We have exposed all the important properties with public getters - the errors array should be pass by reference.
                $pluginerrors = $pluginfunction($this, $data);
                if (!empty($pluginerrors)) {
                    $errors = array_merge($errors, $pluginerrors);
                }
            }
        }
        return $errors;
    }