Documentation

Rating Question

When and Why to Use

Use this to capture how strongly a respondent feels about a given item or concept on a numeric scale. Ideal for:

  • Measuring attitudes or satisfaction
  • Capturing degrees of liking, agreement, or importance
  • Top-box / bottom-box analysis with recodes
Chat Experience
  • Slider, button, or star-style input depending on style
  • Labels shown inline or at ends of the scale
  • Optional "Don't know" button at the bottom if configured
Button style with imageSlider styleStar style with image
Button Markdown ImagesSlider Plain TextStar Plain Text Images
Traditional Experience
  • Input rendered more horizontally with larger interactive area
  • Works well with remote or keyboard input
Button style with an imageSlider style, mobile optimizedStar style with an image
Button Markdown ImagesRating Question Figure 01Star Plain Text Images
Configuration Options
OptionTypeRequiredDefaultDescription
questionstringyes-Text prompt shown to respondent
number_of_pointsintno5 or label countNumber of points on the scale
first_pointintno1 or first labelStarting value on the scale
stylestringnoslider"slider", "button", or "star"
labelsDict[int, str]no-Labels for specific points on the scale
imageMediaItemno-Optional image shown above the question
image_sizeTuple[int, int]no(600, 600)Bounding box size for a displayed image
defaultint | List[int]norandomDefault value used in test mode, or a list of candidate values — each simulated respondent picks one at random
dont_know_optionstrno-Adds a "Don't know" option with this label
recodesDict[str, str]no-Map numeric responses into grouped outputs
custom_validatorCallable[[int | str], str | None]no-Called with the parsed integer (the "Don't know" option arrives as its text); return an error message to reject
number_secondsintno0Seconds to wait before allowing the respondent to continue
tagss.tag()no-For token substitution in text and grouped reporting
idstr | NonenoNoneOptional stable identifier for this question
Example Code

Basic 5-point slider:

s.rating_question( "How much do you like this product?", number_of_points=5, style="slider", labels={ 1: "Dislike", 3: "Neutral", 5: "Like" } )

With recodes:

s.rating_question(
    "How much do you like this product?",
    number_of_points=5,
    recodes={
        "1": "dislike",
        "2": "dislike",
        "3": "neutral",
        "4": "like",
        "5": "like"
    }
)

With "Don't know" and tag token:

s.rating_question(
    "How do you rate {brand} cars?",
    number_of_points=5,
    labels={
        1: "Dislike",
        3: "Neutral",
        5: "Like"
    },
    dont_know_option="Don't know",
    tags=s.tag(brand="Ford")
)
Notes
  • Returns an IntResponse — the selected scale point behaves like a standard Python integer
  • slider and button styles include numeric values with labels
  • dont_know_option responses are recorded as -999 in the survey data and reported as the configured text
  • Use recodes to collapse scale points for reporting
  • custom_validator is helpful for attention checks or edge case handling