Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change default value of radio button to avoid selecting "FALSE" option #515

Merged
merged 4 commits into from
May 3, 2021

Conversation

gadenbuie
Copy link
Member

Reported: https://community.rstudio.com/t/avoid-pre-selected-answers-in-learnr-multiple-choice-questions/101950

Previously, when the answer label was "FALSE", that value would be selected because the default value of selected in radioButtons() was FALSE.

```{r KC-1, echo=FALSE}
question("TRUE or FALSE: My R Scripts can look sloppy as long as RStudio is able to run it.",
  answer("TRUE", message = "Not quite. Think about all the *computers* you are creating computer programs for."),
  answer("FALSE", correct = TRUE, message = "That's right. You should strive to make your computer programs should be interpretable by other humans as well."),
  allow_retry = FALSE
)
```

image

@gadenbuie
Copy link
Member Author

Hmm, it seems like character(0) might be a better default value for selected rstudio/shiny#2266 (comment):

FWIW, I think the way to go is to use character(0) to select none. That's how it works for the update functions updateCheckboxInput and updateSelectInput (and the docs say that's how it works for updateRadioButtons, although # 2688 says that's currently not true).

I'm not sure how far back compatibility goes for selected = character(0) in shiny. Thoughts @schloerke?

R/question_radio.R Outdated Show resolved Hide resolved
Co-authored-by: Barret Schloerke <barret@rstudio.com>
@gadenbuie gadenbuie merged commit 03a6db6 into rstudio:master May 3, 2021
@gadenbuie gadenbuie deleted the fix/default-radio branch May 3, 2021 17:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants