Skip to contents

This function sets up the server-side logic for displaying a survey response data table in a Shiny application. It handles the rendering of the response table and controls its visibility based on various reactive values.

Usage

server_response(output, rv, show_response = TRUE)

Arguments

output

The Shiny output object

rv

A reactive values object containing:

  • survey_completed - Boolean indicating if survey is completed

  • loading - Boolean indicating loading state

  • survey_responses - Data frame of survey responses

  • error_message - String containing error message if any

show_response

Boolean indicating whether to show the response table

Value

None (called for side effects)

Details

The function creates two reactive outputs:

  • surveyResponseTable - A DataTable showing survey responses

  • showResponseTable - Controls visibility of the response table

The table will only be shown when:

  • The survey is completed

  • Data is not loading

  • There are no error messages

  • show_response parameter is TRUE

Examples

if (FALSE) { # \dontrun{
server <- function(input, output, session) {
  rv <- reactiveValues(
    survey_completed = FALSE,
    loading = FALSE,
    survey_responses = data.frame(),
    error_message = NULL
  )

  server_response(output, rv, show_response = TRUE)
}
} # }