shinysurveys icon indicating copy to clipboard operation
shinysurveys copied to clipboard

Displaying surveys based on reactive dataframe input?

Open cmperez024 opened this issue 2 years ago • 0 comments

Hello.

One part of an app I'm making has users enter a URL to a google sheet which generates a survey based on the dataframe read from said sheet. I was able to get it working for the most part by creating a uiOutput which can be later updated using surveyOutput. This gets the survey displaying without using renderSurvey. However, there are some things that are supplied by renderSurvey, such as disabling the submit button if not all responses are filled in. Is there a way I can fix this?

df <- data.frame(question = "What is your favorite food?",
                 option = "Your Answer",
                 input_type = "text",
                 input_id = "favorite_food",
                 dependence = NA,
                 dependence_value = NA,
                 required = F)


  ui <- fluidPage(
    uiOutput("survey")
  )
  
  server <- function(input,output,session){

    # this reactive value in my app is updated based on what url the user submits.
    survey_df <<- reactiveVal(df)
    
    # in my app, this code is ran after the user submits a URL
    output$survey <- renderUI({
      surveyOutput(survey_df())
    })
        
    observeEvent(input$submit, {
    })
  }
  shinyApp(ui, server)

cmperez024 avatar Feb 22 '23 01:02 cmperez024