Omni.Question.Choice (Omni v2.0.0)

Copy Markdown View Source

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

Summary

Types

t()

A question with one answer from a set of choices.

Functions

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

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

Types

t()

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

A question with one answer from a set of choices.

Functions

new(attrs)

@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.

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

new(instructions, choices)

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.

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
)