Skip to content

grade_this_code() does not spot when arguments are missing #366

Open

Description

@garrettgman

I noticed while running the quarto-live exercise code example that grade_this_code() does not provide a sensible feedback message when a user fails to provide an expected argument.

Image

To recreate this error, run either of the quarto-live or rmarkdown scripts below. Then submit the answer starwars > distinct().

R Markdown:

---
title: "Untitled"
output: learnr::tutorial
runtime: shiny_prerendered
---

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

```{r ex_1, exercise = TRUE}
starwars |> ______
```

```{r ex_1-solution}
starwars |> distinct(hair_color)
```

```{r ex_1-check}
gradethis::grade_this_code()
```

Quarto-live:

---
format: live-html
engine: knitr
---

{{< include ./_extensions/r-wasm/live/_knitr.qmd >}}
{{< include ./_extensions/r-wasm/live/_gradethis.qmd >}}

```{webr}
#| exercise: ex_1
#| setup: true
library(dplyr)
```

```{webr}
#| caption: Sample Exercise
#| exercise: ex_1
starwars |> ______
```

::: {.solution exercise="ex_1"}

#### Solution

Use the `distinct()` function from the `{dplyr}` package.

```{webr}
#| exercise: ex_1
#| solution: true
starwars |> distinct(hair_color)
```

:::

```{webr}
#| exercise: ex_1
#| check: true
gradethis::grade_this_code()
```

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions