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

        if (!user_competency::can_read_user($plan->get('userid'))) {
            throw new required_capability_exception($plan->get_context(), 'moodle/competency:usercompetencyview',
                'nopermissions', '');
        }

        $competency = $plan->get_competency($competencyid);

        // Get user competencies from user_competency_plan if the plan status is set to complete.
        $iscompletedplan = $plan->get('status') == plan::STATUS_COMPLETE;
        if ($iscompletedplan) {
            $usercompetencies = user_competency_plan::get_multiple($plan->get('userid'), $plan->get('id'), array($competencyid));
            $ucresultkey = 'usercompetencyplan';
        } else {
            $usercompetencies = user_competency::get_multiple($plan->get('userid'), array($competencyid));
            $ucresultkey = 'usercompetency';
        }

        $found = count($usercompetencies);

        if ($found) {
            $uc = array_pop($usercompetencies);
        } else {
            if ($iscompletedplan) {
                throw new coding_exception('A user competency plan is missing');
            } else {
                $uc = user_competency::create_relation($plan->get('userid'), $competency->get('id'));
                $uc->create();
            }
        }

        $plancompetency = (object) array(
            'competency' => $competency,
            'usercompetency' => null,
            'usercompetencyplan' => null
        );
        $plancompetency->$ucresultkey = $uc;

        return $plancompetency;
    }
public static function get_plan_competency($planorid, $competencyid) {
        static::require_enabled();
        $plan = $planorid;
        if (!is_object($planorid)) {
            $plan = new plan($planorid);
        }

        if (!user_competency::can_read_user($plan->get('userid'))) {
            throw new required_capability_exception($plan->get_context(), 'moodle/competency:usercompetencyview',
                'nopermissions', '');
        }

        $competency = $plan->get_competency($competencyid);

        // Get user competencies from user_competency_plan if the plan status is set to complete.
        $iscompletedplan = $plan->get('status') == plan::STATUS_COMPLETE;
        if ($iscompletedplan) {
            $usercompetencies = user_competency_plan::get_multiple($plan->get('userid'), $plan->get('id'), array($competencyid));
            $ucresultkey = 'usercompetencyplan';
        } else {
            $usercompetencies = user_competency::get_multiple($plan->get('userid'), array($competencyid));
            $ucresultkey = 'usercompetency';
        }

        $found = count($usercompetencies);

        if ($found) {
            $uc = array_pop($usercompetencies);
        } else {
            if ($iscompletedplan) {
                throw new coding_exception('A user competency plan is missing');
            } else {
                $uc = user_competency::create_relation($plan->get('userid'), $competency->get('id'));
                $uc->create();
            }
        }

        $plancompetency = (object) array(
            'competency' => $competency,
            'usercompetency' => null,
            'usercompetencyplan' => null
        );
        $plancompetency->$ucresultkey = $uc;

        return $plancompetency;
    }
public static function get_plan_competency ( $ planorid , $ competencyid ) { static :: require_enabled ( ) ; $ plan = $ planorid ; if ( ! is_object ( $ planorid ) ) { $ plan = new plan ( $ planorid ) ; } if ( ! user_competency :: can_read_user ( $ plan -> get ( 'userid' ) ) ) { throw new required_capability_exception ( $ plan -> get_context ( ) , 'moodle/competency:usercompetencyview' , 'nopermissions' , '' ) ; } $ competency = $ plan -> get_competency ( $ competencyid ) ; // Get user competencies from user_competency_plan if the plan status is set to complete. $ iscompletedplan = $ plan -> get ( 'status' ) == plan :: STATUS_COMPLETE ; if ( $ iscompletedplan ) { $ usercompetencies = user_competency_plan :: get_multiple ( $ plan -> get ( 'userid' ) , $ plan -> get ( 'id' ) , array ( $ competencyid ) ) ; $ ucresultkey = 'usercompetencyplan' ; } else { $ usercompetencies = user_competency :: get_multiple ( $ plan -> get ( 'userid' ) , array ( $ competencyid ) ) ; $ ucresultkey = 'usercompetency' ; } $ found = count ( $ usercompetencies ) ; if ( $ found ) { $ uc = array_pop ( $ usercompetencies ) ; } else { if ( $ iscompletedplan ) { throw new coding_exception ( 'A user competency plan is missing' ) ; } else { $ uc = user_competency :: create_relation ( $ plan -> get ( 'userid' ) , $ competency -> get ( 'id' ) ) ; $ uc -> create ( ) ; } } $ plancompetency = ( object ) array ( 'competency' => $ competency , 'usercompetency' => null , 'usercompetencyplan' => null ) ; $ plancompetency -> $ ucresultkey = $ uc ; return $ plancompetency ; }
Get a single competency from the user plan.

@param  int $planorid The plan, or its ID.
@param  int $competencyid The competency id.
@return (object) array(
'competency' => \core_competency\competency,
'usercompetency' => \core_competency\user_competency
'usercompetencyplan' => \core_competency\user_competency_plan
)
The values of of keys usercompetency and usercompetencyplan cannot be defined at the same time.
Get a single competency from the user plan .