testwhat_learnr: A checker function to use with learnr

View source: R/utils-learnr.R

testwhat_learnrR Documentation

A checker function to use with learnr

Description

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. Users are not intended to use the function themselves, but to pass it to the exercise.checker knitr chunk option within the setup chunk of the tutorial.

Usage

testwhat_learnr(label = NULL, solution_code = NULL, user_code = NULL,
  check_code = NULL, envir_result = NULL, evaluate_result = NULL,
  ...)

Arguments

label

Label for exercise chunk

solution_code

R code submitted by the user

user_code

Code provided within the "-solution" chunk for the exercise.

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 evaluate::evaluate function.

...

Unused (include for compatibility with parameters to be added in the future)

Details

Similar to grader's grade_learnr(), testwhat provides testwhat_learnr() for this purpose. To enable exercise checking in your learnr tutorial, set tutorial_options(exercise.checker = testwhat_learnr) in the setup chunk of your tutorial.

Value

An R list which contains several fields indicating the result of the check.


datacamp/testwhat documentation built on June 26, 2022, 9:07 a.m.