with_exercise: Run an expression as if it were in an exercise's...

View source: R/with_exercise.R

with_exerciseR Documentation

Run an expression as if it were in an exercise's grade_this() block

Description

This function is not intended to be used within grading code, but may be helpful for testing grading code.

Usage

with_exercise(exercise, expr)

Arguments

exercise

An exercise, as created by mock_this_exercise()

expr

An unquoted expression

Value

The value of ⁠grade_this(<expr>)(exercise)⁠

Examples

exercise <- mock_this_exercise(.user_code = "2", .solution_code = "1 + 1")

with_exercise(exercise, pass_if_equal())
with_exercise(exercise, fail_if_code_feedback())

rstudio-education/grader documentation built on July 6, 2023, 8:48 a.m.