Writes question to output and returns boolesn value corresponding to the chosen value.

@param  string $question Question to ask
@param  string $default  Default answer
@return bool
976140
protected function confirm(string $question, string $default = 'n')
	{
		return (new Confirmation($this->input, $this->output))->ask($question, $default);
	}
571053
public function ask($string, $default = null) {
        if ($default === true) {
            $suffix = 'Y/n';
        } else if ($default === false) {
            $suffix = 'y/N';
        } else {
            $suffix = 'y/n';
        }

        $this->output->write(
            "<question>$string</question> [<yellow>$suffix</yellow>]: "
        );
        $input = $this->input->readLine();

        if (array_contains(['yes', 'y'], $input)) {
            return true;
        }

        if (array_contains(['no', 'n'], $input)) {
            return false;
        }

        if (empty($input)) {
            if ($default === true) {
                return true;
            }

            if ($default === false) {
                return false;
            }
        }

        return $this->ask($string, $default);
    }
1268987
protected function secret(string $question, $default = null, bool $fallback = false)
	{
		return (new Secret($this->input, $this->output))->ask($question, $default, $fallback);
	}
1225507
public function askWithCompletion($question, array $choices, $default = null, $attempts = null, $strict = false)
    {
        $question = new Question($question, $default);
        $question->setMaxAttempts($attempts)->setAutocompleterValues($choices);

        if ($strict) {
            $question->setValidator(function($result) use ($choices) {
                if (!in_array($result, $choices)) {
                    throw new \InvalidArgumentException(sprintf(
                        'The provided answer is ambiguous. Value should be one of %s',
                        implode(' or ', $choices)));
                }

                return $result;
            });
        }

        return $this->askQuestion($question);
    }
536212
protected function select($text, $choices, $default = null)
    {
        $question = new ChoiceQuestion($text, $choices, $default);

        return $this->getHelper('question')->ask($this->input, $this->output, $question);
    }
335862
private function askConfirmation(InputInterface $input, OutputInterface $output, $questionText, $default, $separator)
    {
        $questionHelper = $this->getQuestionHelper();

        // NEXT_MAJOR: Remove this BC code for SensioGeneratorBundle 2.3/2.4 after dropping support for Symfony 2.3
        if ($questionHelper instanceof DialogHelper) {
            $question = $questionHelper->getQuestion($questionText, $default, $separator);

            return $questionHelper->askConfirmation($output, $question, ($default === 'no' ? false : true));
        }

        $question = new ConfirmationQuestion($questionHelper->getQuestion(
            $questionText,
            $default,
            $separator
        ), ($default === 'no' ? false : true));

        return $questionHelper->ask($input, $output, $question);
    }
293066
public static function input($question, $default = null)
    {
        echo $question.': ';
        $handle = fopen ('php://stdin', 'r');

        $answer = fgets($handle);
        fclose($handle);

        $answer = trim($answer);

        if(!$answer) {
            $answer = $default;
        }

        return $answer;
    }
844483
public function askChoice($question, array $options, $allowEmptyChoice = true, $default = null)
    {
        $this->write($this->encloseAsQuestion($question, $default));

        $optionValues = array_values($options);

        foreach ($optionValues as $key => $optionQuestion) {
            $this->write('[' . ($key+1) . ']' . $optionQuestion);               //+1 because normal people prefers 1 over 0 as first option
        }

        $validator = function ($choosenValue) use ($optionValues, $allowEmptyChoice, $default) {
            $isValidValue = isset($optionValues[$choosenValue-1]);
            $isAllowedEmpty = is_null($choosenValue) && $allowEmptyChoice;

            if ($isValidValue) {
                return $choosenValue;
            } elseif ($isAllowedEmpty) {
                return $default;
            }

            throw new InputException('Invalid value (' . $choosenValue . ') provided.');
        };

        $message = 'Choose' . ($allowEmptyChoice ? ' (Hit enter for no choice)' : '');

        $answer = $this->askAndValidate($message, $validator, false, $default);

        if (!is_null($answer)) {
            $optionRealValues = array_keys($options);
            $answer = $optionRealValues[$answer-1];
        }

        return $answer;
    }
610
private function choice($question, array $choices, $default, InputInterface $input, OutputInterface $output)
    {
        $helper = new QuestionHelper();

        $result = $helper->ask($input, $output, new ChoiceQuestion(
            $question,
            $choices,
            $choices[$default]
        ));

        $output->writeln('');

        return $result;
    }
227040
protected function confirm($text, $default = true)
    {
        $choices = $default ? 'Yn' : 'yN';
        $confirm = new ConfirmationQuestion("$text [$choices] ", $default);

        return $this->getHelper('question')->ask($this->input, $this->output, $confirm);
    }
103770
private function prompt( $question, $default ) {

		$question .= ': ';
		if ( function_exists( 'readline' ) ) {
			return readline( $question );
		}

		echo $question;

		$ret = stream_get_line( STDIN, 1024, "\n" );
		if ( Utils\is_windows() && "\r" === substr( $ret, -1 ) ) {
			$ret = substr( $ret, 0, -1 );
		}
		return $ret;
	}
446003
protected function askQuestion(string $description, string $default)
    {
        $helper   = $this->getHelper('question');
        $question = new Question($description, $default);
        $answer   = $helper->ask($this->input, $this->output, $question);

        return $answer;
    }
163937
public function askInput($questionText, $default = null, array $autoCompleterValues = [], callable $validator = null)
    {
        if ($default !== null) {
            $questionText .= ' <question>[' . $default . ']</question>';
        }
        $questionText .= ': ';
        $question = new Question($questionText, $default);
        if (!empty($autoCompleterValues)) {
            $question->setAutocompleterValues($autoCompleterValues);
        }
        if ($validator !== null) {
            $question->setValidator($validator);
            $question->setMaxAttempts(5);
        }

        return $this->ask($this->input, $this->output, $question);
    }
457936
public function input($question, $default = '', $options = [])
    {
        if (empty($default)) {
            $this->write($question . ' ');
        } elseif (empty($options)) {
            $this->write($question . ' [' . $default . '] ');
        } else {
            $available_options = [];
            foreach (strtolower($options) as $option) {
                if ($option === strtolower($default)) {
                    $option = strtoupper($option);
                }
                $available_options[] = $option;
            }
            $available_opts = rtrim(implode($available_options, '/'), '/');
            $this->write($question . ' [' . $available_opts . '] ');
        }
        $answer = rtrim(fgets(STDIN), PHP_EOL);
        if (empty($answer)) {
            return $default;
        }
        if (count($options) > 0) {
            if (!in_array(strtolower($answer), array_map('strtolower', $options))) {
                return $this->input($question, $default, $options);
            }
            return $answer;
        }
        return $answer;
    }
161331
public function get_question_options($question) {
        global $DB, $OUTPUT;
        // Get additional information from database
        // and attach it to the question object.
        if (!$question->options = $DB->get_record('question_truefalse',
                array('question' => $question->id))) {
            echo $OUTPUT->notification('Error: Missing question options!');
            return false;
        }
        // Load the answers.
        if (!$question->options->answers = $DB->get_records('question_answers',
                array('question' =>  $question->id), 'id ASC')) {
            echo $OUTPUT->notification('Error: Missing question answers for truefalse question ' .
                    $question->id . '!');
            return false;
        }

        return true;
    }
675941
public function getQuestion() : ?string 
    {
        if ( ! $this->hasQuestion()) {
            $this->setQuestion($this->getDefaultQuestion());
        }
        return $this->question;
    }
1049234
public function ask(string $prompt, array $validAnswers = [], string $default = null)
    {
        if ($validAnswers) {
            $answers = [];
            foreach ($validAnswers as $v) {
                if ($default && $default === $v) {
                    $answers[] = '[' . $v . ']';
                } else {
                    $answers[] = $v;
                }
            }
            $prompt .= ' (' . implode('/', $answers) . ')';
        }

        $prompt .= ' ';

        if ($this->style) {
            echo $this->formatter->getStartMark($this->style);
        }

        $answer = null;
        while (true) {
            $answer = trim($this->console->readLine($prompt));
            if ($validAnswers) {
                if (in_array($answer, $validAnswers, true)) {
                    break;
                }

                if (trim($answer) === '' && $default) {
                    $answer = $default;
                    break;
                }
                continue;
            }
            break;
        }

        if ($this->style) {
            echo $this->formatter->getClearMark();
        }

        return $answer;
    }