Skip to contents

There can be multiple items on any given page. Items can be different questions, or multiple variables that need to be saved from a single question. The question_text is typically saved in run_before and the reply (response_text and/or response_id) is typically saved in run_after.

Usage

set_item_data(
  session,
  page_id,
  item_id = NULL,
  question_text = NULL,
  response_text = NULL,
  response_id = NULL
)

Arguments

session

The shiny session

page_id

The page for which to retrieve data.

item_id

The item for which to set/update data. This has to be different for different items on the same page. Since most pages contain only a single question/item, item_id is set to "default" if missing.

question_text

The question's text. (optional)

response_text

The user's response in text form. (optional)

response_id

The user's response as an id from a set of choices. (optional)

Value

nothing

See also

Examples


if (FALSE) { # \dontrun{
# Set up a "fake" shiny session to store data
session <- shiny::MockShinySession$new()
session$userData <- list(
  current_page_id = "other_page",
  questionnaire_data = list(
    example_page = list()
  )
)

# This code is expected to be run in e.g. run_before or run_after
# It doesn't really make sense to run this code outside
set_item_data(
  session = session,
  page_id = "example_page",
  question_text = "How are you?"
)

set_item_data(
  session = session,
  page_id = "example_page",
  response_id = 3,
  response_text = "I'm doing great! (response_id = 3)"
)
} # }