Skip to content

survey_version_question_branch_conditions

Overview

The conditions belonging to a branch rule: which question's answer, in which state, makes the rule hold.

Table Definition

Logical name Physical name Column Type PK Relation Unique Nullable Default Notes
Branch condition survey_version_question_branch_conditions id uuid โ—ฏ gen_random_uuid()
branch_rule_id uuid survey_version_question_branch_rules:id (cascade)
source_question_code varchar(100) Source question code. intro questions cannot be used
operator branch_operator Condition operator
comparison_value text Comparison value: choice label / matrix row label / FA matching text
sub_comparison_value text โ—ฏ Matrix column label / FA target field label. null = any field
sub_question_index integer โ—ฏ Sub-question index for SA / MA. null = treat all sub-questions flatly
sort_order integer Position within the rule
created_at timestamptz now()

Relations

  • branch_rule_id โ†’ survey_version_question_branch_rules.id (onDelete: cascade)

Indexes

  • Primary key (id)
  • UNIQUE INDEX: branch_conditions_rule_order_idx (branch_rule_id, sort_order)

Condition Operators

Value UI label Main targets Description
equals equals SA The specified choice is selected
includes includes MA / TM / PD / FA Includes the specified choice. For FA, a partial match on the entered text
not_includes does not include MA / TM / PD / FA Does not include the specified choice. Also holds when unanswered
only is only MA / TM Only the specified choice is selected
not_only is not only MA / TM Something other than the specified choice is also selected (also holds when unanswered)
has_other has other than MA / TM Something other than the specified choice is selected
answered answered FA Some input is present

Filling In the Values per Target

Target comparison_value sub_comparison_value sub_question_index
SA / MA / PD Choice label โ€” Position, when sub-questions exist
TM (matrix) Row label Column label โ€”
FA Text to match Label of the target field (null = any field) โ€”

Notes

  • Why labels rather than IDs: choices are recreated on every question update, so their IDs change. Comparison values therefore use the stable label string
  • Mapping to the CS verb: equals / includes โ†’ 0, not_includes โ†’ 1, only โ†’ 2, has_other โ†’ 3, not_only โ†’ 4. answered is converted as verb 3 with an empty comparison value
  • Unanswered handling: not_includes and not_only also hold when unanswered, matching the CS definitions
  • Matrix conditions are specified at cell level (row ร— column), corresponding to CS's answer_item_id (row) + sub_item_id (column)