Documentation

Get All Children Question

When and Why to Use

Use this when you need a complete roster of children within an age window, including:

  • total count,
  • each child's age (with optional recodes),
  • each child's gender,
  • a readable "name" label (e.g., "16 year old son") for downstream questions.

Great for: youth-targeted studies, quota setup, segmentation, or routing follow-ups to each child profile.

Chat Experience
  • Three-step flow: count → ages → genders.
  • Copy for each step is customizable via question_1_text-question_3_text.
  • Gender terms shown to respondents can be mapped to "son/daughter" (or alternatives) via gender_map.
Traditional Experience
  • Sequential screens and compact multi-field forms.
  • Numeric input for count/ages; single/multi-select for genders.
  • Summary list of created child records before proceeding (optional).
Configuration Options
OptionTypeRequiredDefaultDescription
min_ageintyes-Minimum eligible age.
max_ageintyes-Maximum eligible age.
age_recodesdict[int, str] | NonenoNoneMap raw ages to recoded labels (e.g., 13: "Secondary").
gender_mapdict[str, str] | Noneno{"Male": "son", "Female": "daughter"}Maps gender to child term used in the "name" label.
question_1_textstr | Noneno"How many children do you have between the ages of {min_age} and {max_age}?"Custom text for count prompt.
question_2_textstr | Noneno"For each child, please let us know their age"Custom text for ages prompt.
question_3_textstr | Noneno"Now, please let us know their gender"Custom text for genders prompt.
idstr | NonenoNoneOptional stable identifier prefix for the generated child questions.
Return Value

List[StringResponse] - One StringResponse per child, in grid order, with tags attached:

  • age: the recoded age (if age_recodes supplied; otherwise raw age as string),
  • gender: the selected gender,
  • name: a readable label combining age and gender_map term (e.g., "16 year old son").

Children with the same age and gender remain separate entries in the list. If the respondent reports no eligible children, returns an empty list.

Example Code
Basic usage
from survey import Survey

s = Survey(**globals())

children = s.get_all_children_age_gender(
    min_age=5,
    max_age=18,
)

for child in children:
    s.text_question(
        "Thinking about {child}, what is their favorite subject in school?",
        tags=s.tag(child=child.name),
    )

s.complete()
With age recodes and custom gender terms
children = s.get_all_children_age_gender(
    min_age=5,
    max_age=17,
    age_recodes={
        5: "Pre-school",
        6: "Primary",
        7: "Primary",
        8: "Primary",
        9: "Primary",
        10: "Primary",
        11: "Secondary",
        12: "Secondary",
        13: "Secondary",
        14: "Secondary",
        15: "Secondary",
        16: "Secondary",
        17: "Secondary",
    },
    gender_map={"Male": "boy", "Female": "girl"},
)
Custom question copy
children = s.get_all_children_age_gender(
    min_age=10,
    max_age=16,
    question_1_text="Between {min_age} and {max_age}, how many children live in your household?",
    question_2_text="Please enter each child's age.",
    question_3_text="Please select each child's gender."
)
Notes
  • Validation is performed on raw ages; age_recodes affect labels/reporting only.
  • Expand gender options as needed (e.g., "Non-binary," "Prefer not to say"); use gender_map to control the child term used in name.
  • The name field is for respondent-friendly copy; avoid relying on it for programmatic logic - use age and gender tags instead.