# `Omni.Question.Choice`
[🔗](https://github.com/aaronrussell/omni/blob/v2.0.0/lib/omni/question/choice.ex#L1)

A question with one answer from a fixed set of choices.

Answered by `Omni.Answer.Choice`. Build one with `new/2`, or `Omni.choice/2`.

## Struct fields

- `:instructions` - the question, as parts (see `Omni.Question`)
- `:choices` - the options in order, as `{key, description}` pairs. Keys
  are atoms or strings and come back as given in the answer; a `nil`
  description means the model judges the option by its key alone

# `t`

```elixir
@type t() :: %Omni.Question.Choice{
  choices: [Omni.Question.option()],
  instructions: Omni.Question.instructions()
}
```

A question with one answer from a set of choices.

# `new`

```elixir
@spec new(Enumerable.t()) :: t()
```

Creates a choice question from a keyword list or map of fields.

Instructions are built into parts (see `Omni.Question`) and choices into
`{key, description}` pairs, as in `new/2`.

```elixir
Omni.Question.Choice.new(instructions: "...", choices: [:a, :b])
```

# `new`

```elixir
@spec new(Omni.Question.instructions_input(), [
  Omni.Question.key() | Omni.Question.option()
]) :: t()
```

Creates a question with one answer from a set of choices.

Each choice is a key, or a `{key, description}` pair; a choice without a
description is judged by its key alone.

```elixir
Omni.Question.Choice.new("Which team owns this?", [:billing, :infra, :other])

Omni.Question.Choice.new("Which team owns this?",
  billing: "Payments and refunds",
  infra: "Outages",
  other: nil
)
```

---

*Consult [api-reference.md](api-reference.md) for complete listing*
