Skip to content

learnr Tutorials

Run a learnr Tutorial

run_tutorial()
Run a tutorial
available_tutorials()
List available tutorials
safe()
Execute R code in a safe R environment

Write or Configure a learnr Tutorial

tutorial()
Tutorial document format
tutorial_options()
Set tutorial options
tutorial_package_dependencies()
List tutorial dependencies

Interactive Questions

quiz() question()
Tutorial quiz questions
question_checkbox()
Checkbox question
question_radio()
Radio question
question_numeric()
Number question
question_text()
Text box question
answer() answer_fn()
Question answer options
correct() incorrect() mark_as()
Mark submission as correct or incorrect

Random Praise and Encouragement

random_praise() random_encouragement()
Random praise and encouragement
random_phrases_add()
Add phrases to the bank of random phrases

Developer Tools

These functions were designed for use by developers who want to extend learnr with custom formats or interactive question types, or for those who wish to deploy learnr tutorials in custom environments.

Questions

Functions intended for use by developers creating custom questions for learnr.

State and Events

get_tutorial_info()
Get information about the current tutorial
get_tutorial_state()
Observe the user's progress in the tutorial
filesystem_storage()
Filesystem-based storage for tutor state data
event_register_handler()
Register an event handler callback
one_time()
Wrap an expression that will be executed one time in an event handler

General Tools

duplicate_env()
Create a duplicate of an environment
initialize_tutorial()
Initialize tutorial R Markdown extensions
external_evaluator()
External execution evaluator
tutorial_html_dependency()
Tutorial HTML dependency