R/gradethis_error_checker.R
gradethis_error_checker.Rd
learnr uses the checking code in exercise.error.check.code
when the
user's submission produces an error during evaluation.
gradethis_error_checker()
provides default error checking suitable for most
situations where an error was not expected.
If a solution for the exercise is available, the user's submission will be compared to the example solution and the message to the student will include code feedback. Otherwise, the error message from R is returned.
If you are expecting the user to submit code that throws an error, use the
*-error-check
chunk to write custom grading code that validates that the
correct error was created.
gradethis_error_checker( ..., message = getOption("gradethis.error_checker.message", NULL), encourage = getOption("gradethis.fail.encourage", FALSE) )
... | Ignored but included for future compatibility. |
---|---|
message | The feedback message when an error occurred and no solution is
provided for the exercise. May reference |
encourage | Incude a random encouraging phrase with
|
A checking function compatible with gradethis_exercise_checker()
.
# The default error checker is run on an exercise that produces an error. # In the following example, the object `b` is not defined. # This is the error that the user's submission creates: tryCatch( b, error = function(e) message(e$message) )#>#> <gradethis_graded: [Incorrect] #> An error occurred with your R code: #> #> ``` #> object 'b' not found #> ``` #> #> Don't give up now, try it one more time. #> >#> <gradethis_graded_this_code: [Incorrect] #> I expected `a` where you wrote `b`. Give it another try. #> >