public function generateResourceEvaluation(Step $step, User $user, $status)
    {
        $statusData = $this->computeResourceUserEvaluation($step->getPath(), $user);
        $stepIndex = array_search($step->getUuid(), $statusData['stepsToDo']);

        if (false !== $stepIndex && false !== array_search($status, ['seen', 'done'])) {
            ++$statusData['score'];
            array_splice($statusData['stepsToDo'], $stepIndex, 1);
        }

        $evaluationData = [
            'step' => $step->getUuid(),
            'status' => $status,
            'toDo' => $statusData['stepsToDo'],
        ];
        $progression = !is_null($statusData['score']) && $statusData['scoreMax'] > 0 ?
            floor(($statusData['score'] / $statusData['scoreMax']) * 100) :
            null;

        return $this->resourceEvalManager->createResourceEvaluation(
            $step->getPath()->getResourceNode(),
            $user,
            null,
            [
                'status' => $statusData['status'],
                'score' => $statusData['score'],
                'scoreMax' => $statusData['scoreMax'],
                'progression' => $progression,
                'data' => $evaluationData,
            ],
            [
                'status' => true,
                'score' => true,
                'progression' => true,
            ]
        );
    }
public function generateResourceEvaluation(Step $step, User $user, $status)
    {
        $statusData = $this->computeResourceUserEvaluation($step->getPath(), $user);
        $stepIndex = array_search($step->getUuid(), $statusData['stepsToDo']);

        if (false !== $stepIndex && false !== array_search($status, ['seen', 'done'])) {
            ++$statusData['score'];
            array_splice($statusData['stepsToDo'], $stepIndex, 1);
        }

        $evaluationData = [
            'step' => $step->getUuid(),
            'status' => $status,
            'toDo' => $statusData['stepsToDo'],
        ];
        $progression = !is_null($statusData['score']) && $statusData['scoreMax'] > 0 ?
            floor(($statusData['score'] / $statusData['scoreMax']) * 100) :
            null;

        return $this->resourceEvalManager->createResourceEvaluation(
            $step->getPath()->getResourceNode(),
            $user,
            null,
            [
                'status' => $statusData['status'],
                'score' => $statusData['score'],
                'scoreMax' => $statusData['scoreMax'],
                'progression' => $progression,
                'data' => $evaluationData,
            ],
            [
                'status' => true,
                'score' => true,
                'progression' => true,
            ]
        );
    }
public function generateResourceEvaluation ( Step $ step , User $ user , $ status ) { $ statusData = $ this -> computeResourceUserEvaluation ( $ step -> getPath ( ) , $ user ) ; $ stepIndex = array_search ( $ step -> getUuid ( ) , $ statusData [ 'stepsToDo' ] ) ; if ( false !== $ stepIndex && false !== array_search ( $ status , [ 'seen' , 'done' ] ) ) { ++ $ statusData [ 'score' ] ; array_splice ( $ statusData [ 'stepsToDo' ] , $ stepIndex , 1 ) ; } $ evaluationData = [ 'step' => $ step -> getUuid ( ) , 'status' => $ status , 'toDo' => $ statusData [ 'stepsToDo' ] , ] ; $ progression = ! is_null ( $ statusData [ 'score' ] ) && $ statusData [ 'scoreMax' ] > 0 ? floor ( ( $ statusData [ 'score' ] / $ statusData [ 'scoreMax' ] ) * 100 ) : null ; return $ this -> resourceEvalManager -> createResourceEvaluation ( $ step -> getPath ( ) -> getResourceNode ( ) , $ user , null , [ 'status' => $ statusData [ 'status' ] , 'score' => $ statusData [ 'score' ] , 'scoreMax' => $ statusData [ 'scoreMax' ] , 'progression' => $ progression , 'data' => $ evaluationData , ] , [ 'status' => true , 'score' => true , 'progression' => true , ] ) ; }
Create a ResourceEvaluation for a step.

@param Step   $step
@param User   $user
@param string $status

@return ResourceEvaluation
Create a ResourceEvaluation for a step .