Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/PsyTeachR/webex
RMarkdown tools for creating self-guided web exercises
https://github.com/PsyTeachR/webex
Last synced: 8 days ago
JSON representation
RMarkdown tools for creating self-guided web exercises
- Host: GitHub
- URL: https://github.com/PsyTeachR/webex
- Owner: PsyTeachR
- License: other
- Created: 2018-02-01T18:57:24.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2021-09-09T07:17:31.000Z (over 3 years ago)
- Last Synced: 2024-11-30T21:35:26.256Z (12 days ago)
- Language: R
- Homepage: https://psyteachr.github.io/webex/
- Size: 545 KB
- Stars: 55
- Watchers: 9
- Forks: 3
- Open Issues: 4
-
Metadata Files:
- Readme: README.Rmd
- License: LICENSE
Awesome Lists containing this project
- jimsghstars - PsyTeachR/webex - RMarkdown tools for creating self-guided web exercises (R)
README
---
output: github_document
---```{r setup, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```# The `{webexercises}` package
The goal of `{webexercises}` is to enable instructors to easily create interactive web pages that students can use in self-guided learning. Although `{webexercises}` has fewer features than RStudio's [learnr](https://rstudio.github.io/learnr/) package, it is more lightweight: whereas `{learnr}` tutorials must be either hosted on a shiny server or run locally, `{webexercises}` creates standalone HTML files that require only a JavaScript-enabled browser. It is also extremely simple to use.
## Installation
You can install `{webexercises}` from CRAN using:
```{r install-cran, eval=FALSE}
install.packages("webexercises")
```You can install the development version from [GitHub](https://github.com/PsyTeachR/webexercises) with:
```{r install-webexercises, eval=FALSE}
devtools::install_github("psyteachr/webexercises")
```## Creating interactive widgets with inline code
The webexercises package provides functions that create HTML widgets using [inline R code](https://github.com/rstudio/cheatsheets/raw/master/rmarkdown-2.0.pdf). These functions are:
| 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 |
| `longmcq()` | radio buttons | MCQs with long answers |
| `hide()` and `unhide()` | button | solution revealed when clicked |
| `total_correct()` | text | updating 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 webexercises 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:
```{r compile-webexercises, eval=FALSE}
rmarkdown::draft("exercises.Rmd", "webexercises", "webexercises")
```Knit the file to HTML to see how it works. **Note: The widgets only function in a JavaScript-enabled browser.**
## Bookdown
You can add webexercises to a bookdown project or start a new bookdown project using `add_webex_to_bookdown()`.
```{r, eval = FALSE}
# create a new book
# use default includes and scripts directories (include and R)
add_webexercises_to_bookdown(bookdown_dir = "demo_bs4",
output_format = "bs4_book",
render = TRUE)add_webexercises_to_bookdown(bookdown_dir = "demo_git",
output_format = "gitbook",
render = TRUE)add_webexercises_to_bookdown(bookdown_dir = "demo_html",
output_format = "html_book",
render = TRUE)add_webexercises_to_bookdown(bookdown_dir = "demo_tufte",
output_format = "tufte_html_book",
render = TRUE)# update an existing book with custom include and script directories
add_webexercises_to_bookdown(bookdown_dir = ".",
include_dir = "www",
script_dir = "scripts",
output_format = "gitbook")
```
This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.