gradecode

gradecode provides functions for grading code input by students with gradethis. You can learn about the various gradecode functions in the function reference.

gradecode is designed for use with gradethis in learnr tutorials. We recommend that you first be comfortable grading learnr tutorials with gradethis before you begin using gradecode. You can learn more with the gradethis package documentation and the learnr package documentation.

Installation

gradecode is still in development and not on CRAN yet. The development version of gradecode can be installed from GitHub with:

# install.packages("pak")
# pak::pkg_install("rstudio/gradecode")
install.packages("gradecode", repos = c('https://rstudio.r-universe.dev', 'https://cloud.r-project.org'))

Usage

To use gradecode in a learnr tutorial, start by loading gradecode after learnr and gradethis in the setup chunk of your tutorial:

```{r setup}
library(learnr)
library(gradethis)
library(gradecode)
library(dplyr)
```

Then include one of the gradecode functions in your gradethis code. For example, if you want to ensure the student uses a pipe in their response, you could set up your exercise like this:

```{r exercise, exercise = TRUE}

```

```{r exercise-solution}
mtcars %>%
  group_by(am) %>%
  summarise(avg_mpg = mean(mpg))
```

```{r exercise-check}
grade_this({
  find_pipes(.user_code) %>%
    fail_if_not_found("I expected you to use a pipe (`%>%`).")
    
  # Further grading code...
})
```

Learn more about the various gradecode functions in the function reference.

Code of Conduct

Please note that the tblcheck project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.