datacamp / testwhat

Write Submission Correctness Tests for R exercises
https://datacamp.github.io/testwhat
GNU Affero General Public License v3.0
33 stars 24 forks source link

In R markdown exercises, allow checking of text where there is no header #226

Open richierocks opened 5 years ago

richierocks commented 5 years ago

Inspired by ch1ex3 of Reporting with R Markdown.

The exercise asks students to change a line of text.

The old SCT was

test_rmd_group(1, {
  test_text("This is my first R Markdown document", not_called_msg = "Don't forget to change the first sentence to \"This is my first R Markdown document.\".")
})

There is no direct, "check" equivalent to test_rmd_group().

The best I could come up with is

ex() %>% check_rmd() %>% {
  check_code(., 'This is my first R Markdown document', fixed = TRUE, missing_msg = "Don't forget to change the first sentence to \"This is my first R Markdown document.\".")
}

The problem with this is that it doesn't pinpoint a region of text for the students to look at.

The closest test I can find is here, which uses check_header() to zoom in. Unfortunately, there is no header element in the document.

Is there a better solution than the one I found? Do we need a check_text_group() or check_paragraph() function? Or is this too niche to worry about?