check_expr | R Documentation |
Run an expression in student and solution environment and compare the result, output or error that is thrown by it.
check_expr(state, expr) ## S3 method for class 'ExprState' check_result(state, error_msg = NULL, append = TRUE, ...) ## S3 method for class 'ExprState' check_output(state, error_msg = NULL, append = TRUE, ...) ## S3 method for class 'ExprState' check_error(state, no_error_msg = NULL, append = TRUE, ...) ## S3 method for class 'ExprResultState' check_equal(state, eq_condition = "equivalent", eq_fun = NULL, incorrect_msg = NULL, append = TRUE, ...) ## S3 method for class 'ExprOutputState' check_equal(state, eq_fun = NULL, incorrect_msg = NULL, append = TRUE, ...) ## S3 method for class 'ExprErrorState' check_equal(state, eq_fun = NULL, incorrect_msg = NULL, append = TRUE, ...)
state |
state to start from (only for |
expr |
the expression to run |
error_msg |
custom message in case the expression throws an error while it shouldn't |
append |
Whether or not to append the feedback to feedback built in previous states |
... |
S3 stuff |
no_error_msg |
custom message in case the expression doesn't throw an error while it should |
eq_condition |
character string indicating how to compare. See
|
eq_fun |
optional argument to specify a custom equality function. The
function should take two arguments and always return a single boolean
value: |
incorrect_msg |
custom message in case the result, output or error of the expression does not correspond with the solution |
## Not run: # Example 1 a <- c(1, 2, 3, 4, 5, 6) # SCT ex() %>% check_expr("a[c(2, 4)]") %>% check_result() %>% check_equal() # Example 2 my_fun <- function() { print('hello') } # SCT ex() %>% check_expr("my_fun()") %>% check_output() %>% check_equal() ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.