This is the most general way to create a psychTestR page.
page(
ui,
admin_ui = NULL,
label = NULL,
final = FALSE,
get_answer = NULL,
save_answer = FALSE,
validate = NULL,
on_complete = NULL,
next_elt = TRUE
)
Page UI. Can be either a character scalar (e.g.
"Welcome to the test!") or an object of class "shiny.tag",
e.g. shiny::tags$p("Welcome to the test!")
.
Optional UI component for the admin panel.
Page label (character scalar).
Whether or not the page is the final page in the test.
Optional function for extracting the participant's
answer from the current page.
The argument list should include ...
, input
,
and optionally state
, the participant's state
object.
The function should extract the answer from the Shiny
input
object and return it as its output.
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()
.
(Logical scalar) Whether to go to the next element
in the timeline once this page is completed.
This will typically be TRUE
,
except for special cases such as pages that load
testing sessions from file (get_p_id
).