plugin/drop-zone/Manager/DropzoneManager.php
public function computeCorrectionScore(Correction $correction)
    {
        $drop = $correction->getDrop();
        $dropzone = $drop->getDropzone();
        $criteria = $dropzone->getCriteria();

        if ($dropzone->isCriteriaEnabled() && count($criteria) > 0) {
            $score = 0;
            $criteriaIds = [];
            $scoreMax = $dropzone->getScoreMax();
            $total = ($dropzone->getCriteriaTotal() - 1) * count($criteria);
            $grades = $correction->getGrades();

            foreach ($criteria as $criterion) {
                $criteriaIds[] = $criterion->getUuid();
            }
            foreach ($grades as $grade) {
                $gradeCriterion = $grade->getCriterion();

                if (in_array($gradeCriterion->getUuid(), $criteriaIds)) {
                    $score += $grade->getValue();
                }
            }
            $score = round(($score / $total) * $scoreMax, 2);
            $correction->setScore($score);
        }
        $this->om->persist($correction);
        $this->om->flush();

        return $correction;
    }
public function computeCorrectionScore(Correction $correction)
    {
        $drop = $correction->getDrop();
        $dropzone = $drop->getDropzone();
        $criteria = $dropzone->getCriteria();

        if ($dropzone->isCriteriaEnabled() && count($criteria) > 0) {
            $score = 0;
            $criteriaIds = [];
            $scoreMax = $dropzone->getScoreMax();
            $total = ($dropzone->getCriteriaTotal() - 1) * count($criteria);
            $grades = $correction->getGrades();

            foreach ($criteria as $criterion) {
                $criteriaIds[] = $criterion->getUuid();
            }
            foreach ($grades as $grade) {
                $gradeCriterion = $grade->getCriterion();

                if (in_array($gradeCriterion->getUuid(), $criteriaIds)) {
                    $score += $grade->getValue();
                }
            }
            $score = round(($score / $total) * $scoreMax, 2);
            $correction->setScore($score);
        }
        $this->om->persist($correction);
        $this->om->flush();

        return $correction;
    }
public function computeCorrectionScore ( Correction $ correction ) { $ drop = $ correction -> getDrop ( ) ; $ dropzone = $ drop -> getDropzone ( ) ; $ criteria = $ dropzone -> getCriteria ( ) ; if ( $ dropzone -> isCriteriaEnabled ( ) && count ( $ criteria ) > 0 ) { $ score = 0 ; $ criteriaIds = [ ] ; $ scoreMax = $ dropzone -> getScoreMax ( ) ; $ total = ( $ dropzone -> getCriteriaTotal ( ) - 1 ) * count ( $ criteria ) ; $ grades = $ correction -> getGrades ( ) ; foreach ( $ criteria as $ criterion ) { $ criteriaIds [ ] = $ criterion -> getUuid ( ) ; } foreach ( $ grades as $ grade ) { $ gradeCriterion = $ grade -> getCriterion ( ) ; if ( in_array ( $ gradeCriterion -> getUuid ( ) , $ criteriaIds ) ) { $ score += $ grade -> getValue ( ) ; } } $ score = round ( ( $ score / $ total ) * $ scoreMax , 2 ) ; $ correction -> setScore ( $ score ) ; } $ this -> om -> persist ( $ correction ) ; $ this -> om -> flush ( ) ; return $ correction ; }
Computes Correction score from criteria grades.

@param Correction $correction

@return Correction
Computes Correction score from criteria grades .