public static function create_plan(stdClass $record) {
        global $USER;
        static::require_enabled();
        $plan = new plan(0, $record);

        if ($plan->is_based_on_template()) {
            throw new coding_exception('To create a plan from a template use api::create_plan_from_template().');
        } else if ($plan->get('status') == plan::STATUS_COMPLETE) {
            throw new coding_exception('A plan cannot be created as complete.');
        }

        if (!$plan->can_manage()) {
            $context = context_user::instance($plan->get('userid'));
            throw new required_capability_exception($context, 'moodle/competency:planmanage', 'nopermissions', '');
        }

        $plan->create();

        // Trigger created event.
        \core\event\competency_plan_created::create_from_plan($plan)->trigger();
        return $plan;
    }
public static function create_plan(stdClass $record) {
        global $USER;
        static::require_enabled();
        $plan = new plan(0, $record);

        if ($plan->is_based_on_template()) {
            throw new coding_exception('To create a plan from a template use api::create_plan_from_template().');
        } else if ($plan->get('status') == plan::STATUS_COMPLETE) {
            throw new coding_exception('A plan cannot be created as complete.');
        }

        if (!$plan->can_manage()) {
            $context = context_user::instance($plan->get('userid'));
            throw new required_capability_exception($context, 'moodle/competency:planmanage', 'nopermissions', '');
        }

        $plan->create();

        // Trigger created event.
        \core\event\competency_plan_created::create_from_plan($plan)->trigger();
        return $plan;
    }
public static function create_plan ( stdClass $ record ) { global $ USER ; static :: require_enabled ( ) ; $ plan = new plan ( 0 , $ record ) ; if ( $ plan -> is_based_on_template ( ) ) { throw new coding_exception ( 'To create a plan from a template use api::create_plan_from_template().' ) ; } else if ( $ plan -> get ( 'status' ) == plan :: STATUS_COMPLETE ) { throw new coding_exception ( 'A plan cannot be created as complete.' ) ; } if ( ! $ plan -> can_manage ( ) ) { $ context = context_user :: instance ( $ plan -> get ( 'userid' ) ) ; throw new required_capability_exception ( $ context , 'moodle/competency:planmanage' , 'nopermissions' , '' ) ; } $ plan -> create ( ) ; // Trigger created event. \ core \ event \ competency_plan_created :: create_from_plan ( $ plan ) -> trigger ( ) ; return $ plan ; }
Creates a learning plan based on the provided data.

@param stdClass $record
@return \core_competency\plan
Creates a learning plan based on the provided data .