Skip to content

Instantly share code, notes, and snippets.

@jmclawson
Last active March 2, 2025 18:58
Show Gist options
  • Save jmclawson/8810de17f5b9cb2389970651a4bdcf7d to your computer and use it in GitHub Desktop.
Save jmclawson/8810de17f5b9cb2389970651a4bdcf7d to your computer and use it in GitHub Desktop.
RStudio snippet for learnr exercises with quarto-live
snippet exercise
```{webr}
#| exercise: ${1:label}
#| setup: true
```
```{webr}
#| caption: Exercise
#| exercise: ${1:label}
```
::: {.hint exercise="${1:label}"}
::: {.callout-note collapse="false"}
#### Hint 1
<!-- hint text here -->
```{r}
#| eval: false
${3:hintcode}
```
:::
:::
::: {.solution exercise="${1:label}"}
::: {.callout-tip collapse="false"}
#### Solution
<!-- Solution text here -->
```{webr}
#| exercise: ${1:label}
#| solution: true
${2:solutioncode}
```
:::
```{webr}
#| exercise: ${1:label}
#| check: true
#| class: wait
gradethis::grade_this_code()
```
@jmclawson
Copy link
Author

jmclawson commented Feb 20, 2025

Copy into RStudio using Tools > Edit Code Snippets... > Markdown.

To use in a Quarto file, type "exercise" and then hit Shift + Tab.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment