public function loadUserObjectiveCompetencies(Objective $objective, User $user)
    {
        $competencies = $this->doLoadObjectiveCompetencies($objective, false);
        $competenciesWithProgress = [];
        $competencyIds = [];

        // extract the competency ids from the original nested array
        $this->competencyManager->walkCollection($competencies, function ($competency) use (&$competencyIds) {
            if (isset($competency['id'])) {
                $competencyIds[] = isset($competency['originalId']) ?
                    $competency['originalId'] :
                    $competency['id'];
            }

            return $competency;
        });

        // fetch competency progress entities in one query and sort them by id
        $competencyProgresses = $this->competencyProgressRepo->findByUserAndCompetencyIds($user, $competencyIds);
        $competencyProgressesById = [];

        foreach ($competencyProgresses as $competencyProgress) {
            $competencyProgressesById[$competencyProgress->getCompetency()->getId()] = $competencyProgress;
        }

        // augment the original array with progress data
        foreach ($competencies as $competency) {
            $competenciesWithProgress[] = $this->competencyManager->walkCollection(
                $competency,
                function ($collection) use ($user, $competencyProgressesById) {
                    if (isset($collection['id'])) {
                        $id = isset($collection['originalId']) ? $collection['originalId'] : $collection['id'];

                        if (isset($competencyProgressesById[$id])) {
                            $progress = $competencyProgressesById[$id];
                            $collection['progress'] = $progress->getPercentage();
                            $collection['latestResource'] = $progress->getResourceId();

                            if ($level = $progress->getLevel()) {
                                $collection['userLevel'] = $level->getName();
                                $collection['userLevelValue'] = $level->getValue();
                            }
                        }
                    }

                    return $collection;
                }
            );
        }

        return $competenciesWithProgress;
    }
public function loadUserObjectiveCompetencies(Objective $objective, User $user)
    {
        $competencies = $this->doLoadObjectiveCompetencies($objective, false);
        $competenciesWithProgress = [];
        $competencyIds = [];

        // extract the competency ids from the original nested array
        $this->competencyManager->walkCollection($competencies, function ($competency) use (&$competencyIds) {
            if (isset($competency['id'])) {
                $competencyIds[] = isset($competency['originalId']) ?
                    $competency['originalId'] :
                    $competency['id'];
            }

            return $competency;
        });

        // fetch competency progress entities in one query and sort them by id
        $competencyProgresses = $this->competencyProgressRepo->findByUserAndCompetencyIds($user, $competencyIds);
        $competencyProgressesById = [];

        foreach ($competencyProgresses as $competencyProgress) {
            $competencyProgressesById[$competencyProgress->getCompetency()->getId()] = $competencyProgress;
        }

        // augment the original array with progress data
        foreach ($competencies as $competency) {
            $competenciesWithProgress[] = $this->competencyManager->walkCollection(
                $competency,
                function ($collection) use ($user, $competencyProgressesById) {
                    if (isset($collection['id'])) {
                        $id = isset($collection['originalId']) ? $collection['originalId'] : $collection['id'];

                        if (isset($competencyProgressesById[$id])) {
                            $progress = $competencyProgressesById[$id];
                            $collection['progress'] = $progress->getPercentage();
                            $collection['latestResource'] = $progress->getResourceId();

                            if ($level = $progress->getLevel()) {
                                $collection['userLevel'] = $level->getName();
                                $collection['userLevelValue'] = $level->getValue();
                            }
                        }
                    }

                    return $collection;
                }
            );
        }

        return $competenciesWithProgress;
    }
public function loadUserObjectiveCompetencies ( Objective $ objective , User $ user ) { $ competencies = $ this -> doLoadObjectiveCompetencies ( $ objective , false ) ; $ competenciesWithProgress = [ ] ; $ competencyIds = [ ] ; // extract the competency ids from the original nested array $ this -> competencyManager -> walkCollection ( $ competencies , function ( $ competency ) use ( & $ competencyIds ) { if ( isset ( $ competency [ 'id' ] ) ) { $ competencyIds [ ] = isset ( $ competency [ 'originalId' ] ) ? $ competency [ 'originalId' ] : $ competency [ 'id' ] ; } return $ competency ; } ) ; // fetch competency progress entities in one query and sort them by id $ competencyProgresses = $ this -> competencyProgressRepo -> findByUserAndCompetencyIds ( $ user , $ competencyIds ) ; $ competencyProgressesById = [ ] ; foreach ( $ competencyProgresses as $ competencyProgress ) { $ competencyProgressesById [ $ competencyProgress -> getCompetency ( ) -> getId ( ) ] = $ competencyProgress ; } // augment the original array with progress data foreach ( $ competencies as $ competency ) { $ competenciesWithProgress [ ] = $ this -> competencyManager -> walkCollection ( $ competency , function ( $ collection ) use ( $ user , $ competencyProgressesById ) { if ( isset ( $ collection [ 'id' ] ) ) { $ id = isset ( $ collection [ 'originalId' ] ) ? $ collection [ 'originalId' ] : $ collection [ 'id' ] ; if ( isset ( $ competencyProgressesById [ $ id ] ) ) { $ progress = $ competencyProgressesById [ $ id ] ; $ collection [ 'progress' ] = $ progress -> getPercentage ( ) ; $ collection [ 'latestResource' ] = $ progress -> getResourceId ( ) ; if ( $ level = $ progress -> getLevel ( ) ) { $ collection [ 'userLevel' ] = $ level -> getName ( ) ; $ collection [ 'userLevelValue' ] = $ level -> getValue ( ) ; } } } return $ collection ; } ) ; } return $ competenciesWithProgress ; }
Returns an array representation of all the competencies associated
with a user objective, including sub-competencies and progress data
at each level.

@param Objective $objective
@param User      $user

@return array
Returns an array representation of all the competencies associated with a user objective including sub - competencies and progress data at each level .