1

I am developing a tutorial using learnr (using gradethis to check codes). Here is my set-up chunk.

    ```{r setup, include=FALSE}
    library(learnr)
    library(gapminder)
    gm <- data.frame(gapminder)
    
    library(tidyverse)
    tutorial_options(exercise.timelimit = 60)
    gradethis::gradethis_setup(allow_partial_matching=TRUE)
    ```

Here is the simple exercise:

Using gm, find the the GDP of Zimbabwe in 1997

```{r gdpzim, exercise=TRUE}
gm[...,...]
```

```{r gdpzim-solution, exercise.reveal_solution = FALSE}
gm[gm$country == "Zimbabwe" & gm$year==1997,  "gdpPercap"]
```

```{r gdpzim-code-check}
grade_this_code()
```

```{r gdpzim-check}
sol <- gm[gm$country == "Zimbabwe" & gm$year==1997,  "gdpPercap"]
grade_result(
  pass_if(~identical(.result, sol ))
)
```

I would like to find so that code-check accepts both:

gm[gm$country == "Zimbabwe" & gm$year==1997,  "gdpPercap"]

or

gm[gm$year==1997 & gm$country == "Zimbabwe" ,  "gdpPercap"]

As it is now, the second solution is rejected.

This is just a generic question, since there are often different ways to write a solution that is acceptable for a given problem.

djourd1
  • 459
  • 4
  • 14
  • 1
    We're working on adding support for multiple solutions in gradethis grading code. Initial support is pretty low-level but we hope to have some higher-level helper functions soon. Here's the pull request for initial support, I used your example to demo the feature. https://github.com/rstudio/gradethis/pull/286 – grrrck Feb 15 '22 at 17:43

0 Answers0