Description Usage Arguments Details Value Examples
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.
The function must accept a specific set of inputs and return a specific type
of output (see graded()
). Instructors are not intended to use the
grade_learnr
function directly, but to pass it to the
exercise.checker
knitr chunk option within the setup chunk of the
learnr
tutorial.
1 2 3 |
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” 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 exercise. |
... |
Extra arguments supplied by learnr |
To enable exercise checking in your learnr tutorial, set
tutorial_options(exercise.checker = grade_learnr)
in the setup chunk
of your tutorial.
Run gradethis_demo()
to see an example learnr document that uses
grade_learnr()
.
An R list which contains several fields indicating the result of the check.
1 | ## Not run: gradethis_demo()
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.