Check the output of the submission to see if it contains certain elements.

check_output(state, ...)

# S3 method for default
check_output(state, regex, fixed = FALSE,
  trim = FALSE, times = 1, output_only = FALSE, missing_msg = NULL,
  append = TRUE, ...)

check_output_expr(state, expr, times = 1, missing_msg = NULL,
  append = TRUE)

Arguments

state

the state to start from

...

S3 stuff

regex

the regular expression or pattern to look for

fixed

if fixed is TRUE, regex will be sought for 'as is' in the output, if fixed = FALSE (the default), regex will be treated as actual regular expression.

trim

should the student output be trimmed, so that all newlines and spaces are removed, before checking?

times

how often should the pattern/expression output be found?

output_only

Consider only regular output, or also messages, warnings and error? FALSE by default for check_output (so it considers all kinds of output). You cannot specify this argument for check_output_expr and test_output_contains.

missing_msg

Custom message in case the pattern or output wasn't found often enough.

append

Whether or not to append the feedback to feedback built in previous states

expr

The expression (as string) for which the output should be in the student's console output.

Details

With check_output, you can simply specify a regular expression or pattern (depending on the value of fixed) that is looked for in the student's output. By default, regular output, messages, warnings and errors are considered.

With test_output_contains and check_output_expr you can pass an expression, that is executed in the student environment, and whose output is compared to the output the student generated. If the generated output is found in the student's output, the check passes. By default, only regular output is considered.

Examples

if (FALSE) { # Example 1 mtcars # SCT ex() %>% check_output_expr("mtcars") # Example 2 print("hello!") # SCT (robust) ex() %>% check_output("[H|h]ello\\!*") }