public static function plan_viewed($planorid) {
        static::require_enabled();
        $plan = $planorid;
        if (!is_object($plan)) {
            $plan = new plan($plan);
        }

        // First we do a permissions check.
        if (!$plan->can_read()) {
            $context = context_user::instance($plan->get('userid'));
            throw new required_capability_exception($context, 'moodle/competency:planview', 'nopermissions', '');
        }

        // Trigger a template viewed event.
        \core\event\competency_plan_viewed::create_from_plan($plan)->trigger();

        return true;
    }