Interactive Tutorials with 'Quarto' and 'WebR'

Create interactive R tutorials that run entirely in the browser using 'Quarto' < https://quarto.org> and 'WebR' < https://docs.r-wasm.org/webr/latest/> via the 'quarto-live' extension. Provides 'learnr'-style authoring conveniences -- scaffolding, exercises, hints, solutions, and quizzes -- without 'Shiny', 'R Markdown', or a server.


learnr2

R-CMD-check

learnr2 creates interactive R tutorials that run entirely in the reader's web browser using Quarto and WebR, via the quarto-live extension. It offers learnr-style authoring conveniences --- scaffolding, exercises, hints, solutions, and quizzes --- without Shiny, R Markdown, or a server. A rendered tutorial is a self-contained HTML page.

Installation

Install the released version of learnr2 from CRAN:

install.packages("learnr2")

Or install the development version from GitHub:

# install.packages("pak")
pak::pak("PPBDS/learnr2")

You will also need the Quarto CLI.

Usage

Try the bundled feature-tour tutorial:

library(learnr2)

available_tutorials()          # list tutorials bundled with a package
run_tutorial("hello-learnr2")  # render + open in your browser

Scaffold your own tutorial:

create_tutorial("my-tutorial", dir = ".")

This creates my-tutorial/my-tutorial.qmd (under the directory you name; there is no default) with the quarto-live extension copied alongside it, so it renders out of the box with Quarto or quarto::quarto_render().

What's inside a tutorial

  • Live code cells — editable, runnable R that executes in the browser.
  • Exercises — cells with blanks, plus .hint and .solution blocks.
  • Automatic grading — powered by gradethis.
  • Quiz questions — question() / quiz(), graded in the browser with plain JavaScript, including single/multiple choice, free-text, and reflection questions (optionally answered with a pasted screenshot). Answers persist in the browser's localStorage.
  • Student info and submission — student_info() collects a name and email; download_answers_button() bundles every saved answer into a JSON file the reader can turn in. No server involved.
  • Progressive reveal — sections unlock one at a time behind "Continue" buttons, the table of contents can't be used to read ahead unless tutorial_options(allow_skip = TRUE) says so, and every page has a "Start Over" button that clears saved progress.

See the bundled hello-learnr2 tutorial and the reference index for details. Two vignettes cover writing tutorials: "Tutorials in the Age of AI" on how a tutorial should teach, and "Translating learnr Tutorials" on how one is put together, including converting an existing learnr tutorial.

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("learnr2")

0.1.3 by David Kane, 11 hours ago


https://github.com/PPBDS/learnr2, https://ppbds.github.io/learnr2/


Report a bug at https://github.com/PPBDS/learnr2/issues


Browse source code at https://github.com/cran/learnr2


Authors: David Kane [aut, cre, cph] (ORCID: , Minh Vu [aut]


Documentation:   PDF Manual  


MIT + file LICENSE license


Imports fs, htmltools, httpuv, jsonlite, knitr, quarto, rmarkdown

Suggests learnr, pkgdown, pkgload, rstudioapi, testthat, withr

System requirements: Quarto command line tool (https://github.com/quarto-dev/quarto-cli).


See at CRAN