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)
state | the state to start from |
---|---|
... | S3 stuff |
regex | the regular expression or pattern to look for |
fixed | if fixed is TRUE, |
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? |
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. |
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.
if (FALSE) { # Example 1 mtcars # SCT ex() %>% check_output_expr("mtcars") # Example 2 print("hello!") # SCT (robust) ex() %>% check_output("[H|h]ello\\!*") }