get_tutorial_info {learnr} | R Documentation |
Get information about the current tutorial
Description
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.
Usage
get_tutorial_info(
tutorial_path = NULL,
session = getDefaultReactiveDomain(),
...,
encoding = "UTF-8"
)
Arguments
tutorial_path |
Path to a tutorial |
session |
The |
... |
Arguments passed on to
|
encoding |
Ignored. The encoding is always assumed to be UTF-8. |
Value
Returns an ordinary list with the following elements:
-
tutorial_id
: The ID of the tutorial, auto-generated or from thetutorial$id
key in the tutorial's YAML front matter. -
tutorial_version
: The tutorial's version, auto-generated or from thetutorial$version
key in the tutorial's YAML front matter. -
items
: A data frame with columnsorder
,label
,type
anddata
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 thelanguage
item of the YAML front matter.
See Also
Examples
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
}