Skip to content

gradethis helps scale feedback for learnr exercises. Instructors can use a model solution as a template or write highly customized testing logic to provide specific feedback for common mistakes.

gradethis is designed for use in learnr tutorials. We recommend that you first be comfortable writing learnr tutorials before you begin incorporating exercise feedback with gradethis. You can learn more about learnr tutorials with the learnr package documentation.

A screenshot of the gradethis package in action. An exercise starts with the following instructions: 'Here is a number. You can do great things with it, like this: Take the square root of the log of the number 2. Then click Submit Answer.' The student has entered the following code: '2'. The gradethis package generates the following message: 'I expected a call to sqrt() where you wrote 2. Try it again; next time's the charm!'

Installation

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

# install.packages("remotes")
remotes::install_github("rstudio/gradethis")

Usage

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

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

gradethis provides two grading modalities. You can:

  1. Compare student code to model solution code with grade_this_code(), or

  2. Write custom grading logic with grade_this().

Learn more about where and how to write exercise-checking code in vignette("gradethis").

Getting help

RStudio Community: Teaching RStudio Ask a question: gradethis

There are two main places to get help:

  1. The gradethis tag on RStudio Community is a friendly place to ask any questions about gradethis and the R Markdown family of packages. Additionally, we invite instructors to join the Teaching Category on RStudio Community, where any discussions about teaching are welcome.

  2. Stack Overflow can be a source of answers to common gradethis questions. It is also a great place to get help, once you have created a reproducible example that illustrates your problem.

Code of Conduct

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