The following are addon element for learnr tutorials that enable the encoding and decoding of hashed learnr solutions.

Note that when including these functions in a learnr Rmd document it is necessary that the logic functions, *_logic(), be included in an R chunk where context="server" as they interact with the underlying Shiny functionality. Conversely, any of the ui functions, *_ui(), must not be included in an R chunk with a context. Both types of functions have been written to provide useful feedback if they detect they are in the wrong R chunk type.

decoder_logic()

decoder_ui()

encoder_logic(strip_output = FALSE)

default_ui(url = "http://google.com")

iframe_ui(src = "http://google.com", ...)

encoder_ui(ui_before = default_ui(), ui_after = NULL)

Arguments

strip_output

Exercises save their output as html, for exercises that result in plots these can result in very large hashes. The option allows this information to be removed to keep hash sizes more manageable.

url

Link url to use.

src

Source of the iframe.

...

Other iframe attributes, e.g. height and width

ui_before

Shiny ui elements to include before the hash ui

ui_after

Shiny ui elements to include after the hash ui,

Details

For either of the ui parameters you can wrap multiple shiny elements together with shiny::div.