-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gradethis does not work when namespaced #364
Comments
If you just want to compare code, you can call gradethis::code_feedback("rnorm(10)", "rnorm(100)")
#> In `rnorm(10)`, I expected `100` where you wrote `10`. |
Thanks! It's not a complete replacement. Instead, I can use gradethis::random_praise() when the result is correct (NULL) |
You could also use the |
Thank you! I'm having a bit of a tough time following the documentation since I am trying to use gradethis outside of the context of learnr so using |
solution <- "rnorm(10)"
user_correct <- solution
user_wrong <- "rnorm(100)"
code_grade <- function(user_code, solution) {
feedback <- gradethis::code_feedback(user_code, solution)
if (is.null(feedback)) {
gradethis::pass()
} else {
gradethis::fail(feedback, encourage = TRUE)
}
}
code_grade(user_correct, solution)
#> <gradethis_graded: [Correct] Amazing! Correct!> code_grade(user_wrong, solution)
#> <gradethis_graded: [Incorrect]
#> In `rnorm(100)`, I expected `10` where you wrote `100`. That's okay:
#> you learn more from mistakes than successes. Let's do it one more
#> time.
#> > You can get the final pass/fail message directly from str(code_grade(user_correct, solution))
#> List of 4
#> $ message : 'glue' chr "Superb work! Correct!"
#> $ correct : logi TRUE
#> $ type : NULL
#> $ location: NULL
#> - attr(*, "class")= chr [1:2] "gradethis_graded" "condition" |
gradethis must be loaded globally using
library(gradethis)
otherwisecode_feedback
cannot be found.Created on 2024-07-02 with reprex v2.1.0
The text was updated successfully, but these errors were encountered: