@param OpenQuestion $question

@return array
500047
public function expectAnswer(AbstractItem $question)
    {
        return array_filter($question->getKeywords()->toArray(), function (Keyword $keyword) {
            return 0 < $keyword->getScore();
        });
    }
77795
public function serialize(OpenQuestion $wordsQuestion, array $options = [])
    {
        $serialized = [];

        if (in_array(Transfer::INCLUDE_SOLUTIONS, $options)) {
            $serialized['solutions'] = $this->serializeSolutions($wordsQuestion, $options);
        }

        return $serialized;
    }
517695
private function serializeHints(Item $question, array $options = [])
    {
        return array_map(function (Hint $hint) use ($options) {
            return $this->hintSerializer->serialize($hint, $options);
        }, $question->getHints()->toArray());
    }
469981
public function getAnswer(array $question): array
    {
        foreach ($this->resolvers as $resolver) {
            $answer = $resolver->getAnswer($question);
            if (!empty($answer)) {
                return $answer;
            }
        }

        return [];
    }
1029711
protected function askQuestions(array $questons)
    {
        foreach ($questons as $question) {
            $this->verifyQuestion($question);

            $name = $question['name'];
            $prompt = $question['prompt'];
            $default = isset($question['default']) ? $question['default'] : '';
            $required = isset($question['required']) ?  (bool) $question['required'] : false;

            $this->builder->ask($name, $prompt, $default, $required);
        }
    }
766008
public function evaluateQuestion(array $question, PhpStringParser $parser, GeneratorDataObject $generator)
    {
        $iterator       = $this->iteratorValidator->retrieveValidIteration($question, $generator, $parser);
        $iteratorParser = clone $parser;

        foreach ($iterator as $iteration) {
            $iteratorParser->addVariable('iteration', $iteration);

            $origine            = $iteratorParser->parse($question['iteration']['retrieveBy']);
            $responseCollection = new PredefinedResponseCollection();

            foreach ($question['iteration']['response']['predefined'] as $predefinedResponse) {
                $responseCollection->append(
                    new PredefinedResponse(
                        $predefinedResponse['response'],
                        $iteratorParser->parse($predefinedResponse['text']),
                        $predefinedResponse['response']
                    )
                );
            }

            $questionWithPredefinedResponse = new QuestionWithPredefinedResponse(
                $iteratorParser->parse($question['iteration']['text']),
                'set_predefined_' . ucfirst($question['dtoAttribute']) . $origine,
                $responseCollection
            );

            $questionWithPredefinedResponse->setDefaultResponse(
                (isset($question['iteration']['response']['default']) === true) ?
                    $iteratorParser->parse($question['iteration']['response']['default']) : null
            )->setRequired($question['required'])
             ->setResponseType(new QuestionResponseTypeEnum($question['iteration']['response']['type']));

            $response = $this->context->askCollection($questionWithPredefinedResponse);

            $questionName = $question['setter'];
            if ($response !== null) {
                $generator->getDto()->$questionName($origine, $response);
            }
        }

        return $generator;
    }
289169
public function load_and_initialise_questions_for_calculations($quiz) {
        // Load the questions.
        $questions = quiz_report_get_significant_questions($quiz);
        $questionids = array();
        foreach ($questions as $question) {
            $questionids[] = $question->id;
        }
        $fullquestions = question_load_questions($questionids);
        foreach ($questions as $qno => $question) {
            $q = $fullquestions[$question->id];
            $q->maxmark = $question->maxmark;
            $q->slot = $qno;
            $q->number = $question->number;
            $questions[$qno] = $q;
        }
        return $questions;
    }
621674
protected function get_correct_answers($question) {
        $arrayofchoices = $this->get_array_of_choices($question);
        $arrayofplaceholdeers = $this->get_array_of_placeholders($question);

        $correctplayers = array();
        foreach ($arrayofplaceholdeers as $ph) {
            foreach ($arrayofchoices as $key => $choice) {
                if ($key + 1 == $ph) {
                    $correctplayers[] = $choice;
                }
            }
        }
        return $correctplayers;
    }
1184945
protected function validateSolutions(array $question)
    {
        $errors = [];

        if ('highlight' === $question['mode'] || 'select' === $question['mode']) {
            // check solution IDs are consistent with selectionId IDs
            $selectionIds = array_map(function (array $selection) {
                return $selection['id'];
            }, $question['selections']);

            if (count($question['selections']) !== count($question['solutions'])) {
                $errors[] = [
                    'path' => '/solutions',
                    'message' => 'there must be the same number of solutions and selections',
                ];
            }

            foreach ($question['solutions'] as $index => $solution) {
                if (!in_array($solution['selectionId'], $selectionIds)) {
                    $errors[] = [
                        'path' => "/solutions[{$index}]",
                        'message' => "id {$solution['selectionId']} doesn't match any selection id",
                    ];
                }
            }
        }

        if ('highlight' === $question['mode']) {
            // check solution IDs are consistent with selectionId IDs
            $colorIds = array_map(function (array $color) {
                return $color['id'];
            }, $question['colors']);

            foreach ($question['solutions'] as $index => $solution) {
                foreach ($solution['answers'] as $ianswer => $answer) {
                    if (!in_array($answer['colorId'], $colorIds)) {
                        $errors[] = [
                            'path' => "/solutions[{$index}]/answers[$ianswer]",
                            'message' => "id {$answer['colorId']} doesn't match any color id",
                        ];
                    }
                }
            }
        }

        return $errors;
    }
1222737
public function getQuestion($questionUuid)
    {
        $question = null;

        if (empty($this->decodedStructure)) {
            $this->decodeStructure();
        }

        foreach ($this->decodedStructure['steps'] as $step) {
            foreach ($step['items'] as $item) {
                if ($item['id'] === $questionUuid) {
                    $question = $item;
                    break 2;
                }
            }
        }

        return $question;
    }
131443
def questions
      extracted_questions = []

      unless self.qp_questions.nil?
        self.qp_questions.each do |question|   
          extracted_questions.push(Question.new(question))
        end           
      end

      return extracted_questions			
		end
1181982
private function pullQuestion($questionId, array $questions, array $decodedQuestions = [])
    {
        if (empty($decodedQuestions[$questionId])) {
            foreach ($questions as $index => $question) {
                if ($question->getId() === (int) $questionId && !empty($question->getMimeType())) {
                    $decodedQuestions[$questionId] = $this->itemSerializer->serialize($question, [Transfer::INCLUDE_SOLUTIONS]);
                    unset($questions[$index]);
                    break;
                }
            }
        }

        return !empty($decodedQuestions[$questionId]) ? $decodedQuestions[$questionId] : null;
    }
927624
public function ask($question, $default = null)
    {
        $helper = $this->getHelper('question');

        $question = new Question($question, $default);

        return $helper->ask($this->input, $this->getOutputInterface(), $question);
    }
831606
protected function get_array_of_groups($question, $state) {
        $answers = $this->get_array_of_choices($question);
        $arr = array();
        for ($group = 1; $group < count($answers); $group++) {
            $players = $this->get_group_of_players($question, $state, $answers, $group);
            if ($players) {
                $arr[$group] = $players;
            }
        }
        return $arr;
    }
1112289
public function deserialize($data, OpenQuestion $openQuestion = null, array $options = [])
    {
        if (empty($openQuestion)) {
            $openQuestion = new OpenQuestion();
        }
        $this->sipe('maxLength', 'setAnswerMaxLength', $data, $openQuestion);

        return $openQuestion;
    }
1149263
private function serializeQuestionType(Item $question, array $options = [])
    {
        $type = $this->itemDefinitions->getConvertedType($question->getMimeType());
        $definition = $this->itemDefinitions->get($type);

        return $definition->serializeQuestion($question->getInteraction(), $options);
    }
391560
private function serializeHoles(ClozeQuestion $clozeQuestion)
    {
        return array_map(function (Hole $hole) {
            $holeData = [
                'id' => $hole->getUuid(),
                'size' => $hole->getSize(),
            ];

            if ($hole->getSelector()) {
                // We want to propose a list of choices
                $holeData['choices'] = array_map(function (Keyword $keyword) {
                    return $keyword->getText();
                }, $hole->getKeywords()->toArray());
            }
            $placeholder = $hole->getPlaceholder();

            if (!empty($placeholder)) {
                $holeData['placeholder'] = $placeholder;
            }

            return $holeData;
        }, $clozeQuestion->getHoles()->toArray());
    }