View source: R/gradethis_exercise_checker.R
gradethis_exercise_checker | R Documentation |
For exercise checking, learnr tutorials require a function that
learnr can use in the background to run the code in each "-check"
chunk and to format the results into a format that learnr can display.
To enable exercise checking in your learnr tutorial, attach gradethis
with library(gradethis)
, or call gradethis_setup()
in the setup chunk
of your tutorial. See gradethis_demo()
to see an example learnr document
that uses gradethis_exercise_checker()
.
gradethis_exercise_checker(
label = NULL,
solution_code = NULL,
user_code = NULL,
check_code = NULL,
envir_result = NULL,
evaluate_result = NULL,
envir_prep = NULL,
last_value = NULL,
stage = NULL,
...,
solution_eval_fn = NULL
)
label |
Label for exercise chunk |
solution_code |
Code provided within the "-solution" chunk for the exercise. |
user_code |
R code submitted by the user |
check_code |
Code provided within the "-check" (or "-code-check") chunk for the exercise. |
envir_result |
The R environment after the execution of the chunk. |
evaluate_result |
The return value from the |
envir_prep |
A copy of the R environment before the execution of the chunk. |
last_value |
The last value from evaluating the user's exercise submission. |
stage |
The current stage of exercise checking. |
... |
Extra arguments supplied by learnr |
solution_eval_fn |
A function taking solution You may also provide a named list of solution evaluation functions to the
For example, for a hypothetical exercise engine options( gradethis.exercise_checker.solution_eval_fn = list( echo = function(code, envir) { code } ) ) Solution evaluation functions should determine if the solution code is
missing and if so throw an error with class |
Returns a feedback object suitable for learnr tutorials with the results of the exercise grading code.
gradethis_setup()
, grade_this()
, grade_this_code()
## Not run:
gradethis_demo()
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.