View source: R/headphoneTestServer.R
headphoneTestServer | R Documentation |
The server portion of the Headphone Test module. Make your headphoneTestUI() do things!
headphoneTestServer(
id = "headphone_test",
trigger = NULL,
type = c("huggins", "antiphase"),
n_trials = 6,
threshold,
n_attempts = 2,
warn_msg = "default",
fail_msg = "default",
success_msg = "default"
)
id |
The Id of this module. Must match the Id of |
trigger |
Optional. A reactive expression indicating the event that should trigger the appearance of the consent form. Must be wrapped in |
type |
Whether to use the Huggins Pitch headphone screen (see Milne et al., 2020) or the Antiphase headphone screen (Woods et al., 2017). Must be one of "huggins" or "antiphase" and must match the value given in |
n_trials |
Integer. How many trials should be presented to each participant? Defaults to 6. Must match the n_trials argument of |
threshold |
Integer. How many trials must a participant get correct to pass the screen? |
n_attempts |
Integer. How many attempts to pass the screen should a participant get? Defaults to 2. |
warn_msg |
An optional character vector. Customize the text of the warning message that appears when a participant fails the screen but is given another opportunity to pass. |
fail_msg |
An optional character vector. Customize the text of the message shown to participants when they fail the headphone screen on their final attempt. |
success_msg |
An optional character vector. Customize the text of the "success" message when the participant passes the headphone screen. |
A reactive value, status, that has a value of 0 (failed/did not complete headphone screen) or 1 (passed headphone screen).
Milne, A.E., Bianco, R., Poole, K.C., Zhao, S., Oxenham, A.J., Billing, A.J., & Chait, M. 2021. An online headphone screening test based on dichotic pitch.Behavior Research Methods 53, 1551-1562.
Woods, K.J.P., Siegel, M.H., Traer, J., & McDermott, J.H. 2017. Headphone screening to facilitate web-based auditory experiments. Attention, Perception, & Psychophysics 79, 2064-2072.
wwwPrep
, headphoneTestUI
Other headphone screen module:
headphoneTestUI()
## First use wwwPrep() to get the data for the type of headphone screen you want.
## NOTE: Do NOT put this command in your UI!
# Run it once before testing your app to create the www folder.
wwwPrep(HugginsPitchScreen = TRUE)
# Now build the app.
if (interactive()) {
ui <- fluidPage(
headphoneTestUI(id = "headphone_test", type = "huggins"),
textOutput("done")
)
server <- function(input, output, session) {
# Give the reactive value output a name, so it can be checked and accessed later.
phones <- headphoneTestServer(id = "headphone_test", type = "huggins",
n_trials = 6, threshold = 4, n_attempts = 2)
observeEvent(phones(), {
if (phones() == 1) {
output$done <- renderText("Headphone test successfully completed!")
}
})
}
shinyApp(ui = ui, server = server)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.