Run an expression as if it were in an exercise's grade_this()
block
Source: R/with_exercise.R
with_exercise.Rd
This function is not intended to be used within grading code, but may be helpful for testing grading code.
Arguments
- exercise
An exercise, as created by
mock_this_exercise()
- expr
An unquoted expression
Examples
exercise <- mock_this_exercise(.user_code = "2", .solution_code = "1 + 1")
with_exercise(exercise, pass_if_equal())
#> <gradethis_graded: [Correct]
#> That's a first-class answer! Correct!
#> >
with_exercise(exercise, fail_if_code_feedback())
#> <gradethis_graded: [Incorrect]
#> I expected `+` where you wrote `2`.
#> >