plugin/exo/Manager/Item/ItemManager.php
public function getItemScores(Exercise $exercise, Item $question)
    {
        $definition = $this->itemDefinitions->get($question->getMimeType());

        if ($definition instanceof AnswerableItemDefinitionInterface) {
            return array_map(function ($answer) use ($question, $definition) {
                $score = $this->calculateScore($question, $answer);
                // get total available for the question
                $expected = $definition->expectAnswer($question->getInteraction());
                $total = $this->scoreManager->calculateTotal(json_decode($question->getScoreRule(), true), $expected, $question->getInteraction());
                // report the score on 100
                $score = $total > 0 ? (100 * $score) / $total : 0;

                return $score;
            }, $this->answerRepository->findByQuestion($question, $exercise));
        }

        return [];
    }
public function getItemScores(Exercise $exercise, Item $question)
    {
        $definition = $this->itemDefinitions->get($question->getMimeType());

        if ($definition instanceof AnswerableItemDefinitionInterface) {
            return array_map(function ($answer) use ($question, $definition) {
                $score = $this->calculateScore($question, $answer);
                // get total available for the question
                $expected = $definition->expectAnswer($question->getInteraction());
                $total = $this->scoreManager->calculateTotal(json_decode($question->getScoreRule(), true), $expected, $question->getInteraction());
                // report the score on 100
                $score = $total > 0 ? (100 * $score) / $total : 0;

                return $score;
            }, $this->answerRepository->findByQuestion($question, $exercise));
        }

        return [];
    }
public function getItemScores ( Exercise $ exercise , Item $ question ) { $ definition = $ this -> itemDefinitions -> get ( $ question -> getMimeType ( ) ) ; if ( $ definition instanceof AnswerableItemDefinitionInterface ) { return array_map ( function ( $ answer ) use ( $ question , $ definition ) { $ score = $ this -> calculateScore ( $ question , $ answer ) ; // get total available for the question $ expected = $ definition -> expectAnswer ( $ question -> getInteraction ( ) ) ; $ total = $ this -> scoreManager -> calculateTotal ( json_decode ( $ question -> getScoreRule ( ) , true ) , $ expected , $ question -> getInteraction ( ) ) ; // report the score on 100 $ score = $ total > 0 ? ( 100 * $ score ) / $ total : 0 ; return $ score ; } , $ this -> answerRepository -> findByQuestion ( $ question , $ exercise ) ) ; } return [ ] ; }
Get all scores for an Answerable Item.

@param Exercise $exercise
@param Item     $question

@return array
Get all scores for an Answerable Item .