Skip to content

questions

Preparation for getting answers for questions.

Classes

Functions

answer_question

answer_question(
    question: Question,
    running_context: dict,
    question_ui: Callable,
    answer_map: Optional[dict] = None,
    default_overrides: Optional[dict] = None,
) -> Dict[str, Any]

Determine the answer to a question.

  • if question name in overlay’s answer_map - return answer_map[question_name]
  • Update default with overlay’s default (if it exists)
  • Render default using running_context
  • render force_default using running_context
  • if force_default - return default
  • else - return response from send question information to user interface
PARAMETER DESCRIPTION
question

The question configuration.

TYPE: Question

running_context

The current running context used for rendering defaults, answer mappings, and when conditions.

TYPE: dict

question_ui

A callable that takes question information and returns the result from the user interface.

TYPE: Callable

answer_map

A mapping of question keys to answers.

TYPE: Optional[dict] DEFAULT: None

default_overrides

A mapping of question keys to default values.

TYPE: Optional[dict] DEFAULT: None

RETURNS DESCRIPTION
Dict[str, Any]

A dictionary with the question’s name -> value

filter_choices

filter_choices(
    choices: List[Choice], running_context: dict
) -> dict

Filter the choices to a question using the running context.

  • for each choice - render skip_when using running_context - if skip_when - don’t include the choice in the dictionary - else - add the label->value to the dictionary
PARAMETER DESCRIPTION
choices

A list of choice objects that require filtering

TYPE: List[Choice]

running_context

The context used for rendering skip_when expressions

TYPE: dict

RETURNS DESCRIPTION
dict

The dictionary of valid label->value choices.