plugin/exo/Manager/Attempt/PaperManager.php
public function generateResourceEvaluation(Paper $paper, $finished)
    {
        $totalScoreOn = $paper->getExercise()->getTotalScoreOn();
        $total = $totalScoreOn ? $totalScoreOn : $this->calculateTotal($paper);
        $score = $this->calculateScore($paper, $total);
        $successScore = $paper->getExercise()->getSuccessScore();
        $data = [
            'paper' => [
                'id' => $paper->getId(),
                'uuid' => $paper->getUuid(),
            ],
        ];

        if ($finished) {
            if (is_null($successScore)) {
                $status = AbstractResourceEvaluation::STATUS_COMPLETED;
            } else {
                $percentScore = 100 === $totalScoreOn ? $score : $this->calculateScore($paper, 100);
                $status = $percentScore >= $successScore ?
                    AbstractResourceEvaluation::STATUS_PASSED :
                    AbstractResourceEvaluation::STATUS_FAILED;
            }
        } else {
            $status = AbstractResourceEvaluation::STATUS_INCOMPLETE;
        }
        $nbQuestions = 0;
        $structure = json_decode($paper->getStructure(), true);

        if (isset($structure['steps'])) {
            foreach ($structure['steps'] as $step) {
                $nbQuestions += count($step['items']); // TODO : remove content items
            }
        }
        $nbAnswers = 0;

        foreach ($paper->getAnswers() as $answer) {
            if (!is_null($answer->getData())) {
                ++$nbAnswers;
            }
        }

        return $this->resourceEvalManager->createResourceEvaluation(
            $paper->getExercise()->getResourceNode(),
            $paper->getUser(),
            null,
            [
                'status' => $status,
                'score' => $score,
                'scoreMax' => $total,
                'progression' => $nbQuestions > 0 ? floor(($nbAnswers / $nbQuestions) * 100) : null,
                'data' => $data,
            ]
        );
    }
public function generateResourceEvaluation(Paper $paper, $finished)
    {
        $totalScoreOn = $paper->getExercise()->getTotalScoreOn();
        $total = $totalScoreOn ? $totalScoreOn : $this->calculateTotal($paper);
        $score = $this->calculateScore($paper, $total);
        $successScore = $paper->getExercise()->getSuccessScore();
        $data = [
            'paper' => [
                'id' => $paper->getId(),
                'uuid' => $paper->getUuid(),
            ],
        ];

        if ($finished) {
            if (is_null($successScore)) {
                $status = AbstractResourceEvaluation::STATUS_COMPLETED;
            } else {
                $percentScore = 100 === $totalScoreOn ? $score : $this->calculateScore($paper, 100);
                $status = $percentScore >= $successScore ?
                    AbstractResourceEvaluation::STATUS_PASSED :
                    AbstractResourceEvaluation::STATUS_FAILED;
            }
        } else {
            $status = AbstractResourceEvaluation::STATUS_INCOMPLETE;
        }
        $nbQuestions = 0;
        $structure = json_decode($paper->getStructure(), true);

        if (isset($structure['steps'])) {
            foreach ($structure['steps'] as $step) {
                $nbQuestions += count($step['items']); // TODO : remove content items
            }
        }
        $nbAnswers = 0;

        foreach ($paper->getAnswers() as $answer) {
            if (!is_null($answer->getData())) {
                ++$nbAnswers;
            }
        }

        return $this->resourceEvalManager->createResourceEvaluation(
            $paper->getExercise()->getResourceNode(),
            $paper->getUser(),
            null,
            [
                'status' => $status,
                'score' => $score,
                'scoreMax' => $total,
                'progression' => $nbQuestions > 0 ? floor(($nbAnswers / $nbQuestions) * 100) : null,
                'data' => $data,
            ]
        );
    }
public function generateResourceEvaluation ( Paper $ paper , $ finished ) { $ totalScoreOn = $ paper -> getExercise ( ) -> getTotalScoreOn ( ) ; $ total = $ totalScoreOn ? $ totalScoreOn : $ this -> calculateTotal ( $ paper ) ; $ score = $ this -> calculateScore ( $ paper , $ total ) ; $ successScore = $ paper -> getExercise ( ) -> getSuccessScore ( ) ; $ data = [ 'paper' => [ 'id' => $ paper -> getId ( ) , 'uuid' => $ paper -> getUuid ( ) , ] , ] ; if ( $ finished ) { if ( is_null ( $ successScore ) ) { $ status = AbstractResourceEvaluation :: STATUS_COMPLETED ; } else { $ percentScore = 100 === $ totalScoreOn ? $ score : $ this -> calculateScore ( $ paper , 100 ) ; $ status = $ percentScore >= $ successScore ? AbstractResourceEvaluation :: STATUS_PASSED : AbstractResourceEvaluation :: STATUS_FAILED ; } } else { $ status = AbstractResourceEvaluation :: STATUS_INCOMPLETE ; } $ nbQuestions = 0 ; $ structure = json_decode ( $ paper -> getStructure ( ) , true ) ; if ( isset ( $ structure [ 'steps' ] ) ) { foreach ( $ structure [ 'steps' ] as $ step ) { $ nbQuestions += count ( $ step [ 'items' ] ) ; // TODO : remove content items } } $ nbAnswers = 0 ; foreach ( $ paper -> getAnswers ( ) as $ answer ) { if ( ! is_null ( $ answer -> getData ( ) ) ) { ++ $ nbAnswers ; } } return $ this -> resourceEvalManager -> createResourceEvaluation ( $ paper -> getExercise ( ) -> getResourceNode ( ) , $ paper -> getUser ( ) , null , [ 'status' => $ status , 'score' => $ score , 'scoreMax' => $ total , 'progression' => $ nbQuestions > 0 ? floor ( ( $ nbAnswers / $ nbQuestions ) * 100 ) : null , 'data' => $ data , ] ) ; }
Creates a ResourceEvaluation for the attempt.

@param Paper $paper
@param bool  $finished

@return ResourceEvaluation
Creates a ResourceEvaluation for the attempt .