plugin/exo/Serializer/Item/Type/ClozeQuestionSerializer.php
private function deserializeHoles(ClozeQuestion $clozeQuestion, array $holes, array $solutions, array $options = [])
    {
        $holeEntities = $clozeQuestion->getHoles()->toArray();

        foreach ($holes as $holeData) {
            $hole = null;

            // Searches for an existing hole entity.
            foreach ($holeEntities as $entityIndex => $entityHole) {
                /** @var Hole $entityHole */
                if ($entityHole->getUuid() === $holeData['id']) {
                    $hole = $entityHole;
                    unset($holeEntities[$entityIndex]);
                    break;
                }
            }

            $hole = $hole ?: new Hole();
            $hole->setUuid($holeData['id']);

            if (!empty($holeData['size'])) {
                $hole->setSize($holeData['size']);
            }

            if (!empty($holeData['choices'])) {
                $hole->setSelector(true);
            } else {
                $hole->setSelector(false);
            }

            foreach ($solutions as $solution) {
                if ($solution['holeId'] === $holeData['id']) {
                    $this->deserializeHoleKeywords($hole, $solution['answers'], $options);

                    break;
                }
            }

            $clozeQuestion->addHole($hole);
        }

        // Remaining holes are no longer in the Question
        foreach ($holeEntities as $holeToRemove) {
            $clozeQuestion->removeHole($holeToRemove);
        }
    }
private function deserializeHoles(ClozeQuestion $clozeQuestion, array $holes, array $solutions, array $options = [])
    {
        $holeEntities = $clozeQuestion->getHoles()->toArray();

        foreach ($holes as $holeData) {
            $hole = null;

            // Searches for an existing hole entity.
            foreach ($holeEntities as $entityIndex => $entityHole) {
                /** @var Hole $entityHole */
                if ($entityHole->getUuid() === $holeData['id']) {
                    $hole = $entityHole;
                    unset($holeEntities[$entityIndex]);
                    break;
                }
            }

            $hole = $hole ?: new Hole();
            $hole->setUuid($holeData['id']);

            if (!empty($holeData['size'])) {
                $hole->setSize($holeData['size']);
            }

            if (!empty($holeData['choices'])) {
                $hole->setSelector(true);
            } else {
                $hole->setSelector(false);
            }

            foreach ($solutions as $solution) {
                if ($solution['holeId'] === $holeData['id']) {
                    $this->deserializeHoleKeywords($hole, $solution['answers'], $options);

                    break;
                }
            }

            $clozeQuestion->addHole($hole);
        }

        // Remaining holes are no longer in the Question
        foreach ($holeEntities as $holeToRemove) {
            $clozeQuestion->removeHole($holeToRemove);
        }
    }
private function deserializeHoles ( ClozeQuestion $ clozeQuestion , array $ holes , array $ solutions , array $ options = [ ] ) { $ holeEntities = $ clozeQuestion -> getHoles ( ) -> toArray ( ) ; foreach ( $ holes as $ holeData ) { $ hole = null ; // Searches for an existing hole entity. foreach ( $ holeEntities as $ entityIndex => $ entityHole ) { /** @var Hole $entityHole */ if ( $ entityHole -> getUuid ( ) === $ holeData [ 'id' ] ) { $ hole = $ entityHole ; unset ( $ holeEntities [ $ entityIndex ] ) ; break ; } } $ hole = $ hole ? : new Hole ( ) ; $ hole -> setUuid ( $ holeData [ 'id' ] ) ; if ( ! empty ( $ holeData [ 'size' ] ) ) { $ hole -> setSize ( $ holeData [ 'size' ] ) ; } if ( ! empty ( $ holeData [ 'choices' ] ) ) { $ hole -> setSelector ( true ) ; } else { $ hole -> setSelector ( false ) ; } foreach ( $ solutions as $ solution ) { if ( $ solution [ 'holeId' ] === $ holeData [ 'id' ] ) { $ this -> deserializeHoleKeywords ( $ hole , $ solution [ 'answers' ] , $ options ) ; break ; } } $ clozeQuestion -> addHole ( $ hole ) ; } // Remaining holes are no longer in the Question foreach ( $ holeEntities as $ holeToRemove ) { $ clozeQuestion -> removeHole ( $ holeToRemove ) ; } }
Deserializes Question holes.

@param ClozeQuestion $clozeQuestion
@param array         $holes
@param array         $solutions
@param array         $options
Deserializes Question holes .