View source: R/tutorial-state.R
get_tutorial_info | R Documentation |
Returns information about the current tutorial. Ideally the function should
be evaluated in a Shiny context, i.e. in a chunk with option
context = "server"
. Note that the values of this function may change after
the tutorial is completely initialized. If called in a non-reactive context,
get_tutorial_info()
will return default values that will most likely
correspond to the current tutorial.
get_tutorial_info(
tutorial_path = NULL,
session = getDefaultReactiveDomain(),
...,
encoding = "UTF-8"
)
tutorial_path |
Path to a tutorial |
session |
The |
... |
Arguments passed on to
|
encoding |
Ignored. The encoding is always assumed to be UTF-8. |
Returns an ordinary list with the following elements:
tutorial_id
: The ID of the tutorial, auto-generated or from the
tutorial$id
key in the tutorial's YAML front matter.
tutorial_version
: The tutorial's version, auto-generated or from the
tutorial$version
key in the tutorial's YAML front matter.
items
: A data frame with columns order
, label
, type
and data
describing the items (questions and exercises) in the tutorial. This item
is only available in the running tutorial, not during the static
pre-render step.
user_id
: The current user.
learnr_version
: The current version of the running learnr package.
language
: The current language of the tutorial, either as chosen by the
user or as specified in the language
item of the YAML front matter.
get_tutorial_state()
if (rmarkdown::pandoc_available("1.4")) {
tutorial_rmd <- local({
# Use a temp copy of "Hello learnr" tutorial for this example
src <- system.file(
"tutorials", "hello", "hello.Rmd", package = "learnr"
)
dest <- tempfile(fileext = ".Rmd")
file.copy(src, dest)
dest
})
# ---- This is the example! ------------ #
info <- get_tutorial_info(tutorial_rmd)
# -------------------------------------- #
# clean up the temporary Rmd used in this example
unlink(tutorial_rmd)
# This is the result of the example
info
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.