Creates a page where the response is to be selected from a dropdown list.

dropdown_page(
label,
prompt,
choices,
alternative_choice = FALSE,
validate = dropdown_page.validate(alternative_choice, alternative_text),
on_complete = NULL,
next_button_text = "Next",
max_width_pixels = 200,
)

## Arguments

label

Page label (character scalar).

prompt

Prompt to be displayed above the response choices. Can be either a character scalar (e.g. "What is 2 + 2?") or an object of class "shiny.tag", e.g. shiny::tags\$p("What is 2 + 2?").

choices

Character vector of choices for the participant. If names are provided, then these names will be used for display, whereas the values will be stored in the results.

alternative_choice

Whether or not to give the participant the option of providing a free-text response instead of selecting one of the dropdown options.

alternative_text

Prompt for the free-text box (only relevant if alternative_choice is set to TRUE).

Whether or not to save the answer.

validate

Optional validation function. The argument list should include ..., and any of: answer, the participant's most recent answer; state, the participant's state object; input, the current page's Shiny input object; opt, the test's option list as created by test_options(); session, the current Shiny session object. It should return TRUE for a successful validation; for an unsuccessful validation, it should return either FALSE or a character scalar error message. If validation fails then the page will be refreshed, usually to give the user a chance to revise their input.

on_complete

Optional function to execute on leaving the page (after successful validation). The argument list should include ..., and any of: state, the participant's state object; answer, the participant's most recent answer; input, the current page's Shiny input object; session, the current Shiny session object; opt, the test's option list as created by test_options().

next_button_text

Text to display on the next-page button (character scalar).

max_width_pixels

Maximum width of the response UI, in pixels.