checkUI: A User Interface for quick T/F questions about a...

View source: R/checkUI.R

checkUIR Documentation

A User Interface for quick T/F questions about a participant's qualifications or environment

Description

A User Interface for quick T/F questions about a participant's qualifications or environment

Usage

checkUI(
  id = "check",
  title = "",
  type = c("participant", "environment"),
  instructions = "default",
  align = "center"
)

Arguments

id

The module ID. Must be the same as the ID of checkServer().

title

Character. Usually, the title of the experiment. But can be anything else you want to be printed in large friendly letters at the top of the page.

type

Either "participant" or "environment", to specify whether you want to ask questions about a participant's qualifications (i.e., do they meet inclusion criteria) or their acoustic environment (i.e., is it quiet enough for speech research).

instructions

What should the participant do when the TRUE/FALSE question appears?

align

One of 'left', 'center', or 'right'. Should the elements in this UI be left-, center-, or right-aligned?

Value

User interface elements for TRUE/FALSE questions, displayed one at a time.

Examples

 # First get some sample questions for your participant.
data("qualifications")
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.")
      })
    }
  )
}

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