public function expectAnswer(AbstractItem $question)
    {
        $expected = [];

        switch ($question->getSumMode()) {
            case GridQuestion::SUM_CELL:
                foreach ($question->getCells()->toArray() as $cell) {
                    if (0 < count($cell->getChoices())) {
                        $expected[] = $this->findCellExpectedAnswer($cell);
                    }
                }
                break;
            case GridQuestion::SUM_COLUMN:
                for ($i = 0; $i < $question->getColumns(); ++$i) {
                    // get cells where there is at least 1 expected answers for the current column (none possible)
                    foreach ($question->getCells() as $cell) {
                        // found a cell in this col with an expected answer
                        if ($cell->getCoordsX() === $i && 0 < count($cell->getChoices())) {
                            // all choices should have the same score
                            $scoreToApply = $cell->getChoices()[0]->getScore();
                            $expected[] = new GenericScore($scoreToApply);
                            break;
                        }
                    }
                }
                break;
            case GridQuestion::SUM_ROW:
                for ($i = 0; $i < $question->getRows(); ++$i) {
                    // get cells where there is at least 1 expected answers for the current row (none possible)
                    foreach ($question->getCells() as $cell) {
                        // found a cell in this row with an expected answer
                        if ($cell->getCoordsY() === $i && 0 < count($cell->getChoices())) {
                            // all choices should have the same score
                            $scoreToApply = $cell->getChoices()[0]->getScore();
                            $expected[] = new GenericScore($scoreToApply);
                            break;
                        }
                    }
                }
                break;
        }

        return $expected;
    }
public function expectAnswer(AbstractItem $question)
    {
        $expected = [];

        switch ($question->getSumMode()) {
            case GridQuestion::SUM_CELL:
                foreach ($question->getCells()->toArray() as $cell) {
                    if (0 < count($cell->getChoices())) {
                        $expected[] = $this->findCellExpectedAnswer($cell);
                    }
                }
                break;
            case GridQuestion::SUM_COLUMN:
                for ($i = 0; $i < $question->getColumns(); ++$i) {
                    // get cells where there is at least 1 expected answers for the current column (none possible)
                    foreach ($question->getCells() as $cell) {
                        // found a cell in this col with an expected answer
                        if ($cell->getCoordsX() === $i && 0 < count($cell->getChoices())) {
                            // all choices should have the same score
                            $scoreToApply = $cell->getChoices()[0]->getScore();
                            $expected[] = new GenericScore($scoreToApply);
                            break;
                        }
                    }
                }
                break;
            case GridQuestion::SUM_ROW:
                for ($i = 0; $i < $question->getRows(); ++$i) {
                    // get cells where there is at least 1 expected answers for the current row (none possible)
                    foreach ($question->getCells() as $cell) {
                        // found a cell in this row with an expected answer
                        if ($cell->getCoordsY() === $i && 0 < count($cell->getChoices())) {
                            // all choices should have the same score
                            $scoreToApply = $cell->getChoices()[0]->getScore();
                            $expected[] = new GenericScore($scoreToApply);
                            break;
                        }
                    }
                }
                break;
        }

        return $expected;
    }
public function expectAnswer ( AbstractItem $ question ) { $ expected = [ ] ; switch ( $ question -> getSumMode ( ) ) { case GridQuestion :: SUM_CELL : foreach ( $ question -> getCells ( ) -> toArray ( ) as $ cell ) { if ( 0 < count ( $ cell -> getChoices ( ) ) ) { $ expected [ ] = $ this -> findCellExpectedAnswer ( $ cell ) ; } } break ; case GridQuestion :: SUM_COLUMN : for ( $ i = 0 ; $ i < $ question -> getColumns ( ) ; ++ $ i ) { // get cells where there is at least 1 expected answers for the current column (none possible) foreach ( $ question -> getCells ( ) as $ cell ) { // found a cell in this col with an expected answer if ( $ cell -> getCoordsX ( ) === $ i && 0 < count ( $ cell -> getChoices ( ) ) ) { // all choices should have the same score $ scoreToApply = $ cell -> getChoices ( ) [ 0 ] -> getScore ( ) ; $ expected [ ] = new GenericScore ( $ scoreToApply ) ; break ; } } } break ; case GridQuestion :: SUM_ROW : for ( $ i = 0 ; $ i < $ question -> getRows ( ) ; ++ $ i ) { // get cells where there is at least 1 expected answers for the current row (none possible) foreach ( $ question -> getCells ( ) as $ cell ) { // found a cell in this row with an expected answer if ( $ cell -> getCoordsY ( ) === $ i && 0 < count ( $ cell -> getChoices ( ) ) ) { // all choices should have the same score $ scoreToApply = $ cell -> getChoices ( ) [ 0 ] -> getScore ( ) ; $ expected [ ] = new GenericScore ( $ scoreToApply ) ; break ; } } } break ; } return $ expected ; }
Used to compute the question total score. Only for sum score type.

@param GridQuestion $question

@return array
Used to compute the question total score . Only for sum score type .