check_correct
checks whether a set of tests passes, and does
additional, more precise tests if these tests fail. In addition to the state,
it takes two code chunks;
diagnose_code
: Set of tests that gets
executed if the tests in check_code
fail. These tests contain more
detailed tests, to pinpoint the problem.
check_correct(state, ...) check_or(state, ...)
state | The state. Typically |
---|---|
... | sets of tests. In the case of |
check_correct
increases the flexibility for the student: if the tests
in check_code
pass, the results of the tests in diagnose_code
are not considered. If you test for the end result in check_code
, and
only do more rigorous testing in diagnose_code
, you can allow for
multiple solutions to a challenge.
Similarly, check_or
checks whether one of many test sets pass. That
way, you can allow for multiple solutions.
Both check_or
and check_correct
makes the state you feed it to
its subtests available as .
(the dot), similar to how magrittr does
it.
if (FALSE) { # Example 1 solution code x <- mean(1:3) # Example SCT ex() %>% check_correct( check_object(., "x") %>% check_equal(), check_fun(., "mean") %>% check_arg("x") %>% check_equal() ) # Following submissions will all be accepted: x <- mean(1:3) x <- 2 x <- mean(-1:5) # Example 2 solution code # a <- 3; b <- 4 # Example SCT ex() %>% check_or( check_object(., 'a') %>% check_equal(), check_object(., 'b') %>% check-equal() ) # Following submissions will all be accepted: a <- 3; b <- 4 a <- 3 b <- 4 }