vibe.paging

Group status computation for grouped interview mode.

This module provides functions to compute group statuses based on: - Question relevance (determined by template probing) - Current answers in session state - Validation errors

Group statuses: - not_relevant: No questions in this group are currently relevant - not_started: Group has relevant questions but none are answered - in_progress: Some questions answered or validation errors present - complete: All required relevant questions answered with no errors

ProgressCounts

Required-question progress counts.

compute_group_status

compute_group_status(group: GroupConfig, relevant_blocks: set[str], current_state: dict[str, Any], validation_errors: dict[str, Any], questions: dict[str, Any]) -> GroupStatus

Compute the status of a single group.

Parameters:
  • group (GroupConfig) –

    The GroupConfig to compute status for

  • relevant_blocks (set[str]) –

    Set of question IDs that are currently relevant

  • current_state (dict[str, Any]) –

    Current session state with answers

  • validation_errors (dict[str, Any]) –

    Dict of validation errors keyed by question ID

  • questions (dict[str, Any]) –

    Question definitions from template

Returns:
  • GroupStatus

    One of: "not_relevant", "not_started", "in_progress", "complete"

compute_all_group_statuses

compute_all_group_statuses(groups: list[GroupConfig], relevant_blocks: set[str], current_state: NestedValue, validation_errors: dict[str, Any], questions: dict[str, Any]) -> dict[str, GroupStatus]

Compute status for all groups.

Parameters:
  • groups (list[GroupConfig]) –

    List of GroupConfig objects

  • relevant_blocks (set[str]) –

    Set of question IDs that are currently relevant

  • current_state (NestedValue) –

    Current session state with answers

  • validation_errors (dict[str, Any]) –

    Dict of validation errors keyed by question ID

  • questions (dict[str, Any]) –

    Question definitions from template

Returns:
  • dict[str, GroupStatus]

    Dict mapping group_id to GroupStatus

get_first_relevant_group

get_first_relevant_group(groups: list[GroupConfig], relevant_blocks: set[str]) -> str | None

Get the ID of the first group that has at least one relevant question.

Parameters:
  • groups (list[GroupConfig]) –

    List of GroupConfig objects

  • relevant_blocks (set[str]) –

    Set of question IDs that are currently relevant

Returns:
  • str | None

    Group ID of first relevant group, or None if no groups are relevant

get_next_relevant_group

get_next_relevant_group(groups: list[GroupConfig], current_group_id: str, relevant_blocks: set[str]) -> str | None

Get the ID of the next group (after current) that has relevant questions.

Parameters:
  • groups (list[GroupConfig]) –

    List of GroupConfig objects

  • current_group_id (str) –

    ID of the current group

  • relevant_blocks (set[str]) –

    Set of question IDs that are currently relevant

Returns:
  • str | None

    Group ID of next relevant group, or None if no more relevant groups

get_prev_relevant_group

get_prev_relevant_group(groups: list[GroupConfig], current_group_id: str, relevant_blocks: set[str]) -> str | None

Get the ID of the previous group (before current) that has relevant questions.

Parameters:
  • groups (list[GroupConfig]) –

    List of GroupConfig objects

  • current_group_id (str) –

    ID of the current group

  • relevant_blocks (set[str]) –

    Set of question IDs that are currently relevant

Returns:
  • str | None

    Group ID of previous relevant group, or None if no previous relevant groups

get_group_by_id

get_group_by_id(groups: list[GroupConfig], group_id: str) -> GroupConfig | None

Get a GroupConfig by its ID.

Parameters:
  • groups (list[GroupConfig]) –

    List of GroupConfig objects

  • group_id (str) –

    ID of the group to find

Returns:
  • GroupConfig | None

    The GroupConfig or None if not found

build_paged_context

build_paged_context(template: TemplateData, current_group_id: str, relevant_blocks: Collection[str], current_state: NestedValue, validation_errors: dict[str, Any]) -> dict[str, Any]

Build the full paged context dict for template rendering.

Parameters:
  • template (TemplateData) –

    TemplateData object with groups and questions attributes

  • current_group_id (str) –

    ID of the current group

  • relevant_blocks (Collection[str]) –

    Collection of question IDs that are currently relevant (list or set)

  • current_state (NestedValue) –

    Current session state with answers

  • validation_errors (dict[str, Any]) –

    Dict of validation errors keyed by question ID

Returns:
  • dict[str, Any]

    Dict with keys: groups, current_group_id, current_group, prev_group_id,

  • dict[str, Any]

    next_group_id, group_statuses, current_group_title, visible_group_ids,

  • dict[str, Any]

    current_group_index, total_groups

compute_group_progresses

compute_group_progresses(groups: list[GroupConfig], relevant_blocks: set[str], current_state: NestedValue, questions: dict[str, Any]) -> dict[str, ProgressCounts]

Compute required-question progress counts for all groups.

Only relevant questions are counted.

compute_overall_progress

compute_overall_progress(relevant_blocks: Iterable[str], current_state: NestedValue, questions: dict[str, Any]) -> ProgressCounts

Compute required-question progress across all relevant questions.