page: New page

pageR Documentation

New page

Description

This is the most general way to create a psychTestR page.

Usage

page(
  ui,
  admin_ui = NULL,
  label = NULL,
  final = FALSE,
  get_answer = NULL,
  save_answer = FALSE,
  validate = NULL,
  on_complete = NULL,
  next_elt = TRUE
)

Arguments

ui

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!").

admin_ui

Optional UI component for the admin panel.

label

Page label (character scalar).

final

Whether or not the page is the final page in the test.

get_answer

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.

save_answer

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_elt

(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).


pmcharrison/psychTestR documentation built on Nov. 10, 2024, 9:03 p.m.