How do I count the correct answers in an interactive quiz in learnr?

49 Views Asked by At

This is a simple shiny_prerendered Rmd file. I want to count the number of correct answers from user interactions. Additionally, I would like to know how to reset the quiz programmatically, which would allow me to start over with all the questions when the code is executed.

---
title: "Hello, Tutorial!"
output: 
  learnr::tutorial
runtime: shiny_prerendered
---

```{r setup, include=FALSE}
library(learnr)
```

```{r letter-b, echo=FALSE}
question(
    "What number is the letter B in the English alphabet?",
    answer("8"),
    answer("14"),
    answer("2", correct = TRUE, ),
    answer("23")
    )
```

```{r letter-a, echo=FALSE}
question(
  "What number is the letter A in the English alphabet?",
  answer("8"),
  answer("14"),
  answer("1", correct = TRUE),
  answer("23")
)
```
0

There are 0 best solutions below