Learn R Programming

The webex package

The goal of webex is to enable instructors to easily create interactive web pages that students can use in self-guided learning. Although webex has fewer features than RStudio’s learnr package, it is more lightweight: whereas learnr tutorials must be either hosted on a shiny server or run locally, webex creates standalone HTML files that require only a JavaScript-enabled browser. It is also extremely simple to use.

Installation

You can install webex from CRAN using:

install.packages("webex")

You can install the development version of webex from GitHub with:

devtools::install_github("psyteachr/webex")

Creating interactive widgets with inline code

The webex package provides functions that create HTML widgets using inline R code. These functions are:

functionwidgetdescription
fitb()text boxfill-in-the-blank question
mcq()pull-down menumultiple choice question
torf()pull-down menuTRUE or FALSE question
hide() and unhide()buttonsolution revealed when clicked
total_correct()textupdating total correct

The appearance of the text box and pull-down menu widgets changes when users enter the correct answer. Answers can be either static or dynamic (i.e., specified using R code). Widget styles can be changed using style_widgets().

Examples are provided in the Web Exercises R Markdown template. To create a file from the webex template in RStudio, click File -> New File... -> RMarkdown and in the dialog box that appears, select From Template and choose Web Exercises.

Alternatively (or if you’re not using RStudio) use:

rmarkdown::draft("exercises.Rmd", "webex", "webex")

Knit the file to HTML to see how it works. Note: The widgets only function in a JavaScript-enabled browser.

This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.

Copy Link

Version

Install

install.packages('webex')

Monthly Downloads

14

Version

0.9.2

License

CC BY-SA 4.0

Issues

Pull Requests

Stars

Forks

Maintainer

Dale Barr

Last Published

June 10th, 2021

Functions in webex (0.9.2)

hide

Create button revealing hidden content
mcq

Create a multiple-choice question
strip_lzero

Strip leading zero from numeric string
round2

Round up from .5
total_correct

Display total correct
webex_default

Create default webex document
unhide

End hidden HTML content
style_widgets

Change webex widget style
escape_regex

Escape a string for regex
fitb

Create a fill-in-the-blank question
torf

Create a true-or-false question