To use gradethis in your learnr tutorial, you only need to call
library(gradethis)
in your tutorial's setup chunk.
```{r setup} library(learnr) library(gradethis) ```
Use gradethis_setup()
to change the default options suggested by gradethis.
This function also describes in detail each of the global options available
for customization in the gradethis package. Note that you most likely do not
want to change the defaults values for the learnr tutorial options that are
prefixed with exercise.
. Each of the gradethis-specific arguments sets a
global option with the same name, prefixed with gradethis.
. For example,
pass
sets gradethis.pass
.
gradethis_setup( pass = NULL, fail = NULL, ..., code_correct = NULL, code_incorrect = NULL, maybe_code_feedback = NULL, maybe_code_feedback.before = NULL, maybe_code_feedback.after = NULL, pass.praise = NULL, fail.hint = NULL, fail.encourage = NULL, pipe_warning = NULL, error_checker.message = NULL, allow_partial_matching = NULL, exercise.checker = gradethis_exercise_checker, exercise.timelimit = NULL, exercise.error.check.code = NULL, fail_code_feedback = NULL )
pass | Default message for |
---|---|
fail | Default message for |
... | Arguments passed on to
|
code_correct | Default |
code_incorrect | Default |
maybe_code_feedback | Logical |
maybe_code_feedback.before, maybe_code_feedback.after | Text that should
be added |
pass.praise | Logical |
fail.hint | Logical |
fail.encourage | Logical |
pipe_warning | The default message used in |
error_checker.message | The default message used by gradethis's default
error checker, |
allow_partial_matching | Logical |
exercise.checker | Function used to check exercise answers
(e.g., |
exercise.timelimit | Number of seconds to limit execution time to
(defaults to |
exercise.error.check.code | A string containing R code to use for checking
code when an exercise evaluation error occurs (e.g., |
fail_code_feedback | Deprecated. Use |
Invisibly returns the global options as they were prior to setting
them with gradethis_setup()
.
These global package options can be set by gradethis_setup()
or by
directly setting the global option. The default values set for each option
when gradethis is loaded are shown below.
Option | Default Value |
gradethis.pass | "{random_praise()} Correct!" |
gradethis.pass.praise | FALSE |
gradethis.fail | "Incorrect.{maybe_code_feedback()} {random_encouragement()}" |
gradethis.fail.hint | FALSE |
gradethis.fail.encourage | FALSE |
gradethis.maybe_code_feedback | TRUE |
gradethis.maybe_code_feedback.before | " " |
gradethis.maybe_code_feedback.after | NULL |
gradethis.code_correct | NULL |
gradethis.code_incorrect | "{pipe_warning()}{code_feedback()} {random_encouragement()}" |
gradethis.pipe_warning | "I see that you are using pipe operators (e.g. %>%), so I want to let you know that this is how I am interpretting your code before I check it:\n\n```r\n{.user_code_unpiped}\n```\n\n" |
gradethis.allow_partial_matching | NULL |
gradethis.error_checker.message | "An error occurred with your R code:\n\n```\n{.error$message}\n```\n\n\n" |
# Not run in package documentation because this function changes global opts if (FALSE) { old_opts <- gradethis_setup( pass = "Great work!", fail = "{random_encouragement()}" ) } # Use getOption() to see the default value getOption("gradethis.pass")#> [1] "{random_praise()} Correct!"#> [1] TRUE