Creates a page where the response is to be selected from a dropdown list.
dropdown_page(
label,
prompt,
choices,
alternative_choice = FALSE,
alternative_text = "Other (please state)",
save_answer = TRUE,
validate = dropdown_page.validate(alternative_choice, alternative_text),
on_complete = NULL,
next_button_text = "Next",
max_width_pixels = 200,
admin_ui = NULL
)
Page label (character scalar).
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?")
.
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.
Whether or not to give the participant the option of providing a free-text response instead of selecting one of the dropdown options.
Prompt for the free-text box (only relevant
if alternative_choice
is set to TRUE
).
Whether or not to save the answer.
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.
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()
.
Text to display on the next-page button (character scalar).
Maximum width of the response UI, in pixels.
Optional UI component for the admin panel.