Skip to content

grade_this_code() produces error in -code-check (but grade_code() succeeds) #362

@gcpoole

Description

@gcpoole

The help file for grade_this_code() states the following:

If grade_this_code() is called in a -code-check chunk and returns feedback, either passing or failing feedback, then the user's code is not executed. If you want the user to see the output of their code, call grade_this_code() in the -check chunk.

  • When I call grade_this_code() in a -check chuck, it works as expected when an exercise is submitted.
  • If I change the -check chunk into a -code-check chunk, the tutorial raises an error: "A problem occurred with the grading code for this exercise" when an exercise is submitted.
  • If I change grade_this_code() to grade_code() in the -code-check chunk, everything works as expected when an exercise is submitted, but grade-code() is tagged as superseded by grade_this_code()

learnr: version 0.11.5.9000
gradethis: version 0.2.14

Here is a reproducible example:

---
title: "Reproducible"
output: learnr::tutorial
runtime: shiny_prerendered
---

```{r setup, include=FALSE}
library(learnr)
knitr::opts_chunk$set(echo = FALSE)
gradethis::gradethis_setup()
```

## Topic 1

Write the R code required to add two plus two:

```{r two-plus-two, exercise=TRUE}

```

```{r two-plus-two-solution}
2+2
```

<!-- The following works fine: note `-check` chunk with `grade_this_code()`

```{r two-plus-two-check}
gradethis::grade_this_code()
```
-->

<!-- The following works fine: note `-code-check` chunk with `grade_code()`

```{r two-plus-two-code-check}
gradethis::grade_code()
```
-->

<!-- the following fails with an error: `-code-check` chunk with `grade_this_code() -->

```{r two-plus-two-code-check}
gradethis::grade_this_code()
```

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions