consentUI: Shiny UI function for displaying a participant consent form

View source: R/consentUI.R

consentUIR Documentation

Shiny UI function for displaying a participant consent form

Description

Shiny UI function for displaying a participant consent form

Usage

consentUI(id = "consent", title = "Consent Form", filename = NULL)

Arguments

id

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

title

The title of the consent form. Defaults to "Consent Form."

filename

The name of the file containing the consent form text. This must be an HTML file stored in the app's www directory. If no filename is given, a generic consent text is used.

Value

A user interface that displays a custom consent form from a separate file, buttons for the participant to consent or decline, and (optionally) an opportunity for the participant to explicitly agree to audio recording.

Note

Events can be added to the "agree" button by accessing it among the app's inputs with the following (replace id with the id you supplied for the module): input[["id-agree"]].

See Also

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

Other Consent form module: consentServer()

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.