---
echo: false
warning: false
theme: [league, weekly.scss] ## night & league
---
``{r, echo=FALSE}
library(surveydown)
``
{.absolute height="100"}
::: {#welcome .sd-page}
# Welcome to our survey!
$I_i(\theta)=a^{2}_iP_i(\theta)Q_i(\theta)$
[This is a simple demonstration of a `surveydown` survey. It has two pages with one question on each page.]{.kulas3}
Here is a basic "multiple choice" question, created using `type = 'mc'` inside the `sd_question()` function:
``{r}
#| echo: false
sd_question(
type = 'mc',
id = 'penguins',
label = "$I_i(\\theta)=a^{2}_iP_i(\\theta)Q_i(\\theta)$",
option = c(
'Adélie' = 'adelie',
'Chinstrap' = 'chinstrap',
'Chilly Willy' = "chilly",
'Downy WP' = 'woody',
"Gentoo" = 'gentoo'
)
)
``
You need to insert next buttons with `sd_next()` and set the `next_page` argument to the name of the page you want to go to next.
``{r}
sd_next(next_page = 'page2')
``
:::
::: {#page2 .sd-page}
This is another page in your survey.
{surveydown} supports many types of questions. For example, here is a simple `text` type question:
``{r}
sd_question(
type = "text",
id = "silly_word",
label = "Write a silly word here:"
)
sd_next(next_page = 'end')
``
:::
``{r}
sd_question(
type = 'slider',
id = 'climate_care',
label = "To what extent do you believe human-caused climate change is real?",
option = c(
"Don't Believe" = "dont_believe",
"Somewhat Believe" = "somewhat",
"Neutral" = "neutral",
"Believe" = "believe",
"Strongly Believe" = "strongly_believe"
)
)
``
``{r}
sd_question(
type = 'mc_buttons',
id = 'fruit',
label = "Which fruit do you prefer most from this list?",
option = c(
"Apple" = "apple",
"Banana" = "banana",
"Pear" = "pear",
"Strawberry" = "strawberry",
"Grape" = "grape",
"Mango" = "mango",
"Watermelon" = "watermelon"
)
)
``
::: {#end .sd-page}
## End
This it the last page in the survey.
``{r}
sd_close("Exit Survey")
``
:::
# remotes::install_github("surveydown-dev/surveydown", force = TRUE)library(surveydown)# Database setup# surveydown stores data on a database that you define at https://supabase.com/# To connect to a database, update the sd_database() function with details# from your supabase database. For this demo, we set ignore = TRUE, which will# ignore the settings and won't attempt to connect to the database. This is# helpful for local testing if you don't want to record testing data in the# database table. See the documentation for details:# https://surveydown.org/store-datadb <-sd_database(host ="",dbname ="",port ="",user ="",table ="",ignore =TRUE)# Server setupserver <-function(input, output, session) {# Define any conditional skip logic here (skip to page if a condition is true)sd_skip_if()# Define any conditional display logic here (show a question if a condition is true)sd_show_if()# Database designation and other settingssd_server(db = db )}# shinyApp() initiates your app - don't change itshiny::shinyApp(ui =sd_ui(), server = server)# viola