plugin/exo/Library/Attempt/PaperGenerator.php
private function pickItems(Step $step, array $previousStep = null)
    {
        if (!empty($previousStep) && Recurrence::ALWAYS !== $step->getRandomPick()) {
            // Just get the list of question from previous step
            // We get the entities to reapply shuffle (= redo serialization with shuffle option)
            $items = array_map(function (array $pickedItem) use ($step) {
                return $step->getQuestion($pickedItem['id']);
            }, $previousStep['items']);
        } else {
            // Pick a new set of questions
            $items = static::pick(
                $step->getQuestions(),
                $step->getPick()
            );
        }

        // Serialize items
        $pickedItems = array_map(function (Item $pickedItem) {
            return $this->itemSerializer->serialize($pickedItem, [
                Transfer::SHUFFLE_ANSWERS,
                Transfer::INCLUDE_SOLUTIONS,
            ]);
        }, $items);

        // Recalculate order of the items based on the configuration
        // if we don't want to keep the one from the previous paper
        if ((empty($previousStep) && Recurrence::ONCE === $step->getRandomOrder())
            || Recurrence::ALWAYS === $step->getRandomOrder()) {
            shuffle($pickedItems);
        }

        return $pickedItems;
    }
private function pickItems(Step $step, array $previousStep = null)
    {
        if (!empty($previousStep) && Recurrence::ALWAYS !== $step->getRandomPick()) {
            // Just get the list of question from previous step
            // We get the entities to reapply shuffle (= redo serialization with shuffle option)
            $items = array_map(function (array $pickedItem) use ($step) {
                return $step->getQuestion($pickedItem['id']);
            }, $previousStep['items']);
        } else {
            // Pick a new set of questions
            $items = static::pick(
                $step->getQuestions(),
                $step->getPick()
            );
        }

        // Serialize items
        $pickedItems = array_map(function (Item $pickedItem) {
            return $this->itemSerializer->serialize($pickedItem, [
                Transfer::SHUFFLE_ANSWERS,
                Transfer::INCLUDE_SOLUTIONS,
            ]);
        }, $items);

        // Recalculate order of the items based on the configuration
        // if we don't want to keep the one from the previous paper
        if ((empty($previousStep) && Recurrence::ONCE === $step->getRandomOrder())
            || Recurrence::ALWAYS === $step->getRandomOrder()) {
            shuffle($pickedItems);
        }

        return $pickedItems;
    }
private function pickItems ( Step $ step , array $ previousStep = null ) { if ( ! empty ( $ previousStep ) && Recurrence :: ALWAYS !== $ step -> getRandomPick ( ) ) { // Just get the list of question from previous step // We get the entities to reapply shuffle (= redo serialization with shuffle option) $ items = array_map ( function ( array $ pickedItem ) use ( $ step ) { return $ step -> getQuestion ( $ pickedItem [ 'id' ] ) ; } , $ previousStep [ 'items' ] ) ; } else { // Pick a new set of questions $ items = static :: pick ( $ step -> getQuestions ( ) , $ step -> getPick ( ) ) ; } // Serialize items $ pickedItems = array_map ( function ( Item $ pickedItem ) { return $ this -> itemSerializer -> serialize ( $ pickedItem , [ Transfer :: SHUFFLE_ANSWERS , Transfer :: INCLUDE_SOLUTIONS , ] ) ; } , $ items ) ; // Recalculate order of the items based on the configuration // if we don't want to keep the one from the previous paper if ( ( empty ( $ previousStep ) && Recurrence :: ONCE === $ step -> getRandomOrder ( ) ) || Recurrence :: ALWAYS === $ step -> getRandomOrder ( ) ) { shuffle ( $ pickedItems ) ; } return $ pickedItems ; }
Pick items for a step according to the step configuration.

@param Step       $step
@param array|null $previousStep

@return Item[]
Pick items for a step according to the step configuration .