jdtrat / shinysurveys

Develop and deploy surveys in Shiny/R.
https://shinysurveys.jdtrat.com/
Other
97 stars 26 forks source link

Multiple pages? #21

Closed miiichaellam closed 3 years ago

miiichaellam commented 3 years ago

Hi, first off - great package, it's simple to use and im loving it. Just wondering if there is a way for me to spread the questions across multiple pages instead of all being on one?

jdtrat commented 3 years ago

Hi! Thank you! I've been meaning to add this feature for a little while. I should be able to get to it pretty soon, so I'll keep you updated!

jdtrat commented 3 years ago

@miiichaellam, in the development version, I've implemented multiple pages. If you add a page column to the data frame of questions, you can specify which page certain questions will be appear on. The page column is optional, though, so if you don't add it, the survey will only be on one page.

Take a look at the following example and let me know if this solution is helpful for you! If not, please let me know how I can improve it.


library(shiny)
# uncomment the following line once to install the development version
#remotes::install_github("jdtrat/shinysurveys@extend-shinysurveys")
library(shinysurveys)

page_example <- data.frame(
  question = c("What's your favorite food?", rep("Do you like SunButter®", 2),
               "Where do you live?", "What is the temperature where you are?"),
  option = c("Sushi", "Yes", "No", "North Carolina", "79"),
  input_type = c("text", rep("y/n", 2), "text", "numeric"),
  input_id = c("favorite_food", rep("sunbutter", 2), "location", "temperature"),
  dependence = NA,
  dependence_value = NA,
  required = FALSE,
  page = c("food", "food", "food", "second", "final")
)

ui <- fluidPage(
  surveyOutput(page_example, survey_title = "Multiple Page {shinysurveys} Example")
)

server <- function(input, output, session) {
  renderSurvey()
}

shinyApp(ui, server)
jdtrat commented 3 years ago

Hi! I'm getting ready to launch v0.2.0 of shinysurveys, so if you have any feedback, please let me know ASAP!

miiichaellam commented 3 years ago

@jdtrat so sorry for the late reply. This is fantastic and exactly what I was after, thank you 👍