checkServer | R Documentation |
Present participants with a set of TRUE/FALSE questions one at a time. These are commonly used to check that participants meet inclusion criteria or get information about their current environment. It is recommended that experimenters confirm that participants meet qualifications before doing any data collection.
checkServer(id = "check", trigger, questionFile, outFile = NULL, returnVals)
id |
The module ID. Must be the same as the ID of |
trigger |
A reactive value indicating the event that should trigger the appearance of the consent form. May be an |
questionFile |
A .csv file containing ALL and ONLY the following columns: id, priority, label, error. See Details below for more information. |
outFile |
An optional file name for the (optional) return file where the participant's T/F answers will be saved. |
returnVals |
A list of input IDs from the column "id" in |
The questionFile argument is the source for the questions that should be displayed to the participant as statements or questions to which they must answer TRUE or FALSE. We have packaged some generic sets of questions with speechcollectr. You may access them using data("qualifications")
or data("environment")
. Any question file must contain ONLY the following columns:
"id:"Gives a unique input ID for each question. Values MUST be unique for each row and follow the same rules as other Shiny input IDs (no spaces).
"label:"Contains the labels (i.e., the questions or statements) that will be displayed to participants.
"priority:"All items in the check
module require an answer, but this column specifies whether the question on each row requires an answer of TRUE. There are two accepted options (required and optional), denoted by the following values (values separated by pipe (|) are treated as equivalent): 'required'|'req'|'r' and 'optional'|'opt'|'o'.
"error:" This column is required if ANY value in priority
is equal to "required". This is the error message the participant will see when they answer FALSE to a question that requires an answer of TRUE.
Answers that the participant gave to the questions whose input IDs are listed in the argument returnVals
.
# First get some sample questions for your participant.
data("qualifications")
utils::write.csv(qualifications, "qualifications.csv", row.names = FALSE)
# Now ask the questions!
if (interactive()) {
shinyApp(
ui = fluidPage(
fluidRow(
column(width = 8, offset = 2,
actionButton("btn", "Click me"),
checkUI(id = "example", title = "Speech Experiment",
type = "participant"),
textOutput("confirmation"))
)
),
server = function(input, output, session) {
answer <- checkServer(id = "example",
trigger = reactive(input$btn),
questionFile = "qualifications.csv",
outFile = NULL,
returnVals = c("eighteen"))
observeEvent(input$btn, {
shinyjs::hide("btn")
})
observe({
if (isTruthy(answer$eighteen))
output$confirmation <- renderText("This participant is an adult.")
})
}
)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.