
Run an expression as if it were in an exercise's grade_this() block
Source: R/with_exercise.R
with_exercise.RdThis 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] What first-rate work! Correct!>
with_exercise(exercise, fail_if_code_feedback())
#> <gradethis_graded: [Incorrect]
#> I expected `+` where you wrote `2`.
#> >