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

Throw an informative error if an exercise chunk is NULL #411

Merged
merged 2 commits into from
Jul 30, 2020

Conversation

cpsievert
Copy link
Contributor

@cpsievert cpsievert commented Jul 29, 2020

Closes #172
Closes #410

Testing notes

Install remotes::install_github("rstudio/learnr") and run the following tutorial (rmarkdown::run("test.Rmd")). After these changes, you should now get the following error (i.e., the test passes if you see this error):

Error: The exercise chunk 'foo' doesn't have anything inside of it. Try adding empty line(s) inside the code chunk.
---
title: "Issue #410"
output: learnr::tutorial
runtime: shiny_prerendered
---

```{r setup, include=FALSE}
library(learnr)
library(gradethis)
tutorial_options(exercise.checker = grade_learnr)
knitr::opts_chunk$set(echo = FALSE)
```

## Minimal example

This chunk isn't treated as an exercise!

```{r foo, exercise = TRUE}
```

```{r foo-solution}
sum(1)
```

```{r foo-check}
grade_code()
```

@schloerke
Copy link
Collaborator

Tested on #172. ✅

❯❯ rmarkdown::run("learnr_issue_172.Rmd")
Loading required namespace: shiny


processing file: learnr_issue_172.Rmd
  |........                                                                                                      |   7%
  ordinary text without R code

  |................                                                                                              |  14%
label: setup (with options) 
List of 1
 $ include: logi FALSE

  |........................                                                                                      |  21%
  ordinary text without R code

  |...............................                                                                               |  29%
label: dataframe-exercise (with options) 
List of 1
 $ exercise: logi TRUE

  |.......................................                                                                       |  36%
  ordinary text without R code

  |...............................................                                                               |  43%
label: dataframe-exercise-hint-1
  |.......................................................                                                       |  50%
  ordinary text without R code

  |...............................................................                                               |  57%
label: dataframe2-exercise (with options) 
List of 1
 $ exercise: logi TRUE

Quitting from lines 31-31 (learnr_issue_172.Rmd) 
Error: The exercise chunk 'dataframe2-exercise' doesn't have anything inside of it. Try adding empty line(s) inside the code chunk.

@schloerke
Copy link
Collaborator

Please add a news item, as it closes #172

@cpsievert cpsievert merged commit 76fac84 into master Jul 30, 2020
@cpsievert cpsievert deleted the carson/bugfix/empty-exercise branch July 30, 2020 17:33
schloerke added a commit that referenced this pull request Aug 7, 2020
* master:
  Disable completion of R code inside quotes, closes #401 (#413)
  Bump version (#414)
  Save tutorial output to temp folder when tutorial folder does not have write permissions (#412)
  Throw an informative error if an exercise chunk is NULL (#411)
  Remove outdated exercise option
  Checking for exercise errors (#403)
schloerke added a commit that referenced this pull request Sep 2, 2020
* master:
  Add events to website (#423)
  Add a checker test with error as solution (#422)
  Fixes for learnr on external evaluator (#420)
  Add shinytest support (#407)
  Validate the ability to create an idb store (#417)
  Disable completion of R code inside quotes, closes #401 (#413)
  Bump version (#414)
  Save tutorial output to temp folder when tutorial folder does not have write permissions (#412)
  Throw an informative error if an exercise chunk is NULL (#411)
  Remove outdated exercise option
  Checking for exercise errors (#403)
  Add event handler system (#398)
  External evaluator fixes (#399)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

'Empty' exercise chunks aren't treated as exercises Hints only work if I have something in the exercise box
2 participants