get_item_data {occupationMeasurement} | R Documentation |
Retrieve data for an item.
Description
Each page in the questionnaire can have multiple items on it.
Usage
get_item_data(
session,
page_id,
item_id = NULL,
key = c("all", "question_text", "response_text", "response_id"),
default = NULL
)
Arguments
session |
The shiny session |
page_id |
The page for which to retrieve data. |
item_id |
The item for which to retrieve data.
This has to be different for different items on the same page.
Since most pages contain only a single question/item, |
key |
The key for which to retrieve a value. (Optional) If no key is provided, the items's whole data will be returned. |
default |
A default value to return if the key or page is not present in the questionnaire data. |
Value
The items's data.
See Also
Examples
## Not run:
# 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?"
)
# This code is expected to be run in e.g. run_before
get_item_data(
session = session,
page_id = "example_page"
)
## End(Not run)
[Package occupationMeasurement version 0.3.2 Index]