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

A question rating the state on an ordered scale of levels.

Answered by `Omni.Answer.Score`, whose score is the probability-weighted
average of the level indices (the first level is 0). Build one with
`new/2`, or `Omni.score/2`.

## Struct fields

- `:instructions` - the question, as parts (see `Omni.Question`)
- `:levels` - the levels from lowest to highest, as `{key, description}`
  pairs. Keys are atoms or strings and come back as given in the answer;
  a `nil` description means the key itself describes the level

# `t`

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

A question rating the state on an ordered scale.

# `new`

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

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

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

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

# `new`

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

Creates a question rating the state on an ordered scale.

Levels run from lowest to highest. Each is a key, or a `{key, description}`
pair; the answer's score is the probability-weighted average of the level
indices, starting at 0.

```elixir
Omni.Question.Score.new("How angry is the customer?", ["Calm", "Frustrated", "Very angry"])

Omni.Question.Score.new("How urgent is this?",
  low: "Can wait",
  medium: "Needs attention this week",
  high: "Needs attention today"
)
```

---

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