Skip to content

For exercise checking, learnr tutorials require a function that learnr can use in the background to run the code in each "-check" chunk and to format the results into a format that learnr can display. To enable exercise checking in your learnr tutorial, attach gradethis with library(gradethis), or call gradethis_setup() in the setup chunk of your tutorial. See gradethis_demo() to see an example learnr document that uses gradethis_exercise_checker().

Usage

gradethis_exercise_checker(
  label = NULL,
  solution_code = NULL,
  user_code = NULL,
  check_code = NULL,
  envir_result = NULL,
  evaluate_result = NULL,
  envir_prep = NULL,
  last_value = NULL,
  stage = NULL,
  ...
)

Arguments

label

Label for exercise chunk

solution_code

Code provided within the "-solution" chunk for the exercise.

user_code

R code submitted by the user

check_code

Code provided within the "-check" (or "-code-check") chunk for the exercise.

envir_result

The R environment after the execution of the chunk.

evaluate_result

The return value from the evaluate::evaluate function.

envir_prep

A copy of the R environment before the execution of the chunk.

last_value

The last value from evaluating the user's exercise submission.

stage

The current stage of exercise checking.

...

Extra arguments supplied by learnr

Value

Returns a feedback object suitable for learnr tutorials with the results of the exercise grading code.

Examples

if (FALSE) {
gradethis_demo()
}