View source: R/consentServer.R
consentServer | R Documentation |
Shiny Server function for documenting participant consent
consentServer(
id = "consent",
trigger = NULL,
result = c("disable", "hide"),
delayResponse = 1000,
agreeLab = "Agree",
agreeId = "consent-yes",
disagreeLab = NULL,
disagreeId = "consent-no",
cons2rec = FALSE,
cons2recRequire = TRUE,
cons2recLab =
"This experiment requires us to make audio recordings of your voice.\n Do you consent to having your voice recorded?",
cons2recYes = "I consent to my voice being recorded for this research.",
cons2recNo = "I do NOT grant my consent for my voice to be recorded."
)
id |
The input ID associated with the consent module. Must match the ID of |
trigger |
A reactive value indicating the event that should trigger the appearance of the consent form. May be an |
result |
A character value describing what should happen when the participant gives consent. Must be either "disable" or "hide". |
delayResponse |
Integer. How long (in milliseconds) should the participant be forced to wait (i.e., to read the form text) before clicking "Agree" or "Disagree"? Defaults to no delay. |
agreeLab |
Character. The text to be displayed on the button that the participant will click to give their consent. Defaults to "I agree". |
agreeId |
Character. The inputId for the "agree" button. Defaults to "consent-yes". |
disagreeLab |
If not |
disagreeId |
If disagreeLab is not |
cons2rec |
Boolean. Should the participant be required to explicitly give their consent to be recorded? Default is |
cons2recRequire |
Boolean. If a separate consent to record is shown, should the participant be required to consent to voice recording before the can agree to the rest of the consent form and continue with the experiment? Defaults to |
cons2recLab |
Character. Label for the "Consent to Record" radio button pane. Defaults to a generic question about permission to record audio. |
cons2recYes |
Character. Label for the radio button the participant will click to agree to audio recording. Defaults to a generic statement. |
cons2recNo |
Character. Label for the radio button the participant will click to decline consent to audio recording. Defaults to a generic statement. |
A value of type integer
indicating whether the participant has given consent to the experiment and to record (=2), consent to everything not including recording (=1), or not consented to any portion of the experiment (=0).
Must be used with consentUI
. If cons2rec = TRUE
, consider using recordUI
and recordServer
.
Other Consent form module:
consentUI()
if (interactive()) {
ui <- shiny::fluidPage(
shiny::actionButton("ok", "OK"),
consentUI(id = "cons"),
textOutput("result")
)
server <- function(input, output, session) {
consent <- consentServer(id = "cons",
trigger = shiny::reactive(input$ok),
delayResponse = 3000,
agreeId = "agree",
disagreeLab = "Decline",
disagreeId = "disagree",
cons2rec = TRUE)
shiny::observeEvent(input$ok, {
shinyjs::hide("ok")
})
# Show the output value when the participant agrees.
shiny::observeEvent(input$agree, {
output$result <- shiny::renderText({consent$agree})
})
}
shiny::shinyApp(ui = ui, server = server)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.