class: center, middle, inverse .leftcol40[ <center> <img src="https://surveydown.org/images/logo.png" width=100%> </center> ] .rightcol60[ <br><br> # .font150[.fancy[Conditional Control]] ] --- class: inverse, middle # .fancy[Conditional Control] ### 1. Conditional display ### 2. Conditional skip forward --- class: inverse, middle # .fancy[Conditional Control] ### 1. .orange[Conditional display] ### 2. Conditional skip forward --- class: center, middle # Conditional Question Display --- class: center ## [Conditional question display](https://surveydown.org/docs/conditional-logic#conditional-question-display) <center> <img src="images/show_if.gif" width=68%> </center> --- .leftcol[ survey.qmd ``` r # Conditional question sd_question( type = "mc", id = "penguins", label = "Which is your favorite type of penguin?", option = c( "Adélie" = "adelie", "Chinstrap" = "chinstrap", "Gentoo" = "gentoo", "Other" = "other" ) ) # Target question sd_question( type = "text", id = "penguins_other", label = "Please specify the other penguin type:" ) ``` ] -- .rightcol[ app.R ``` r server <- function(input, output, session) { * sd_show_if( * input$penguins == "other" ~ "penguins_other" * ) # ...other server code... } ``` Condition ~ Target "If {condition}, then show {target}" ] --- class: center, middle # Conditional Page Display --- background-color: #fff class: center ## Example: Randomly display one of two page versions <br> <center> <img src="images/show_if_page.png" width: 100%> </center> --- .leftcol[.code70[ survey.qmd ```` markdown --- page1 This is page 1 ```{r} sd_next() ``` --- page2a This is page 2A ```{r} sd_next() ``` --- page2b This is page 2B ```{r} sd_next() ``` --- page3 This is page 3 ```` ]] -- .rightcol[ app.R ``` r server <- function(input, output, session) { # Generate random condition rand_val <- sample(c('A', 'B'), 1) # Store the condition value sd_store_value(rand_val) # Use sd_show_if to show target pages sd_show_if( rand_val == 'A' ~ 'page2a', rand_val == 'B' ~ 'page2b' ) sd_server() } ``` ] --- class: inverse, middle # .fancy[Conditional Control] ### 1. Conditional display ### 2. .orange[Conditional skip forward] --- class: center, middle # Example: **Participant screen out** --- class: center ### Example: **Participant screen out** <br> <center> <img src="images/screenout.png" width=70%> </center> --- .leftcol[ survey.qmd ```` markdown --- page1 ```{r} sd_question( type = 'mc', id = 'vehicle_ownership', label = "Do you own a vehicle?", option = c( 'Yes' = 'yes', 'No' = 'no' ) ) ``` --- screenout Sorry, but you are not qualified to take our survey. ```` ] .rightcol[ app.R ``` r server <- function(input, output, session) { * sd_skip_if( * input$vehicle_ownership == "no" ~ "screenout" * ) # ...other server code... } ``` Condition ~ Target Page "If {condition}, then skip to {target}" ] --- class: center, middle ## For both conditional display and conditional skip forward,<br>there are lots of [conditions to choose from](https://surveydown.org/docs/conditional-logic#common-conditions) --- class: inverse
−
+
15
:
00
## Your turn - Open the survey you were editing from your last practice. - Add conditional logic content: - Add one simple multiple choice question about your survey topic and another that will only display depending on a specific choice in the first question. - Add a target page that respondents should be sent to based on their choices in another question in an earlier page (e.g., a multiple choice question). ## OR: Open and play with the examples: - `part-2-conditional-display` - `part-2-conditional-navigation`