public function computeResourceUserEvaluation(Path $path, User $user)
    {
        $steps = $path->getSteps()->toArray();
        $stepsUuids = array_map(function (Step $step) {
            return $step->getUuid();
        }, $steps);
        $resourceUserEval = $this->resourceEvalManager->getResourceUserEvaluation($path->getResourceNode(), $user);
        $evaluations = $resourceUserEval->getEvaluations();
        $score = 0;
        $scoreMax = count($steps);

        /** @var ResourceEvaluation $evaluation */
        foreach ($evaluations as $evaluation) {
            $data = $evaluation->getData();

            if (isset($data['step']) && isset($data['status'])) {
                $statusIndex = array_search($data['status'], ['seen', 'done']);
                $uuidIndex = array_search($data['step'], $stepsUuids);

                if (false !== $statusIndex && false !== $uuidIndex) {
                    ++$score;
                    array_splice($stepsUuids, $uuidIndex, 1);
                }
            }
        }
        $status = $score >= $scoreMax ?
            AbstractResourceEvaluation::STATUS_COMPLETED :
            AbstractResourceEvaluation::STATUS_INCOMPLETE;

        return [
            'score' => $score,
            'scoreMax' => $scoreMax,
            'status' => $status,
            'stepsToDo' => $stepsUuids,
        ];
    }
public function computeResourceUserEvaluation(Path $path, User $user)
    {
        $steps = $path->getSteps()->toArray();
        $stepsUuids = array_map(function (Step $step) {
            return $step->getUuid();
        }, $steps);
        $resourceUserEval = $this->resourceEvalManager->getResourceUserEvaluation($path->getResourceNode(), $user);
        $evaluations = $resourceUserEval->getEvaluations();
        $score = 0;
        $scoreMax = count($steps);

        /** @var ResourceEvaluation $evaluation */
        foreach ($evaluations as $evaluation) {
            $data = $evaluation->getData();

            if (isset($data['step']) && isset($data['status'])) {
                $statusIndex = array_search($data['status'], ['seen', 'done']);
                $uuidIndex = array_search($data['step'], $stepsUuids);

                if (false !== $statusIndex && false !== $uuidIndex) {
                    ++$score;
                    array_splice($stepsUuids, $uuidIndex, 1);
                }
            }
        }
        $status = $score >= $scoreMax ?
            AbstractResourceEvaluation::STATUS_COMPLETED :
            AbstractResourceEvaluation::STATUS_INCOMPLETE;

        return [
            'score' => $score,
            'scoreMax' => $scoreMax,
            'status' => $status,
            'stepsToDo' => $stepsUuids,
        ];
    }
public function computeResourceUserEvaluation ( Path $ path , User $ user ) { $ steps = $ path -> getSteps ( ) -> toArray ( ) ; $ stepsUuids = array_map ( function ( Step $ step ) { return $ step -> getUuid ( ) ; } , $ steps ) ; $ resourceUserEval = $ this -> resourceEvalManager -> getResourceUserEvaluation ( $ path -> getResourceNode ( ) , $ user ) ; $ evaluations = $ resourceUserEval -> getEvaluations ( ) ; $ score = 0 ; $ scoreMax = count ( $ steps ) ; /** @var ResourceEvaluation $evaluation */ foreach ( $ evaluations as $ evaluation ) { $ data = $ evaluation -> getData ( ) ; if ( isset ( $ data [ 'step' ] ) && isset ( $ data [ 'status' ] ) ) { $ statusIndex = array_search ( $ data [ 'status' ] , [ 'seen' , 'done' ] ) ; $ uuidIndex = array_search ( $ data [ 'step' ] , $ stepsUuids ) ; if ( false !== $ statusIndex && false !== $ uuidIndex ) { ++ $ score ; array_splice ( $ stepsUuids , $ uuidIndex , 1 ) ; } } } $ status = $ score >= $ scoreMax ? AbstractResourceEvaluation :: STATUS_COMPLETED : AbstractResourceEvaluation :: STATUS_INCOMPLETE ; return [ 'score' => $ score , 'scoreMax' => $ scoreMax , 'status' => $ status , 'stepsToDo' => $ stepsUuids , ] ; }
Compute current resource evaluation status.

@param Path $path
@param User $user

@return array
Compute current resource evaluation status .