Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove exercise.error.checker in favor of exercise.error.check.code and -error-check chunks #426

Merged
merged 3 commits into from
Aug 28, 2020

Conversation

cpsievert
Copy link
Contributor

@cpsievert cpsievert commented Aug 28, 2020

Fixes #356
Fixes #425
Fixes rstudio/gradethis#140
Related rstudio/gradethis#143

After feedback from @garrettgman, and discussion with @schloerke, it's becoming apparent the exercise.error.checker probably isn't the right approach to exercise (evaluation) error checking.

This PR replaces exercise.error.checker with a slightly different option, exercise.error.check.code, which defines what checking code to run when an exercise error occurs. This option, in some sense, provides a global default value, which can be overridden for a particular exercise with a -error-check chunk. Overall this seems like a much cleaner solution than exercise.error.checker since it decouples error checking code from -code-check (pre-evaluation) and -check (post evaluation)

Testing notes

Install remotes::install_github("rstudio/learnr"); remotes::install_github("rstudio-education/gradethis"), then rmarkdown::run() the following document:

  1. Enter mtcars, then click "Submit". You should see positive (green) feedback.
  2. Enter cars, then click "Submit". You should see negative feedback with "This is the cars (not mtcars) dataset." in the message
  3. Enter mtc, then click "Submit". You should see negative feedback with both the submission (mtc) and the solution (mtcars)
  4. Enter mtc, then click "Run Code". You should see negative feedback that says object 'mtc' not found
```{r setup, include=FALSE}
library(learnr)
gradethis::gradethis_setup()
```

* Enter `mtcars`

```{r mtcars, exercise = TRUE}

```

```{r mtcars-solution}
mtcars
```

```{r mtcars-check}
grade_result(
  fail_if(~identical(.result, cars), "This is the cars (not mtcars) dataset."),
  pass_if(~identical(.result, mtcars))
)
```

…ck. This way the error check won't be run when 'Run Code' is clicked
@cpsievert cpsievert requested review from schloerke, nischalshrestha and garrettgman and removed request for schloerke August 28, 2020 16:37
Co-authored-by: Barret Schloerke <barret@rstudio.com>
@cpsievert cpsievert merged commit dc1dbdd into master Aug 28, 2020
@cpsievert cpsievert deleted the carson/feature/exercise-error-check-chunk branch August 28, 2020 19:57
schloerke added a commit that referenced this pull request Sep 2, 2020
* master:
  Rewrite exercise checking section (#427)
  Remove exercise.error.checker in favor of exercise.error.check.code and -error-check chunks (#426)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants