dtkaplan / checkr Goto Github PK
View Code? Open in Web Editor NEWChecks code submissions in learnr (and potentially other) tutorials.
License: MIT License
Checks code submissions in learnr (and potentially other) tutorials.
License: MIT License
Have pre_check()
do the step by step evaluation instead of for_checkr()
. Right now there's redundancy: both functions are doing it.
Add an argument to for_checkr()
with the solution code, so that spell checks can take place within that context.
Add a SOLN_CODE binding along with USER_CODE. That will make it easier to pass any solution code to the new for_checkr()
.
I have been trying to use checkr with learnr and keep coming across an issue when trying to extract function arguments. I have tried named_arg, function_arg and data_arg and get the same error. Using the examples provided:
code <- for_checkr(quote(lm(mpg ~ hp, data = mtcars)))
formula_arg(code)
checkr result fail with message:
Error : Can't take the names()
of the .data
pronoun
data_arg(code, insist("hp" %in% names(V), "The data should have a column named 'hp'."))
checkr result fail with message:
Error : Can't take the names()
of the .data
pronoun
named_arg(code, "data", failif(E ==
mtcars
, "I didn't want mtcars."))
checkr result fail with message:
Error : Can't take the names()
of the .data
pronoun
Hi, I am new to this package. I am struggling to do multiple tests by assigning tests to t1, t2, t3 e.t.c. and then using
if (failed(t1)) return(t1)
I am getting the error message (code not found)
Was wondering if I was the only person with this issue.
For context I have being trying to apply the lm modelling code from the vignette to a different modelling example:
check_tree <- function(USER_CODE) {
code <- for_checkr(USER_CODE) # pre-processing
rpart_line <- line_calling(code, rpart, message = "Use rpart() to construct the model.")
rpart_call <- arg_calling(rpart_line, rpart)
t1 <- data_arg(rpart_call,
insist(identical(V, trainingdata),
"Your data argument {{E}} was not trainingdata
."),
message = "You didn't supply a data =
argument to rpart()
.")
if (failed(t1)) return(t1)
f <- formula_arg(rpart_call,
message = "You didn't give a formula specifying the structure of the model.")
t2 <- check(f, insist(two_sided(f), "There's no response variable in your formula."))
if (failed(t2)) return(t2)
}
When capturing a formula with check_blanks
, what get's captured is actually the call to generate the formula, not the formula itself. You need to evaluate the formula-call before you can compare it to another formula, e.g.
check_blanks(code, quote(lm(..form.., data = iris)))
failif(eval(form) == (Sepal.Length ~ Species)
This seems awkward.
Currently these take bare statements. This prevents associating a message with a particular test and leads to run-time errors when a test statement is used with the wrong kind of test.
Since devtools 2.0.0
the command to build vignettes devtools::install_github("dtkaplan/checkr", build_vignettes=TRUE)
does not work anymore. Therefore I used the new syntax.
But I got an error:
E creating vignettes (9s)
Quitting from lines 639-640 (checkr.Rmd)
Error: processing vignette 'checkr.Rmd' failed with diagnostics:
is.name(e1) || is.character(e1) is not TRUE
Execution halted
Error in processx::run(bin, args = real_cmdargs, stdout_line_callback = real_callback(stdout), :
System command error
Is it possible to not execute submitted code and only verify the syntax? I created a question about opening file and how to use parameters (sep, header, etc). I want the student to write a line of code that would read a file and verify only the code since the file is not available.
Thank you for the great package.
I am trying to use learnr with checkr. But I cannot understand the general logic. Could you provide a very simple example to demonstrate the interplay between learnr and checkr? - Your examples in your vignette checkr.Rmd are already very complex.
I am thinking of explanations which elaborates the simple examples of the "Interactive Tutorial" - template, provided by learnr, e.g. checking the code for "Write the R code required to add two plus two". As the main use case of checkr is in conjunction with learnr it should preferably elaborate the exercise part of the learnr tutorial.
To give you more information about my difficulties:
check_exer_1_v0
for the rep(1:4, each = 3)
example in a script file "check_test.R" under a folder "www".tutorial_options(exercise.checker = checkr::check_for_learnr)
to the setup chunk.source("../www/check_test.R")
as my R Markdownfile "01-Exercise.RMD" is under the folder "01-Exercise".Use the rep() function, with 1:4 as an input, to generate the 12-element vector 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4.
exercise1
and the chunk option exercise=TRUE
.exercise1-check
So far I believe I did all things correctly. But now I do not know what to put into the exercise1-check
chunk.
After many trials, I finally succeeded with check_exer_1_v0(USER_CODE)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.