Some rudimentary string cleaning is performed to allow for different ways of saying the same things (removing spaces, changing single quotes to double quotes, changing TRUE to T ...).

check_code(state, regex, fixed = FALSE, times = 1,
  missing_msg = NULL, append = TRUE, drop_comments = FALSE)

Arguments

state

the state to start from

regex

A set of strings/regexes that should be in the student code.

fixed

if TRUE, strings are treated literally. If FALSE, strings are treated as regex patterns.

times

how often should any of the strings be matched?

missing_msg

Custom feedback in case the pattern is not contained often enough in the student's submission.

append

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

drop_comments

Logical value indicating whether or not to remove comments from these student code before looking for the pattern. Defaults to FALSE for backwards compatibility reasons.

Details

Using these function should be a last resort, as there are myriad ways of solving the same problem with R!

Examples

if (FALSE) { # Example 1 TRUE & FALSE # SCT ex() %>% check_code(c("TRUE & FALSE", "FALSE & TRUE"), fixed = TRUE) # Example 2: "Hello, world!" # SCT, robust to small typos ex() %>% check_code("[H|h]ello,*\\s*[W|w]orld\\!*") }