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

Support for Shiny and learnr style questions #46

Closed
ryjohnson09 opened this issue Aug 16, 2024 · 1 comment
Closed

Support for Shiny and learnr style questions #46

ryjohnson09 opened this issue Aug 16, 2024 · 1 comment

Comments

@ryjohnson09
Copy link
Contributor

I'd love to ask questions using quarto-live similar to the learnr example found here: https://learnr-examples.shinyapps.io/ex-setup-r/#section-welcome

Things like multiple-choice and radio buttons.

Maybe this is already possible?

@georgestagg
Copy link
Member

georgestagg commented Aug 27, 2024

I agree this is a good idea, but I'm going to close this in favour of tracking the request as part of #9.

In the mean time, you can manually setup something similar to this using webR+OJS. The approach in #43 is pretty good:

```{webr}
#| edit: false
#| output: false
#| define:
#|   - ok_reponse
library(htmltools)
ok_reponse <- function(reponse, n) {
  if (is.na(reponse)) HTML("")
  else if (reponse == n) div(HTML("Correct ✓"), style = "color: green")
  else div(HTML("Incorrect ✗"), style = "color: red")
}
```

```{ojs}
//| echo: false
mutable ok_reponse = (reponse, n) => { return html`Loading...` };
viewof reponse = Inputs.radio(
  new Map([
    ["First choice.", 1],
    ["Second choice.", 2],
    ["Third choice", 3],
    ["Fourth choice.", 4]
  ])
);
ok_reponse(reponse, 2);
```

But clearly it would be better if these implementation details were automated away.

@georgestagg georgestagg closed this as not planned Won't fix, can't repro, duplicate, stale Aug 27, 2024
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

No branches or pull requests

2 participants