Description Usage Arguments Details Examples
Specify a binding pattern in terms of an expression where elements like ..one..
or ..x..
, etc
set the names to be bound to the corresponding part of the code.
1 | check_blanks(ex, pat, ...)
|
ex |
the expression to check, e.g. USER_CODE |
pat |
a quoted expression containing the anticipated correct form. Use elements such as |
... |
tests to apply to expressions in |
For formulas, the ~
should be encompassed by the named element. For instance, if the user is
shown a statement like mean( ~ hp, data = mtcars)
, the blanks statement should be something like
mean(..v.., data = mtcars)
and NOT mean( ~ ..v.., data = mtcars).
In pat
, you can use .
(for a name or call) and ...
(for remaining arguments) to stand for components of the pattern you don't care about.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | submission <- for_checkr(quote({a <- 3; b <- 4; res <- sqrt(a^2 + b^2)}))
submission2 <- for_checkr(quote({a <- 3; b <- 4; res <- sin(a^2 + b^2)}))
# a template with a blank ..fn..
as_posted <- quote(res <- ..fn..(a^2 + b^2))
check_blanks(submission, as_posted,
insist(fn == quote(sqrt), "{{fn}} is not the right function."),
passif(TRUE, "Right! You're using the square-root function."))
check_blanks(submission2, as_posted,
insist(fn == quote(sqrt), "{{fn}} is not the right function."),
passif(TRUE, "Right! You're using the square-root function."))
as_posted2 <- quote(b <- ..bval..)
check_blanks(submission, list(as_posted, as_posted2),
insist(fn == quote(sqrt), "Wrong function."),
insist(bval == 5, "`b` is not supposed to be {{bval}}."))
# Multiple blanks
as_posted <- for_checkr(quote({res <- ..fn..(`+`(`^`(a, ..exp1..), `^`(b, ..exp2..)))}))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.