You could try and register an 'extendInpuTtype'. This will help achieve your goal. However, there is some limitations with using the shiny widgets extension input for instance when displaying the choices in the ui. see code example below. You can play around with the various shiny inputs to see what will be aesthetically pleasing and consistent with your ui desires.
library(shiny)
library(shinysurveys)
df_1 <- data.frame(question = "what is your favorite food",
option = NA,
input_type = "slider",
input_id = rep("ID1", 7),
dependence = NA,
dependence_value = NA,
required = TRUE
)
df_2 <- data.frame(question = "Why is this your favorite food?",
option = NA,
input_type = "textSlider",
input_id = rep("ID2", 7),
dependence = rep("ID1", 7),
dependence_value = rep("1", 7),
required = TRUE
)
extendInputType(input_type = "slider", {
shiny::sliderInput(
inputId = surveyID(),
label = surveyLabel(),
min = 0,
max = 5,
value = 0
)
})
extendInputType("textSlider", {
shinyWidgets::sliderTextInput(
inputId = surveyID(),
label = surveyLabel(),
force_edges = TRUE,
choices = c("I Love it", "It's all I can afford")
)
})
df_merged <- rbind(df_1, df_2)
#create user interface
ui <- fluidPage(
surveyOutput(df = df_merged,
survey_title = "Dependant Qustionaire",
survey_description = "This is a two part survey that only shows the next question when the correct answer is provided to the first"))
#specify server function
server <- function(input, output, session) {
renderSurvey()
observeEvent(input$submit, {
showModal(modalDialog(
title = "Survey End!"
))
})
}
shinyApp(ui, server)