check_blanks: Checking fill-in-the-blanks problems

Description Usage Arguments Examples

View source: R/check_blanks.R

Description

Checking fill-in-the-blanks problems

Usage

1
check_blanks(ex, pat, ...)

Arguments

ex

the expression to check, e.g. USER_CODE

pat

the anticipated correct form. Use elements such as ..one.. to define a blank.

...

tests to apply to expressions in ex. These are typically made with passif(), failif(), and so on.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
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."))
check_blanks(submission2, !!as_posted,
   insist(fn == quote(sqrt), "{{fn}} is not the right function."))
# Multiple blanks
as_posted <- for_checkr(quote({res <- ..fn..(`+`(`^`(a, ..exp1..), `^`(b, ..exp2..)))}))

dtkaplan/checkr2 documentation built on May 17, 2019, 4:01 p.m.