The goal of the labsheet package is to enable the easy authoring of interactive web pages for student self-guided learning.
The package works by providing an RMarkdown template for generating HTML hands-on worksheets as utilized in Barry’s Bioinformatics classes at UCSD. This includes in-line R functions for creating student question responses, interactive answer checking, score tracking, and accessory functions for hide/reveal answer display. Extensive CSS style settings are also provided as convenient R functions.
To see an example of labsheet output see labsheet_eg1.html and the corresponding input labsheet_eg1.Rmd. Note that this input file can be generated by following the Getting Started instructions below.
You can install the development version of labsheet from GitHub with:
devtools::install_github("bioboot/labsheet")
To create an interactive worksheet in RStudio, click File -> New File… -> RMarkdown and in the dialog box that appears, select From Template and choose Hands-on Q/A Web Exercises (labsheet).
This will result in a new RMarkdown document being generated with example code and text demonstrating major features. Save and Knit the file to HTML to see how it works.
Alternatively (or if you’re not using RStudio) use:
rmarkdown::draft("exercises.Rmd", "labsheet", "labsheet")
Functions and features of the labsheet package are based on on ideas from Software Carpentry lessons and the learnr package.
Although labsheet currently 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 through an R/shiny process, labsheet creates single standalone HTML files that require only a JavaScript-enabled web browser. This means they will work well on any web host including GitHub pages. The output HTML files can also be sent directly to students and opened on their own computers, tablets or chromebooks. labsheet is also much more simple to use.
The labsheet package provides functions that create HTML widgets, CSS styling, or common text snippets by using inline R code. These functions include:
function | widget | description |
---|---|---|
fitb() |
text box | fill-in-the-blank question |
mcq() |
pull-down menu | multiple choice question |
torf() |
pull-down menu | TRUE or FALSE question |
hide() and unhide() |
button | solution revealed when clicked |
question_start() |
css | style question block |
question_end() |
css | style question block |
author() |
html text | author and date text |
score_counter() |
floating text | floating score counter |
total_correct() |
html text | total count of correct answers |
All package functions:
library(labsheet)
ls("package:labsheet")
#> [1] "author" "fitb" "hide"
#> [4] "labsheet_default" "mcq" "question_end"
#> [7] "question_start" "round2" "score_counter"
#> [10] "strip_lzero" "style_widgets" "torf"
#> [13] "total_correct" "unhide"
The appearance of the question/answer 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). Running scores
and counting of correct answer responses is provided by either
score_counter()
or total_correct()
. Currently only one of these
functions can be used in a given document and counters will be reset
upon page
refresh.
This
work is licensed under a
Creative
Commons Attribution-ShareAlike 4.0 International License.