consentServer: Shiny Server function for documenting participant consent

View source: R/consentServer.R

consentServerR Documentation

Shiny Server function for documenting participant consent

Description

Shiny Server function for documenting participant consent

Usage

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

Arguments

id

The input ID associated with the consent module. Must match the ID of consentUI().

trigger

A reactive value indicating the event that should trigger the appearance of the consent form. May be an input$... value from outside the module wrapped in reactive().

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 NULL (the default), a button will be shown alongside the "agree" button, that the participant may click to decline their consent. The character string provided here will serve as the label for that button.

disagreeId

If disagreeLab is not NULL, a character string representing the inputId for the disagree button. Defaults to "consent-no"

cons2rec

Boolean. Should the participant be required to explicitly give their consent to be recorded? Default is FALSE.

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 TRUE.

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.

Value

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

See Also

Must be used with consentUI. If cons2rec = TRUE, consider using recordUI and recordServer.

Other Consent form module: consentUI()

Examples

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)
}


abbey-thomas/speechcollectr documentation built on Nov. 19, 2024, 7:09 p.m.