From bbd27834a72dc26a3903905778b4c95190c58955 Mon Sep 17 00:00:00 2001
From: gadenbuie You can now customize the “continue” button text in sub-topics by adding ‘data-continue-text’ with your custom label as a property of the section heading — e.g. learnr tutorials now work when Quarto comment-style chunk options are used to set the chunk CRAN release: 2023-05-24Releases
learnr (development version)
-### Subtopic Title {data-continue-text="Show Solution"}
(@dave-mills #777).### Subtopic Title {data-continue-text="Show Solution"}
(@dave-mills #777).label
(thanks @jimjam-slam, #795).learnr 0.11.4
Examples info
}
#> $tutorial_id
-#> [1] "/tmp/RtmpiRGplN"
+#> [1] "/tmp/Rtmpav7LUT"
#>
#> $tutorial_version
#> [1] "1.0"
diff --git a/dev/reference/random_praise.html b/dev/reference/random_praise.html
index 1a99bcf0..5cb936c1 100644
--- a/dev/reference/random_praise.html
+++ b/dev/reference/random_praise.html
@@ -113,14 +113,14 @@
Value
Examples
random_praise()
-#> [1] "Excellent!"
+#> [1] "Very good!"
random_praise()
-#> [1] "Beautiful!"
+#> [1] "You rock!"
random_encouragement()
-#> [1] "Don't give up now, try it one more time."
+#> [1] "That's okay: you learn more from mistakes than successes. Let's do it one more time."
random_encouragement()
-#> [1] "Try it again. Perseverence is the key to success."
+#> [1] "Give it another try."
Argumentssass::sass(). Also, if
theme
is a
-bslib::bs_theme()
object, Sass code may reference the relevant Bootstrap
+bslib::bs_theme()
object, Sass code may reference the relevant Bootstrap
Sass variables, functions, mixins, etc.
"<\/code>, '<\/code>, (<\/code> or {<\/code> with a matching "<\/code>, '<\/code>, )<\/code> or }<\/code>. unparsablequotes: It looks like your R code contains specially formatted quotation marks or "curly" quotes ({{character}}<\/code>) around character strings, making your code invalid. R requires character values to be contained in straight quotation marks ("<\/code> or '<\/code>).<\/p> {{code}} Don't worry, this is a common source of errors when you copy code from another app that applies its own formatting to text. You can try replacing the code on that line with the following. There may be other places that need to be fixed, too.<\/p> {{suggestion}} unparsableunicode:
It looks like your R code contains an unexpected special character ({{character}}<\/code>) that makes your code invalid.<\/p> {{code}} Sometimes your code may contain a special character that looks like a regular character, especially if you copy and paste the code from another app. Try deleting the special character from your code and retyping it manually.<\/p> unparsableunicodesuggestion:
It looks like your R code contains an unexpected special character ({{character}}<\/code>) that makes your code invalid.<\/p> {{code}} Sometimes your code may contain a special character that looks like a regular character, especially if you copy and paste the code from another app. You can try replacing the code on that line with the following. There may be other places that need to be fixed, too.<\/p> {{suggestion}} and: and or: or listcomma: , oxfordcomma: ,"},{"path":"https://pkgs.rstudio.com/learnr/dev/articles/multilang.html","id":"format-of-language-option-in-yaml-header","dir":"Articles","previous_headings":"","what":"Format of language Option in YAML Header:","title":"Internationalization","text":"several ways can use language option choose language translation customize phrasing used particular language.","code":""},{"path":"https://pkgs.rstudio.com/learnr/dev/articles/multilang.html","id":"default-language","dir":"Articles","previous_headings":"Format of language Option in YAML Header:","what":"Default Language","title":"Internationalization","text":"Chose default language tutorial. learnr currently provides complete translations \"en\", \"fr\", \"es\", \"pt\", \"tr\", \"eu\", \"de\", \"ko\", \"zh\", \"pl\". translation need available use default language, particular providing custom translation language without available complete translation. want change default language, use: also providing language customizations, first language list customizations default language.","code":"language: \"fr\""},{"path":"https://pkgs.rstudio.com/learnr/dev/articles/multilang.html","id":"customizing-a-single-language","dir":"Articles","previous_headings":"Format of language Option in YAML Header:","what":"Customizing a Single Language","title":"Internationalization","text":"customize displayed text single language, use following format. format customization applied English translation, also default language tutorial.","code":"language: en: button: runcode: Run! text: startover: Restart!"},{"path":"https://pkgs.rstudio.com/learnr/dev/articles/multilang.html","id":"customizing-multiple-languages","dir":"Articles","previous_headings":"Format of language Option in YAML Header:","what":"Customizing Multiple Languages","title":"Internationalization","text":"provide custom display text multiple languages, provide list containing button /text custom labels. example , default tutorial language Spanish (es). Note first language customizations used rendered tutorial. future, may extend multi-language features learnr accommodate dynamic localization.","code":"language: es: button: runcode: Ejecutar en: button: runcode: Run! text: startover: Restart!"},{"path":"https://pkgs.rstudio.com/learnr/dev/articles/multilang.html","id":"store-customizations-in-a-json-file","dir":"Articles","previous_headings":"Format of language Option in YAML Header:","what":"Store Customizations in a JSON File","title":"Internationalization","text":"intend reuse custom language repeatedly, may helpful store custom language parameters JSON file simply import file. case, can set language code item path single JSON file, written structure YAML. example, write Spanish language customizations tutorial_es.json following R code: load customizations file referencing YAML header. Similarly, can store entire language list JSON file provide path JSON file language key. R code writes custom text en es languages custom_language.json, reference YAML header:","code":"jsonlite::write_json( list( button = list(runcode = \"Ejecutar\"), text = list(startover = \"Empezar de nuevo\") ), path = \"tutorial_es.json\", auto_unbox = TRUE ) language: es: tutorial_es.json jsonlite::write_json( list( en = list( button = list(runcode = \"Run the code\"), text = list(startover = \"Restart the tutorial\") ), es = list( button = list(runcode = \"Ejecutar\"), text = list(startover = \"Empezar de nuevo\") ) ), path = \"custom_language.json\", auto_unbox = TRUE ) language: custom_language.json"},{"path":"https://pkgs.rstudio.com/learnr/dev/articles/multilang.html","id":"complete-translations","dir":"Articles","previous_headings":"","what":"Complete Translations","title":"Internationalization","text":"Complete translations provided internal function i18n_translations(). contribute complete translation language currently provided learnr, please submit pull request github.com/rstudio/learnr updating list data-raw/i18n_translations.yml, following format described file. Note language available inside alert boxes learnr, ’ll need set language one language codes used bootbox1. language available bootbox, buttons default English.","code":""},{"path":"https://pkgs.rstudio.com/learnr/dev/articles/publishing.html","id":"r-package","dir":"Articles","previous_headings":"","what":"R Package","title":"Publishing Basics","text":"convenient way publish tutorials within R packages. Tutorials included within R packages can run via learnr::run_tutorial function. example, following functions runs “hello” “slidy” sample tutorials built learnr package: bundle tutorial R package make available running via run_tutorial function : Create tutorials directory within inst sub-directory package create directory tutorial (e.g. inst/tutorials/hello, inst/tutorials/slidy, etc.). Add .Rmd associated tutorial directory. (may see ..._files/ directory .html file periodically get generated adjacent .Rmd tutorial. can safely ignore, delete, exclude package version control. temporary artifacts produced rendering tutorial specific system aren’t likely portable environments.) ’ve done users can run tutorial follows (note sure install learnr package attempting run tutorial): Users simply install learnr directly running tutorial, example:","code":"learnr::run_tutorial(\"hello\", package = \"learnr\") learnr::run_tutorial(\"slidy\", package = \"learnr\") install.packages(\"learnr\") learnr::run_tutorial(\"introduction\", package = \"mypackage\")"},{"path":"https://pkgs.rstudio.com/learnr/dev/articles/publishing.html","id":"exercise-checkers","dir":"Articles","previous_headings":"R Package","what":"Exercise Checkers","title":"Publishing Basics","text":"Note tutorial performs exercise checking via external package sure add package use checking Imports dependency package ’s installed automatically along package. Note ’s likely learnr package eventually include depend another package provides checking functions. time though explicit installation external checking packages requirement.","code":""},{"path":[]},{"path":"https://pkgs.rstudio.com/learnr/dev/articles/publishing.html","id":"rstudio-connect-and-shinyapps-io","dir":"Articles","previous_headings":"Tutorial deployment","what":"RStudio Connect and shinyapps.io","title":"Publishing Basics","text":"can also deploy tutorials server ’d deploy Shiny application. several ways , two : Publish shinyapps.io cloud service. Publish RStudio Connect server. methods, can use RStudio IDE’s integrated one-click publishing publish directly desktop:","code":""},{"path":"https://pkgs.rstudio.com/learnr/dev/articles/publishing.html","id":"shiny-server-open-source-and-pro-versions","dir":"Articles","previous_headings":"Tutorial deployment","what":"Shiny Server (Open Source and Pro versions)","title":"Publishing Basics","text":"third way publishing tutorial serve .Rmd document hosted directory Shiny Server. Shiny Server fully supports interactive R Markdown documents. take advantage capability, need make sure rmarkdown installed available users. can running following command: hosted directory include app.R server.R file, Shiny Server look see contains .Rmd files. , Shiny Server host directory “R Markdown” mode using rmarkdown::run(). Particular .Rmd files can accessed referencing full path including filename, e.g., http://myserver.org/mydocs/hello.Rmd. (Note need finish url .Rmd, .html). request made directory rather particular .Rmd file, Shiny Server attempt serve file index.Rmd. file exist, user get error alerting file available.","code":"sudo su - -c \"R -e \\\"install.packages('rmarkdown')\\\"\""},{"path":"https://pkgs.rstudio.com/learnr/dev/articles/publishing.html","id":"resource-usage","dir":"Articles","previous_headings":"Tutorial deployment","what":"Resource Usage","title":"Publishing Basics","text":"Since users can execute arbitrary R code within tutorial, code can also consume arbitrary resources time! (e.g. users create infinite loop allocate available memory machine). limit time taken execution exercises can use exercise.timelimit option. see documentation Exercise Time Limits additional details. can use various features RStudio Connect Shiny Server Pro run tutorials within resource /filesystem sandbox. See also section Exercise Execution details customizing evaluation environment exercises.","code":""},{"path":"https://pkgs.rstudio.com/learnr/dev/articles/publishing.html","id":"security-considerations","dir":"Articles","previous_headings":"Tutorial deployment","what":"Security Considerations","title":"Publishing Basics","text":"Since tutorials enable end users submit R code execution server, need architect deployment tutorials code placed appropriate sandbox. variety ways accomplish including placing entire Shiny Server container Linux namespace limits ’s access filesystem /system resources. Note default running UNIX systems learnr package runs exercise code within forked child process. means ’s possible exercise code modify state parent Shiny Server process. can customize evaluation environment exercises using AppArmor system resource management facilities (see Exercise Execution section details).","code":""},{"path":"https://pkgs.rstudio.com/learnr/dev/articles/publishing.html","id":"deployment-dependencies-not-found","dir":"Articles","previous_headings":"Tutorial deployment > Security Considerations","what":"Deployment Dependencies Not Found","title":"Publishing Basics","text":"tutorial contains broken code within exercises users fix, CRAN version packrat find dependencies install tutorial deployed. deploy tutorials containing broken exercise code, install development version packrat. version packrat able find dependencies per R chunk, allowing broken R chunks within tutorial file.","code":"devtools::install_github(\"rstudio/packrat\")"},{"path":"https://pkgs.rstudio.com/learnr/dev/articles/publishing.html","id":"hosting-services","dir":"Articles","previous_headings":"","what":"Hosting Services","title":"Publishing Basics","text":"Publishing tutorials server makes instantly accessible user web browser, requires local installation R R packages. also opens possibility collecting data user interactions tutorials (progress made, errors encountered, etc.). learnr package includes variety mechanisms intended make easy deploy within tutorial hosting service, described . writing publicly available tutorial hosting services, however hope change soon, update documentation services become available.","code":""},{"path":"https://pkgs.rstudio.com/learnr/dev/articles/publishing.html","id":"tutorial-storage","dir":"Articles","previous_headings":"Hosting Services","what":"Tutorial Storage","title":"Publishing Basics","text":"Tutorials save state inputs outputs (e.g. exercise question submissions) automatically restore users revisit tutorial. locally deployed tutorials (e.g. tutorials run within R package) state saved within local filesystem. server deployed tutorials state saved within per-domain storage provided end user’s web browser. benefit saving restoring state per-user basis without notion user authentication identity, however work within single web browser (.e. state won’t restored users accesses tutorial another machine).","code":""},{"path":"https://pkgs.rstudio.com/learnr/dev/articles/publishing.html","id":"storage-provider","dir":"Articles","previous_headings":"Hosting Services > Tutorial Storage","what":"Storage Provider","title":"Publishing Basics","text":"Hosting services typically want provide custom implementation storage tutorial state tied tutorial provisioning user identity system. custom storage provider specified assigning R list includes storage functions tutorial.storage global option. example, “-op” storage provider: parameters passed storage provider’s functions follows (note various ID fields can customized hosting provider, see Tutorial Identifiers section details):","code":"options(tutorial.storage = list( # save an arbitrary R object \"data\" to storage save_object = function(tutorial_id, tutorial_version, user_id, object_id, data) { }, # retreive a single R object from storage get_object = function(tutorial_id, tutorial_version, user_id, object_id) { NULL }, # retreive a list of all R objects stored get_objects = function(tutorial_id, tutorial_version, user_id) { list() }, # remove all stored R objects remove_all_objects = function(tutorial_id, tutorial_version, user_id) { } )"},{"path":"https://pkgs.rstudio.com/learnr/dev/articles/publishing.html","id":"exercise-execution","dir":"Articles","previous_headings":"Hosting Services","what":"Exercise Execution","title":"Publishing Basics","text":"Note default running UNIX systems learnr package runs exercise code within forked child process. means ’s possible exercise code modify state parent Shiny Server process. section describe various ways customizing exercise execution.","code":""},{"path":"https://pkgs.rstudio.com/learnr/dev/articles/publishing.html","id":"start-and-cleanup-hooks","dir":"Articles","previous_headings":"Hosting Services > Exercise Execution","what":"Start and Cleanup Hooks","title":"Publishing Basics","text":"learnr package can ’s exercise evaluation environment customized using onstart oncleanup hooks. Within hooks can use functions RAppArmor package another package provides interfaces system resource management functions. Using method can apply time limits, resource limits, filesystem limits. steps required use RAppArmor onstart oncleanup hooks: Install configure RAppArmor package described : https://github.com/jeroenooms/RAppArmor#readme Add following line /etc/apparmor.d/rapparmor.d/r-user profile (required default AppArmor profile also support calling pandoc markdown renderer): Define onstart oncleaup hooks setting tutorial.exercise.evaluator.onstart tutorial.exercise.evaluator.oncleanup global options. example: ’d likely set options within Rprofile.site another R source file evaluated prior running tutorial rmarkdown::run.","code":"/usr/lib/rstudio/bin/pandoc/* rix, options(tutorial.exercise.evaluator.onstart = function(pid) { # import RAppArmor require(RAppArmor, quietly = TRUE) # set process group to pid (allows kill of entire subtree in cleanup) setpgid(); # set nice priority setpriority(10) # set rlimits as appropriate rlimit_nproc(1000) rlimit_as(1024*1024*1024) # change to r-user profile (see note above on required edit to r-user) aa_change_profile(\"r-user\") }) options(tutorial.exercise.evaluator.oncleanup = function(pid) { # import RAppArmor require(RAppArmor, quietly = TRUE) # kill entire process subtree. note that the second call works # because the call to setpgid above sets our pgid (process group id) # to our pid (process id) kill(pid, tools::SIGKILL) kill(-1 * pid, tools::SIGKILL) })"},{"path":"https://pkgs.rstudio.com/learnr/dev/articles/publishing.html","id":"fully-custom-evaluator","dir":"Articles","previous_headings":"Hosting Services > Exercise Execution","what":"Fully Custom Evaluator","title":"Publishing Basics","text":"can replace default exercise evaluation code entirely via tutorial.exercise.evaluator global R option. evaluator R function accepts four arguments: expression evaluate timelimit evaluation serializable representation exercise evaluated session associated request returns list functions (start, completed, result) use execution. two default evaluators (used Windows/MacOS UNIX systems, respectively, ): inline_evaluator — Evaluate exercises inline within main Shiny Server process (default Windows Mac OS systems). forked_evaluator — Evaluate exercises within forked child process (default UNIX systems). can see source code evaluators : https://github.com/rstudio/learnr/blob/main/R/evaluators.R. parameters provided evaluator may expanded future, custom evaluators permit additional arguments yet defined.","code":""},{"path":"https://pkgs.rstudio.com/learnr/dev/articles/publishing.html","id":"external-evaluator","dir":"Articles","previous_headings":"Hosting Services > Exercise Execution > Fully Custom Evaluator","what":"External Evaluator","title":"Publishing Basics","text":"versions learnr later 0.10.1, also support external_evaluator. evaluator allows exercises executed remote host rather host running Shiny process. can use evaluator specifying tutorial.external.host option setting TUTORIAL_EXTERNAL_EVALUATOR_HOST environment variable. set, learnr submit exercises HTTP specified host. given host expected fulfill OpenAPI specification. words, two HTTP endpoints: POST /learnr/ - Initiate session POST /learnr/ - Submit exercise run part session","code":""},{"path":"https://pkgs.rstudio.com/learnr/dev/articles/publishing.html","id":"events","dir":"Articles","previous_headings":"","what":"Events","title":"Publishing Basics","text":"Learnr event system can used recording information usage, causing code run events occur. part deploying tutorial might want record various user events occur within tutorials (e.g. exercise question submissions, requests hints/solutions, etc.). event system can also used cause arbitrary code run events occur.","code":""},{"path":"https://pkgs.rstudio.com/learnr/dev/articles/publishing.html","id":"recording-events","dir":"Articles","previous_headings":"Events","what":"Recording Events","title":"Publishing Basics","text":"can capture events using custom event recorder function. function specified via tutorial.event_recorder global option. example, ’s define simple event recorder function prints stdout: following parameters passed event recorder function (note various ID fields can customized hosting provider, see Tutorial Identifiers section details): event parameter one following values: data parameter R list provides additional data varies depending event recorded.","code":"tutorial_event_recorder"},{"path":"https://pkgs.rstudio.com/learnr/dev/articles/publishing.html","id":"event-handlers","dir":"Articles","previous_headings":"Events","what":"Event handlers","title":"Publishing Basics","text":"can also useful cause code run event occurs. event_register_handler() function can used . example, cause message printed console \"section_viewed\" event triggered: Note event_register_handler() called code chunk context=\"server-start\"! callback must take three parameters: session: Shiny session object. event: name event (like \"section_viewed\"). data: list contains arbitrary data. cases useful handlers triggered just tutorial. can done one_time() function. Inside handler, call one_time(), pass session object, cond, condition expression, expr, code expression run. first time cond true, expr evaluated; , expr evaluated . example , cond true time section ID \"section-exercise--hint\" viewed, first time section visible, print message. Technical note: reason one_time() unusual interface needs able store data persists across runs tutorial. code run one time, even user stops document starts ; resets user clicks “Start ”. section IDs generated automatically section title. example, section heading: ID section----section. want use different ID, can supply curly braces, prepended section-. set ID section-myid: can even sections don’t title, ID:","code":"```{r context=\"server-start\"} event_register_handler(\"section_viewed\", function(session, event, data) { message(\"event: section_viewed: \", data$sectionId) }) ``` ```{r context=\"server-start\"} event_register_handler(\"section_viewed\", function(session, event, data) { one_time( session, cond = data$sectionId == \"section-exercise-with-hint\", expr = { message(\"Seeing \", data$sectionId, \" for the first time.\") } ) } ) ``` ### This is a section ### This is a section {#myid} ### {#myid}"},{"path":"https://pkgs.rstudio.com/learnr/dev/articles/publishing.html","id":"tutorial-identifiers","dir":"Articles","previous_headings":"Events","what":"Tutorial Identifiers","title":"Publishing Basics","text":"Tutorial Storage Recording Events sections describe various ways record user progress actions within tutorials. Storage tutorial state requires unique identifiers tutorials (versions) well users. Tutorial hosting services often need customize identifiers based notions tutorial provisioning user identify. section describes .","code":""},{"path":"https://pkgs.rstudio.com/learnr/dev/articles/publishing.html","id":"default-identifiers","dir":"Articles","previous_headings":"Events > Tutorial Identifiers","what":"Default Identifiers","title":"Publishing Basics","text":"default tutorial user identifiers determined follows: addition, tutorial authors can use YAML metadata provide custom tutorial IDs versions. example:","code":"--- title: \"Hello, Tutorial!\" tutorial: id: \"com.example.tutorials.my-first-tutorial\" version: 2.1 output: learnr::tutorial runtime: shiny_prerendered ---"},{"path":"https://pkgs.rstudio.com/learnr/dev/articles/publishing.html","id":"custom-identifiers","dir":"Articles","previous_headings":"Events > Tutorial Identifiers","what":"Custom Identifiers","title":"Publishing Basics","text":"Tutorial hosting services often need provide custom external definitions tutorial IDs/versions user IDs. can accomplished adding HTTP headers requests route tutorial. names headers configurable, specified using tutorial.http_header_tutorial_id, tutorial.http_header_tutorial_version tutorial.http_header_user_id global options. example: configuring custom header names ’d need ensure HTTP proxy layer mediating traffic tutorials set appropriate values.","code":"options( tutorial.http_header_tutorial_id = \"X-Tutorial-ID\", tutorial.http_header_tutorial_version = \"X-Tutorial-Version\", tutorial.http_header_user_id = \"X-Tutorial-UserID\" })"},{"path":"https://pkgs.rstudio.com/learnr/dev/articles/questions.html","id":"overview","dir":"Articles","previous_headings":"","what":"Overview","title":"Interactive Questions","text":"can include one multiple-choice quiz questions within tutorial help verify readers understand concepts presented. Questions can either single multiple correct answers. Include question calling question function within R code chunk: example defines question single correct answer. can also create questions require multiple answers specified: Note examples specify echo = FALSE option R code chunks produce questions. required ensure R source code questions printed within document. example quiz questions look like within tutorial:","code":"```{r letter-a, echo=FALSE} question(\"What number is the letter A in the English alphabet?\", answer(\"8\"), answer(\"14\"), answer(\"1\", correct = TRUE), answer(\"23\") ) ``` ```{r where-am-i, echo=FALSE} question(\"Where are you right now? (select ALL that apply)\", answer(\"Planet Earth\", correct = TRUE), answer(\"Pluto\"), answer(\"At a computing device\", correct = TRUE), answer(\"In the Milky Way\", correct = TRUE), incorrect = \"Incorrect. You're on Earth, in the Milky Way, at a computer.\") ) ```"},{"path":"https://pkgs.rstudio.com/learnr/dev/articles/questions.html","id":"custom-messages","dir":"Articles","previous_headings":"","what":"Custom Messages","title":"Interactive Questions","text":"can add answer-specific correct/incorrect messages using message option. example:","code":"```{r letter-a, echo=FALSE} question(\"What number is the letter A in the *English* alphabet?\", answer(\"8\"), answer(\"1\", correct = TRUE), answer(\"2\", message = \"2 is close but it's the letter B rather than A.\"), answer(\"26\") ) ```"},{"path":"https://pkgs.rstudio.com/learnr/dev/articles/questions.html","id":"formatting-and-math","dir":"Articles","previous_headings":"","what":"Formatting and Math","title":"Interactive Questions","text":"can use markdown format text within questions, answers, custom messages. can also include embedded LaTeX math using $ delimiter. example: Note use double-backslash (\\\\) prefix LaTeX macros. necessary “escape” single-backslash R doesn’t interpret special character. ’s example look like within tutorial:","code":"```{r math, echo=FALSE} x"},{"path":"https://pkgs.rstudio.com/learnr/dev/articles/questions.html","id":"retrying-questions","dir":"Articles","previous_headings":"","what":"Retrying Questions","title":"Interactive Questions","text":"default incorrect answer provided users get appropriate feedback correct answer(s) highlighted. can also provide option user try question . can using allow_retry option, example:","code":"```{r letter-a, echo=FALSE} question(\"What number is the letter A in the English alphabet?\", answer(\"8\"), answer(\"14\"), answer(\"1\", correct = TRUE), answer(\"23\"), allow_retry = TRUE ) ```"},{"path":"https://pkgs.rstudio.com/learnr/dev/articles/questions.html","id":"random-answer-order","dir":"Articles","previous_headings":"","what":"Random Answer Order","title":"Interactive Questions","text":"want answers questions randomly arranged, can add random_answer_order option. example:","code":"```{r letter-a, echo=FALSE} question(\"What number is the letter A in the English alphabet?\", answer(\"8\"), answer(\"14\"), answer(\"1\", correct = TRUE), answer(\"23\"), random_answer_order = TRUE ) ```"},{"path":"https://pkgs.rstudio.com/learnr/dev/articles/questions.html","id":"groups-of-questions","dir":"Articles","previous_headings":"","what":"Groups of Questions","title":"Interactive Questions","text":"can present group related questions quiz wrapping questions within quiz function. example:","code":"```{r quiz1, echo=FALSE} quiz(caption = \"Quiz 1\", question(\"What number is the letter A in the *English* alphabet?\", answer(\"8\"), answer(\"14\"), answer(\"1\", correct = TRUE), answer(\"23\") ), question(\"Where are you right now? (select ALL that apply)\", answer(\"Planet Earth\", correct = TRUE), answer(\"Pluto\"), answer(\"At a computing device\", correct = TRUE), answer(\"In the Milky Way\", correct = TRUE), incorrect = \"Incorrect. You're on Earth, in the Milky Way, at a computer.\" ) ) ```"},{"path":"https://pkgs.rstudio.com/learnr/dev/articles/releases/learnr_v0-11-0.html","id":"intro","dir":"Articles > Releases","previous_headings":"","what":"Intro","title":"learnr v0.11.0","text":"happy announce version 0.11.0 learnr arrived CRAN mirror near . release collects many large small improvements learnr package, goal making easier create interactive tutorials teaching programming concepts skills. Read overview changes version 0.11.0, review changelog full list updates. Use install.packages() install latest version learnr, includes demonstrations many new features.","code":"install.packages(\"learnr\")"},{"path":"https://pkgs.rstudio.com/learnr/dev/articles/releases/learnr_v0-11-0.html","id":"learnr-speaks-more-than-r","dir":"Articles > Releases","previous_headings":"","what":"learnr speaks more than R","title":"learnr v0.11.0","text":"learnr tutorials great way teach others R: ’s package name, . thanks R Markdown’s flexibility, learnr great way teach programming languages well, using spoken language choice!","code":""},{"path":"https://pkgs.rstudio.com/learnr/dev/articles/releases/learnr_v0-11-0.html","id":"internationalization","dir":"Articles > Releases","previous_headings":"learnr speaks more than R","what":"Internationalization","title":"learnr v0.11.0","text":"learnr now allows tutorial authors choose words language used learnr’s UI elements using language argument tutorial format. grateful contributions number community members allow learnr include ---box support following languages: Basque (eu) language support contributed Mikel Madina (#489) Portuguese (pt) language support contributed Beatriz Milz (#488, #551) Spanish (es) language support contributed Yanina Bellini Saibene (#483, #546) Turkish (tr) language support contributed Hulya Yigit James J Balamuta ( #493, #554) German (de) language support contributed @NinaCorrelAid (#611, #612) Korean (ko) language support contributed Choonghyun Ryu (#634) Chinese (zh) language support contributed @shalom-lab (#681) Polish (pl) language support contributed Jakub Jędrusiak (#686) can choose one via language setting tutorial’s YAML frontmatter: language chosen tutorial passed R session used evaluate exercise code, translatable messages R also presented specified language (thanks Alex Rossell Hayes). addition, can customize words displayed specific UI elements using named list. example, default text used “Run Code” button Spanish Ejecutar código. can use Spanish language translation modify particular translation using named list: can learn internationalization features full syntax customizing language used learnr internationalization vignette. love support languages happily welcome contribution.","code":"--- output: learnr::tutorial: language: es runtime: shinyrmd --- --- output: learnr::tutorial: language: es: button: runcode: Ejecutar runtime: shinyrmd ---"},{"path":"https://pkgs.rstudio.com/learnr/dev/articles/releases/learnr_v0-11-0.html","id":"support-for-additional-programming-languages","dir":"Articles > Releases","previous_headings":"learnr speaks more than R","what":"Support for additional programming languages","title":"learnr v0.11.0","text":"addition spoken languages, learnr now better running code programming languages R. biggest improvement SQL exercises, learners can execute SQL queries database. previously possible, now tutorial authors can use grading packages like gradethis grade tables returned student’s queries. can see action using run_tutorial(\"sql-exercise\", \"learnr\") (SQL demo online version). learnr also includes UI improvements interactive exercise component languages, including syntax highlighting basic auto-completion exercise code languages Python, JavaScript, Julia SQL. Try run_tutorial(\"polyglot\", \"learnr\") (polyglot online version) see several programming languages use tutorial. exercise checking, learnr communicates exercise engine exercise-checking functions via new engine argument included exercise checker function signature.","code":""},{"path":"https://pkgs.rstudio.com/learnr/dev/articles/releases/learnr_v0-11-0.html","id":"exercises","dir":"Articles > Releases","previous_headings":"","what":"Exercises","title":"learnr v0.11.0","text":"Beyond expanded language support, interactive exercises questions learnr tutorials received number updates improvements.","code":""},{"path":"https://pkgs.rstudio.com/learnr/dev/articles/releases/learnr_v0-11-0.html","id":"setup-chunk-chaining","dir":"Articles > Releases","previous_headings":"Exercises","what":"Setup chunk chaining","title":"learnr v0.11.0","text":"Thanks Nischal Shrestha, exercises can now chained together via chained setup chunks setup one exercise may depend exercises1, including setup chunks exercises tutorial. makes easier author progressively work problem series interactive exercises build . exercise chunk — R chunk exercise = TRUE — can specify setup chunk using {label}-chunk naming convention exercise.setup chunk option. chunk used setup chunk may also include execise.setup option specifying parent chunk. Try run_tutorial(\"setup-chunks\", \"learnr\") (setup-chunks online version) see chained setup chunks action.","code":""},{"path":"https://pkgs.rstudio.com/learnr/dev/articles/releases/learnr_v0-11-0.html","id":"catching-common-code-issues","dir":"Articles > Releases","previous_headings":"Exercises","what":"Catching common code issues","title":"learnr v0.11.0","text":"teaching new programming concepts, can helpful provide learners scaffolding exercise focus attention skills just recently learned. example, explaining difference names_from values_from arguments tidyr::pivot_wider(), might want ask students practice using arguments without distracting writing code set transformation. ’s common use underscores patterns indicate students fill missing piece. students submit code containing blanks, learnr warn student replace ____ valid code. Blanks detected using regular expressions (since blanks may make code unparsable), learnr’s default pattern detect three consecutive underscores. Authors can choose pattern detecting blanks exercise.blanks chunk option. Setting exercise.blanks = \"[.]{2}[-z]+[.]{2}\", example, allow author use valid R syntax blanks. warning message shown students calls blanks need fill . Another common problem code involves character conversions student copies code application automatic formatting pastes text learnr tutorial. frequently see problems quotation marks code samples converted Unicode-formatted quotation marks (curly quotes). general, kinds conversions make R code unparsable. Now learnr detect mistakes suggest replacement. Finally, learner submits code isn’t parsable – reasons – learnr now returns generic, helpful, feedback message guidance common syntax errors. cases, actual R output, often error message, always shown learner. helps students acclimate error messages see console encountered every-day usage R.","code":"library(tidyverse) us_rent_income %>% select(name = NAME, variable, estimate) %>% pivot_wider(names_from = ____, values_from = ____)"},{"path":"https://pkgs.rstudio.com/learnr/dev/articles/releases/learnr_v0-11-0.html","id":"improved-keyboard-support","dir":"Articles > Releases","previous_headings":"Exercises","what":"Improved keyboard support","title":"learnr v0.11.0","text":"Keyboard navigation shortcuts interactive exercise code editor improved. Previously, editor trap keyboard focus Tab key used indentation editor. Now, users can press Escape editor focus temporarily disable using Tab indentation, making possible move next previous element tutorial. demonstration navigating exercise editor. start animation, editor focus '2 + 2' typed editor. user presses Esc key dark outline applied editor container. Pressing Shift Tab moves previous element, 'Run Code' button exercise toolbar. user uses Tab move back editor presses Esc disable indentation, followed Tab move editor next focusable element page. exercise editor also supports additional keyboard shortcuts: (magrittr) pipe %>% Cmd / Ctrl + Shift + M assignment arrow, <- Opt / Alt + - Cmd / Ctrl + Enter runs selected code","code":""},{"path":"https://pkgs.rstudio.com/learnr/dev/articles/releases/learnr_v0-11-0.html","id":"the-data-directory","dir":"Articles > Releases","previous_headings":"Exercises","what":"The data directory","title":"learnr v0.11.0","text":"users submit code part exercise, learnr evaluates code temporary directory ’s used just evaluation submission. helps ensure every submission returns value, makes harder authors write exercises use files, .csv files, inputs user’s code. remedy , thanks work Alex Rossell Hayes, learnr now treats data/ directory, stored adjacent tutorial, special. Authors can reference files data/ directory static content tutorials, files also made available student use exercises. exercise evaluation copies directory exercise’s temporary directory subsequent submissions work even student accidentally overwrites deletes files. cases, files data/ can referenced using relative path, e.g. \"data/estimates.csv\".","code":""},{"path":"https://pkgs.rstudio.com/learnr/dev/articles/releases/learnr_v0-11-0.html","id":"error-checking","dir":"Articles > Releases","previous_headings":"Exercises","what":"Error checking","title":"learnr v0.11.0","text":"now possible provide customized feedback learner’s exercise submission produces evaluation error. exercise.error.checker option tutorial_options() allows authors define error-checking function applied error thrown user’s code. may also use exercise.error.check.code define default error checking code normally written -error-check chunk. excellent default error checker gradethis::gradethis_error_checker(), enabled default gradethis loaded learnr tutorial. gradethis error checker automatically provides student hint error encountered, comparing submitted code expected solution.","code":""},{"path":"https://pkgs.rstudio.com/learnr/dev/articles/releases/learnr_v0-11-0.html","id":"questions","dir":"Articles > Releases","previous_headings":"","what":"Questions","title":"learnr v0.11.0","text":"release learnr includes new question type, question_numeric(). numeric question type complement question_text() numeric answer required. general, question answers specified answer() function, answers can single value, limited applicability text numeric questions. Now, authors can use answer_fn() provide single-argument function takes student’s submitted answer determines submission correct. allows authors check range values answers .","code":""},{"path":"https://pkgs.rstudio.com/learnr/dev/articles/releases/learnr_v0-11-0.html","id":"thanks","dir":"Articles > Releases","previous_headings":"","what":"Thanks","title":"learnr v0.11.0","text":"hugely thankful 101 community members contributed pull requests, submitted translations, reported issues since last release. many contributions updates version learnr aren’t covered post; sure check full list changes. Thank also previous maintainer learnr, Barrett Schloerke! (learnr now maintained , Garrick Aden-Buie.) 🙏 Big thank contributors: @acarzfr, @acastleman, @adisarid, @agmath, @AlbertLeeUCSF, @andysouth, @annafergusson, @assignUser, @batpigandme, @bbitarello, @beatrizmilz, @bhogan-mitre, @bjornerstedt, @blaiseli, @Brunox13, @C4caesar, @caievelyn, @cderv, @chendaniely, @choonghyunryu, @chrisaberson, @coatless, @ColinFay, @cpsievert, @cswclui, @czucca, @davidkane9, @dcossyleon, @ddauber, @deepanshu88, @dfailing, @dmenne, @dputhier, @DrAtzi, @drmowinckels, @dtkaplan, @elimillera, @elmstedt, @emarsh25, @enoches, @ericemc3, @ethelpruss, @gadenbuie, @gaelso, @garrettgman, @gdkrmr, @gtritchie, @gvwilson, @helix84, @hyigit2, @ijlyttle, @indenkun, @jakub-jedrusiak, @jcheng5, @jennybc, @jhk0530, @joe-chelladurai, @johnbde, @jooyoungseo, @jtelleriar, @jtransue, @kaisamng, @KatherineCox, @kendavidn, @kevinushey, @lorenzwalthert, @ltl-manabi, @MAGALLANESJoseManuel, @MaralDorri, @markwsac, @MayaGans, @meatballhat, @mikelmadina, @mine-cetinkaya-rundel, @mpjashby, @mstackhouse, @mutlusun, @NinaCorrelAid, @nischalshrestha, @NuoWenLei, @petzi53, @plukethep, @profandyfield, @psads-git, @pseudorational, @RaymondBalise, @rossellhayes, @rundel, @schloerke, @shalom-lab, @shalutiwari, @siebrenf, @SilasK, @stragu, @themfrees, @tombeesley, @trestletech, @tvedebrink, @vnijs, @wch, @yabellini.","code":""},{"path":"https://pkgs.rstudio.com/learnr/dev/articles/shinyapps-publishing.html","id":"alternative-options-for-hosting-learnr-tutorials","dir":"Articles","previous_headings":"","what":"Alternative options for hosting learnr tutorials","title":"Publishing on shinyapps.io","text":"Note options hosting tutorials besides shinyapps.io, : creating tutorial package students run locally (free, requires students able download install packages, well run commands R), setting free academic Shiny Server Pro account (free, provided server institution host software, may require help). require configuration setup, may beyond either students wish undertake time (.e. running short-term course). leads third option costs money, may save valuable time system administration: deploying learnr tutorial shinyapps.io. Note: Currently, free shinyapps.io service designed three five users . like multiple users able access service without tutorial crashing, need pay hosted shinyapps.io service.","code":""},{"path":"https://pkgs.rstudio.com/learnr/dev/articles/shinyapps-publishing.html","id":"optimal-settings-for-shinyapps-io","dir":"Articles","previous_headings":"","what":"Optimal settings for shinyapps.io","title":"Publishing on shinyapps.io","text":"educator, assume concerns: can students access tutorials concurrently, multiple sessions, long period time? can reduce cost tutorial hosting? Balancing two things part figuring optimal configuration settings.","code":""},{"path":"https://pkgs.rstudio.com/learnr/dev/articles/shinyapps-publishing.html","id":"optimizing-for-classroom-settings","dir":"Articles","previous_headings":"Optimal settings for shinyapps.io","what":"Optimizing for classroom settings","title":"Publishing on shinyapps.io","text":"published tutorials shinyapps.io, log account, click application page configure following: Instances: increase maximum amount allowed. total number independent servers available run tutorial. , better! help handle “flash traffic” (numerous students load tutorial ) beginning class. go Settings > General configure following: Instance Size: increase maximum size possible. larger instance, memory work . larger memory, students can concurrently working. Finally, go Settings > Advanced page configure following: Max Worker Processes: reduce possible, possibly 2. Keep equation mind: (Instance Size) / (Worker Processes * Max Connections) = Amount memory available new student accessing tutorial. Max Connections: reduce possible, possibly 20 . Start Count: increase maximum size possible. number servers (“instances”) launch single person accesses tutorial. means first student access tutorial class start servers others can access quickly. recommend set Start Count Instance Size maximum, monitor hours used, adjust settings .","code":""},{"path":"https://pkgs.rstudio.com/learnr/dev/articles/shinyapps-publishing.html","id":"reducing-cost","dir":"Articles","previous_headings":"Optimal settings for shinyapps.io","what":"Reducing cost","title":"Publishing on shinyapps.io","text":"paying active hours use per month, want minimize stay within subscription limits. , can adjust following: Reduce Start Count Increase Max Worker Processes Increase Max Connections Reduce Connection Timeout Reduce Instance Size good workflow change one setting, observe usage metrics, modify needed.","code":""},{"path":[]},{"path":"https://pkgs.rstudio.com/learnr/dev/articles/shinyapps-publishing.html","id":"context","dir":"Articles","previous_headings":"Example use case","what":"Context","title":"Publishing on shinyapps.io","text":"Suppose teaching statistical programming seminar 5 weeks several class sections 60 people . course short students just introduced R RStudio, may worth setting full server hosting seminar tutorials asking students configure R package. browser-based interface also friendly may trouble understanding navigating RStudio interface first weeks classes. sections back--back, ideally, settings learnr tutorials robust enough allow next section’s students access .","code":""},{"path":"https://pkgs.rstudio.com/learnr/dev/articles/shinyapps-publishing.html","id":"initial-settings","dir":"Articles","previous_headings":"Example use case","what":"Initial settings","title":"Publishing on shinyapps.io","text":"situation, department purchase Standard shinyapps.io subscription $100/month, gave 2,000 Active Hours per month. (Note Active Hours refers amount time spent launching tutorial actively processing R code input submitted students instance.) tutorial deployed, set : 5 XXX-Large Instances (8 GB) shinyapps.io, 2 Worker Processes 10 Max Connections. also set Start Count 5, tutorials launched .","code":""},{"path":"https://pkgs.rstudio.com/learnr/dev/articles/shinyapps-publishing.html","id":"adjusting-based-on-usage-metrics","dir":"Articles","previous_headings":"Example use case","what":"Adjusting based on usage metrics","title":"Publishing on shinyapps.io","text":"observed usage metrics shinyapps.io dashboard Metrics. noticing tutorials require excessive memory, : changed size Instances X-Large (2 GB) increased Max Connections 15 reduced Start Count 2 completed week’s sections. 5-week course done, : canceled shinyapps.io Standard subscription, reduced Instance Count Instance Size single Large Instance (1 GB), left Worker Processes Max Connections . enabled students return tutorial workshop done, without optimized mass numbers students accessing tutorial . used around 1000 Active Hours first month, around 300 second month course, next year, likely purchase Standard subscription (<= 2000 hours / month) one month, reduce Basic level (<= 500 hours / month) second month. Example usage metrics dashboard :","code":""},{"path":"https://pkgs.rstudio.com/learnr/dev/articles/shinyapps-publishing.html","id":"troubleshooting-beyond-settings","dir":"Articles","previous_headings":"Example use case","what":"Troubleshooting beyond settings","title":"Publishing on shinyapps.io","text":"consecutive classes, still issues lingering open server connections previous class getting way. published identical learnr tutorial different name (.e. \"tutorial-2\"), direct students different link needed.","code":""},{"path":"https://pkgs.rstudio.com/learnr/dev/authors.html","id":null,"dir":"","previous_headings":"","what":"Authors","title":"Authors and Citation","text":"Garrick Aden-Buie. Author, maintainer. Barret Schloerke. Author. JJ Allaire. Author, conceptor. Alexander Rossell Hayes. Author. Nischal Shrestha. Contributor. Angela Li. Contributor. vignette . Copyright holder, funder. Ajax.org B.V.. Contributor, copyright holder. Ace library Zeno Rocha. Contributor, copyright holder. clipboard.js library Nick Payne. Contributor, copyright holder. Bootbox library Jake Archibald. Contributor, copyright holder. idb-keyval library i18next authors. Contributor, copyright holder. i18next library","code":""},{"path":"https://pkgs.rstudio.com/learnr/dev/authors.html","id":"citation","dir":"","previous_headings":"","what":"Citation","title":"Authors and Citation","text":"Aden-Buie G, Schloerke B, Allaire J, Rossell Hayes (2023). learnr: Interactive Tutorials R. https://rstudio.github.io/learnr/, https://github.com/rstudio/learnr.","code":"@Manual{, title = {learnr: Interactive Tutorials for R}, author = {Garrick Aden-Buie and Barret Schloerke and JJ Allaire and Alexander {Rossell Hayes}}, year = {2023}, note = {https://rstudio.github.io/learnr/, https://github.com/rstudio/learnr}, }"},{"path":"https://pkgs.rstudio.com/learnr/dev/index.html","id":"learnr-","dir":"","previous_headings":"","what":"Interactive Tutorials for R","title":"Interactive Tutorials for R","text":"learnr package makes easy turn R Markdown document interactive tutorial. Tutorials consist content along interactive components checking reinforcing understanding. Tutorials can include following: Narrative, figures, illustrations, equations. Code exercises (R code chunks users can edit execute directly). Quiz questions. Videos (supported services include YouTube Vimeo). Interactive Shiny components. Tutorials automatically preserve work done within , user works exercises questions returns tutorial later can pick right left .","code":""},{"path":"https://pkgs.rstudio.com/learnr/dev/index.html","id":"examples","dir":"","previous_headings":"","what":"Examples","title":"Interactive Tutorials for R","text":"examples tutorials created learnr package. tutorial featuring videos interactive questions guide new R user installation set everything ’ll need get started R. example tutorial teaching common data transformation: filtering rows data frame dplyr::filter(). example tutorial learners introduced dplyr::summarise(). Along way, learners also gain practice pipe operator, %>%, dplyr::group_by().","code":""},{"path":"https://pkgs.rstudio.com/learnr/dev/index.html","id":"installation","dir":"","previous_headings":"","what":"Installation","title":"Interactive Tutorials for R","text":"Install latest official learnr release CRAN: can install recent version -development GitHub remotes package: learnr works best recent version RStudio (v1.0.136 later) includes tools easily running previewing tutorials.","code":"install.packages(\"learnr\") # install.packages(\"remotes\") remotes::install_github(\"rstudio/learnr\")"},{"path":"https://pkgs.rstudio.com/learnr/dev/index.html","id":"hello-tutorial","dir":"","previous_headings":"","what":"Hello, Tutorial!","title":"Interactive Tutorials for R","text":"create tutorial, set runtime: shiny_prerendered YAML frontmatter .Rmd file turn R Markdown document interactive app. , call library(learnr) within Rmd file activate tutorial mode, use exercise = TRUE chunk option turn code chunks exercises. Users can edit execute R code see results right within browser. example, ’s simple tutorial: running tutorial document looks like user entered answer:","code":"--- title: \"Hello, Tutorial!\" output: learnr::tutorial runtime: shiny_prerendered --- ```{r setup, include=FALSE} library(learnr) ``` This code computes the answer to one plus one, change it so it computes two plus two: ```{r addition, exercise=TRUE} 1 + 1 ```"},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/answer.html","id":null,"dir":"Reference","previous_headings":"","what":"Question answer options — answer","title":"Question answer options — answer","text":"Create options users used question_checkbox() question_radio() learnr questions. question_text() question_numeric(), individual answers directly presented students, values can used determining student submitted correct answer. flexible feedback checkbox, text, numeric questions, answer_fn() can used provide function evaluates student's submission returns custom result.","code":""},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/answer.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Question answer options — answer","text":"","code":"answer(text, correct = FALSE, message = NULL, label = text) answer_fn(fn, label = NULL)"},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/answer.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Question answer options — answer","text":"text answer text value; selection-type questions value shown user. correct Logical value indicating whether answer() corresponds correct incorrect option. message custom message shown answer selected overall question result matches state answer. example, message correct solution shown entire submission incorrect, shown user picks answer option question correct. label label shown option presented user. fn function used evaluate submitted answer. function called student's submitted value first argument, function take least one argument user's value passed first argument. Inline purrr-style lambda functions allowed, see rlang::as_function() complete details syntax. body function, can perform arbitrary calculations decide submitted answer correct compose message presented user. signal final answer, call mark_as() helper functions correct() incorrect(). return values ignored; e.g. returning NULL may yield submission evaluation answer() answer_fn() options question.","code":""},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/answer.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Question answer options — answer","text":"Returns list \"tutorial_question_answer\" class.","code":""},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/answer.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Question answer options — answer","text":"answer(): Create answer option answer_fn(): Evaluate student's submission determine correctness return feedback.","code":""},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/answer.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Question answer options — answer","text":"","code":"answer(32, correct = FALSE) #> X: \"32\" answer(42, correct = TRUE, message = \"The meaning of life.\") #> ✔: \"42\"; \"The meaning of life.\""},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/available_tutorials.html","id":null,"dir":"Reference","previous_headings":"","what":"List available tutorials — available_tutorials","title":"List available tutorials — available_tutorials","text":"List tutorials currently available via installed R packages. list specific tutorials contained within given R package.","code":""},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/available_tutorials.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"List available tutorials — available_tutorials","text":"","code":"available_tutorials(package = NULL)"},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/available_tutorials.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"List available tutorials — available_tutorials","text":"package Name package","code":""},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/available_tutorials.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"List available tutorials — available_tutorials","text":"available_tutorials() returns data.frame containing \"package\", \"name\", \"title\", \"description\", \"package_dependencies\", \"private\", \"yaml_front_matter\".","code":""},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/available_tutorials.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"List available tutorials — available_tutorials","text":"","code":"available_tutorials(package = \"learnr\") #> Available tutorials: #> * learnr #> - ex-data-basics : \"Data basics\" #> - ex-data-filter : \"Filter observations\" #> - ex-data-mutate : \"Create new variables\" #> - ex-data-summarise : \"Summarise Tables\" #> - ex-setup-r : \"Set Up\" #> - hello : \"Hello, Tutorial!\" #> - polyglot : \"Multi-language exercises\" #> - quiz_question : \"Tutorial Quiz Questions in `learnr`\" #> - setup-chunks : \"Chained setup chunks\" #> - slidy : \"Slidy demo\" #> - sql-exercise : \"Interactive SQL Exercises\""},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/debug_exercise_checker.html","id":null,"dir":"Reference","previous_headings":"","what":"An Exercise Checker for Debugging — debug_exercise_checker","title":"An Exercise Checker for Debugging — debug_exercise_checker","text":"exercise checker debugging renders expected arguments exercise.checker option HTML. Additionally, function used testing evaluate_exercise().","code":""},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/debug_exercise_checker.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"An Exercise Checker for Debugging — debug_exercise_checker","text":"","code":"debug_exercise_checker( label, user_code, solution_code, check_code, envir_result, evaluate_result, envir_prep, last_value, engine, ... )"},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/debug_exercise_checker.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"An Exercise Checker for Debugging — debug_exercise_checker","text":"label Exercise label user_code Submitted user code solution_code code *-solution chunk check_code checking code originates *-check chunk, *-code-check chunk, *-error-check chunk. evaluate_result return value evaluate::evaluate(), called user_code envir_prep, envir_result environment running user code (envir_prep) environment just running user's code (envir_result). last_value last value evaluating user_code engine engine exercise chunk ... used (future compatibility)","code":""},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/debug_exercise_checker.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"An Exercise Checker for Debugging — debug_exercise_checker","text":"Feedback use exercise debugging.","code":""},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/disable_all_tags.html","id":null,"dir":"Reference","previous_headings":"","what":"Disable all html tags — disable_all_tags","title":"Disable all html tags — disable_all_tags","text":"Method disable html tags allow users interact html.","code":""},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/disable_all_tags.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Disable all html tags — disable_all_tags","text":"","code":"disable_all_tags(ele)"},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/disable_all_tags.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Disable all html tags — disable_all_tags","text":"ele html tag element","code":""},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/disable_all_tags.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Disable all html tags — disable_all_tags","text":"htmltools HTML object appended class = \"disabled\" disabled attributes tags.","code":""},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/disable_all_tags.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Disable all html tags — disable_all_tags","text":"","code":"# add an href to all a tags disable_all_tags( htmltools::tagList( htmltools::a(), htmltools::a() ) ) #> <\/a> #> <\/a>"},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/duplicate_env.html","id":null,"dir":"Reference","previous_headings":"","what":"Create a duplicate of an environment — duplicate_env","title":"Create a duplicate of an environment — duplicate_env","text":"Copy items environment new environment. default, new environment share parent environment.","code":""},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/duplicate_env.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create a duplicate of an environment — duplicate_env","text":"","code":"duplicate_env(envir, parent = parent.env(envir))"},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/duplicate_env.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create a duplicate of an environment — duplicate_env","text":"envir environment duplicate parent parent environment set new environment. Defaults parent environment envir.","code":""},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/duplicate_env.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create a duplicate of an environment — duplicate_env","text":"duplicated copy envir whose parent env parent.","code":""},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/duplicate_env.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Create a duplicate of an environment — duplicate_env","text":"","code":"# Make a new environment with the object 'key' envir <- new.env() envir$key <- \"value\" \"key\" %in% ls() # FALSE #> [1] FALSE \"key\" %in% ls(envir = envir) # TRUE #> [1] TRUE # Duplicate the envir and show it contains 'key' new_envir <- duplicate_env(envir) \"key\" %in% ls(envir = new_envir) # TRUE #> [1] TRUE"},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/event_register_handler.html","id":null,"dir":"Reference","previous_headings":"","what":"Register an event handler callback — event_register_handler","title":"Register an event handler callback — event_register_handler","text":"Register event handler per-tutorial basis. Handlers event fired order registered.","code":""},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/event_register_handler.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Register an event handler callback — event_register_handler","text":"","code":"event_register_handler(event, callback)"},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/event_register_handler.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Register an event handler callback — event_register_handler","text":"event name event. callback function invoked event specified name occurs. callback must take parameters session, event, data.","code":""},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/event_register_handler.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Register an event handler callback — event_register_handler","text":"function , invoked, remove callback.","code":""},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/event_register_handler.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Register an event handler callback — event_register_handler","text":"cases, called within learnr document. case, handler exist long document (, Shiny application) running. function called learnr .Rmd document, chunk context=\"server-start\". called context=\"server\", handler registered least two times (application whole, per user session). function called outside learnr document, handler persist learnr package unloaded, typically R session stopped.","code":""},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/external_evaluator.html","id":null,"dir":"Reference","previous_headings":"","what":"External execution evaluator — external_evaluator","title":"External execution evaluator — external_evaluator","text":"Lifecycle: experimental","code":""},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/external_evaluator.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"External execution evaluator — external_evaluator","text":"","code":"external_evaluator( endpoint = getOption(\"tutorial.external.host\", Sys.getenv(\"TUTORIAL_EXTERNAL_EVALUATOR_HOST\", NA)), max_curl_conns = 50 )"},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/external_evaluator.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"External execution evaluator — external_evaluator","text":"endpoint HTTP(S) endpoint POST exercises max_curl_conns maximum number simultaneous HTTP requests endpoint.","code":""},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/external_evaluator.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"External execution evaluator — external_evaluator","text":"function takes expression (expr), timelimit, exercise session.","code":""},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/filesystem_storage.html","id":null,"dir":"Reference","previous_headings":"","what":"Filesystem-based storage for tutor state data — filesystem_storage","title":"Filesystem-based storage for tutor state data — filesystem_storage","text":"Tutorial state storage handler uses filesystem backing store. directory contain tutorial state data partitioned user_id, tutorial_id, tutorial_version (order)","code":""},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/filesystem_storage.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Filesystem-based storage for tutor state data — filesystem_storage","text":"","code":"filesystem_storage(dir, compress = TRUE)"},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/filesystem_storage.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Filesystem-based storage for tutor state data — filesystem_storage","text":"dir Directory store state data within compress .rds files compressed?","code":""},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/filesystem_storage.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Filesystem-based storage for tutor state data — filesystem_storage","text":"Storage handler suitable options(tutorial.storage = ...)","code":""},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/finalize_question.html","id":null,"dir":"Reference","previous_headings":"","what":"Finalize a question — finalize_question","title":"Finalize a question — finalize_question","text":"Mark question finalized adding question-final class HTML output top level, addition disabling tags disable_all_tags().","code":""},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/finalize_question.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Finalize a question — finalize_question","text":"","code":"finalize_question(ele)"},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/finalize_question.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Finalize a question — finalize_question","text":"ele html tag element","code":""},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/finalize_question.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Finalize a question — finalize_question","text":"htmltools HTML object appropriately appended classes tutorial question marked final answer.","code":""},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/finalize_question.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Finalize a question — finalize_question","text":"","code":"# finalize the question UI finalize_question( htmltools::div( class = \"custom-question\", htmltools::div(\"answer 1\"), htmltools::div(\"answer 2\") ) ) #> #> answer 1<\/div> #> answer 2<\/div> #> <\/div>"},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/format_quiz.html","id":null,"dir":"Reference","previous_headings":"","what":"Formatting and printing quizzes, questions, and answers — format.tutorial_question_answer","title":"Formatting and printing quizzes, questions, and answers — format.tutorial_question_answer","text":"Notes: custom question types created, custom s3 formating methods may implemented well. Due shiny runtime questions, text representation quizzes, questions, answers presented.","code":""},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/format_quiz.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Formatting and printing quizzes, questions, and answers — format.tutorial_question_answer","text":"","code":"# S3 method for tutorial_question_answer format(x, ..., spacing = \"\") # S3 method for tutorial_question format(x, ..., spacing = \"\") # S3 method for tutorial_quiz format(x, ...) # S3 method for tutorial_question print(x, ...) # S3 method for tutorial_question_answer print(x, ...) # S3 method for tutorial_quiz print(x, ...)"},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/format_quiz.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Formatting and printing quizzes, questions, and answers — format.tutorial_question_answer","text":"x object interest ... ignored spacing Text placed beginning new line","code":""},{"path":[]},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/format_quiz.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Formatting and printing quizzes, questions, and answers — format.tutorial_question_answer","text":"","code":"ex_question <- question(\"What number is the letter A in the alphabet?\", answer(\"8\"), answer(\"14\"), answer(\"1\", correct = TRUE), answer(\"23\"), incorrect = \"See [here](https://en.wikipedia.org/wiki/English_alphabet) and try again.\", allow_retry = TRUE ) cat(format(ex_question), \"\\n\") #> Question: \"What number is the letter A in the alphabet?\" #> type: \"learnr_radio\" #> allow_retry: TRUE #> random_answer_order: FALSE #> answers: #> X: \"8\" #> X: \"14\" #> ✔: \"1\" #> X: \"23\" #> messages: #> correct: \"Correct!\" #> incorrect: \"See here<\/a> and try again.\" #> try_again: \"See here<\/a> and try again.\""},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/get_tutorial_info.html","id":null,"dir":"Reference","previous_headings":"","what":"Get information about the current tutorial — get_tutorial_info","title":"Get information about the current tutorial — get_tutorial_info","text":"Returns information current tutorial. Ideally function evaluated Shiny context, .e. chunk option context = \"server\". Note values function may change tutorial completely initialized. called non-reactive context, get_tutorial_info() return default values likely correspond current tutorial.","code":""},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/get_tutorial_info.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get information about the current tutorial — get_tutorial_info","text":"","code":"get_tutorial_info( tutorial_path = NULL, session = getDefaultReactiveDomain(), ..., encoding = \"UTF-8\" )"},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/get_tutorial_info.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get information about the current tutorial — get_tutorial_info","text":"tutorial_path Path tutorial .Rmd source file session session object passed function given shinyServer. Default shiny::getDefaultReactiveDomain(). ... Arguments passed rmarkdown::render output_format R Markdown output format convert . option \"\" render formats defined within file. option can name format (e.g. \"html_document\") render document single format. One can also use vector format names render multiple formats. Alternatively, can pass output format object (e.g. html_document()). using NULL output format first one defined YAML frontmatter input file (defaults HTML format specified ). pass output format object output_format, options specified YAML header _output.yml ignored must explicitly set options want construct object. pass string, output format use output parameters YAML header _output.yml. output_dir output directory rendered output_file. allows choice alternate directory output file written (default output directory input file). path provided filename output_file directory specified take precedence. Please note directory path provided create necessary directories exist. output_options List output options can override options specified metadata (e.g. used force self_contained mathjax = \"local\"). Note valid output format read metadata (.e. custom format object passed output_format). output_yaml Paths YAML files specifying output formats configurations. first existing one used. none found, function searches YAML files specified output_yaml top-level parameter YAML front matter, _output.yml _output.yaml, uses first existing one. intermediates_dir Intermediate files directory. path specified intermediate files written path. NULL, intermediate files written directory input file. knit_root_dir working directory knit document; uses knitr's root.dir knit option. NULL behavior follow knitr default, use parent directory document. runtime runtime target rendering. static option produces output intended static files; shiny produces output suitable use Shiny document (see run). default, auto, allows runtime target specified YAML metadata take precedence, renders static runtime target otherwise. clean Using TRUE clean intermediate files created rendering. params list named parameters override custom params specified within YAML front-matter (e.g. specifying dataset read date range confine output ). Pass \"ask\" start application helps guide parameter configuration. knit_meta (option reserved expert use.) Metadata generated knitr. envir environment code chunks evaluated knitting (can use new.env() guarantee empty new environment). run_pandoc option whether run pandoc convert Markdown output. quiet option suppress printing rendering knitr, pandoc command line others. suppress printing last \"Output created: \" message, can set rmarkdown.render.message FALSE encoding Ignored. encoding always assumed UTF-8.","code":""},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/get_tutorial_info.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get information about the current tutorial — get_tutorial_info","text":"Returns ordinary list following elements: tutorial_id: ID tutorial, auto-generated tutorial$id key tutorial's YAML front matter. tutorial_version: tutorial's version, auto-generated tutorial$version key tutorial's YAML front matter. items: data frame columns order, label, type data describing items (questions exercises) tutorial. item available running tutorial, static pre-render step. user_id: current user. learnr_version: current version running learnr package. language: current language tutorial, either chosen user specified language item YAML front matter.","code":""},{"path":[]},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/get_tutorial_info.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get information about the current tutorial — get_tutorial_info","text":"","code":"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 } #> $tutorial_id #> [1] \"/tmp/RtmpiRGplN\" #> #> $tutorial_version #> [1] \"1.0\" #> #> $items #> # A tibble: 1 × 4 #> order label type data #> #> 1 1 addition exercise #> #> $user_id #> [1] \"runner\" #> #> $learnr_version #> [1] \"0.11.4.9000\" #> #> $language #> [1] \"en\" #>"},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/get_tutorial_state.html","id":null,"dir":"Reference","previous_headings":"","what":"Observe the user's progress in the tutorial — get_tutorial_state","title":"Observe the user's progress in the tutorial — get_tutorial_state","text":"student progresses learnr tutorial, progress stored Shiny reactive values list session (see shiny::reactiveValues()). Without arguments, get_tutorial_state() returns full reactiveValues object can converted conventional list shiny::reactiveValuesToList(). label argument provided, state individual question exercise label returned. Calling get_tutorial_state() introduces reactive dependency state returned questions exercises unless called within isolate(). Note get_tutorial_state() work tutorial author must used reactive context, .e. within shiny::observe(), shiny::observeEvent(), shiny::reactive(). logic observing user's tutorial state must written inside context=\"server\" chunk tutorial's R Markdown source.","code":""},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/get_tutorial_state.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Observe the user's progress in the tutorial — get_tutorial_state","text":"","code":"get_tutorial_state(label = NULL, session = getDefaultReactiveDomain())"},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/get_tutorial_state.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Observe the user's progress in the tutorial — get_tutorial_state","text":"label length-1 character label exercise question. session session object passed function given shinyServer. Default shiny::getDefaultReactiveDomain().","code":""},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/get_tutorial_state.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Observe the user's progress in the tutorial — get_tutorial_state","text":"reactiveValues object single reactive value (label provided). names full reactiveValues object correspond label question exercise. item contains following entries: type: One \"question\" \"exercise\". answer: character vector containing user's submitted answer(s). correct: logical indicating whether user's answer correct, logical NA submission checked correctness. timestamp: time user's submission completed, character string UTC, formatted \"%F %H:%M:%OS3 %Z\".","code":""},{"path":[]},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/initialize_tutorial.html","id":null,"dir":"Reference","previous_headings":"","what":"Initialize tutorial R Markdown extensions — initialize_tutorial","title":"Initialize tutorial R Markdown extensions — initialize_tutorial","text":"One time initialization R Markdown extensions required learnr package. function typically called automatically result using exercises questions.","code":""},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/initialize_tutorial.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Initialize tutorial R Markdown extensions — initialize_tutorial","text":"","code":"initialize_tutorial()"},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/initialize_tutorial.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Initialize tutorial R Markdown extensions — initialize_tutorial","text":"previously run, initializes knitr hooks provides required rmarkdown::shiny_prerendered_chunk()s initialize learnr.","code":""},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/knit_print.html","id":null,"dir":"Reference","previous_headings":"","what":"Knitr quiz print methods — knit_print.tutorial_question","title":"Knitr quiz print methods — knit_print.tutorial_question","text":"knitr::knit_print methods question quiz","code":""},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/knit_print.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Knitr quiz print methods — knit_print.tutorial_question","text":"","code":"# S3 method for tutorial_question knit_print(x, ...) # S3 method for tutorial_quiz knit_print(x, ...)"},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/knit_print.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Knitr quiz print methods — knit_print.tutorial_question","text":"x R object printed ... Additional arguments passed S3 method. Currently ignored, except two optional arguments options inline; see references .","code":""},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/learnr-package.html","id":null,"dir":"Reference","previous_headings":"","what":"learnr: Interactive Tutorials for R — learnr-package","title":"learnr: Interactive Tutorials for R — learnr-package","text":"Create interactive tutorials using R Markdown. Use combination narrative, figures, videos, exercises, quizzes create self-paced tutorials learning R R packages.","code":""},{"path":[]},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/learnr-package.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"learnr: Interactive Tutorials for R — learnr-package","text":"Maintainer: Garrick Aden-Buie garrick@posit.co (ORCID) Authors: Barret Schloerke barret@posit.co (ORCID) JJ Allaire jj@posit.co [conceptor] Alexander Rossell Hayes alex.rossellhayes@posit.co (ORCID) contributors: Nischal Shrestha nischal@posit.co (ORCID) [contributor] Angela Li angelali921@gmail.com (vignette) [contributor] Posit, PBC [copyright holder, funder] Ajax.org B.V. (Ace library) [contributor, copyright holder] Zeno Rocha (clipboard.js library) [contributor, copyright holder] Nick Payne (Bootbox library) [contributor, copyright holder] Jake Archibald (idb-keyval library) [contributor, copyright holder] i18next authors (i18next library) [contributor, copyright holder]","code":""},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/mark_as_correct_incorrect.html","id":null,"dir":"Reference","previous_headings":"","what":"Mark submission as correct or incorrect — correct","title":"Mark submission as correct or incorrect — correct","text":"Helper method communicate user's submission correct incorrect. functions originally designed developers create question_is_correct() methods custom question types, can also called inside functions created answer_fn() dynamically determine result message provided user.","code":""},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/mark_as_correct_incorrect.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Mark submission as correct or incorrect — correct","text":"","code":"correct(messages = NULL) incorrect(messages = NULL) mark_as(correct, messages = NULL)"},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/mark_as_correct_incorrect.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Mark submission as correct or incorrect — correct","text":"messages vector messages displayed. type message determined correct value. Note markdown messages rendered HTML, may provide HTML using htmltools::HTML() htmltools::tags. correct Logical: question answer correct","code":""},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/mark_as_correct_incorrect.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Mark submission as correct or incorrect — correct","text":"Returns list class learnr_mark_as returned question_is_correct() method learnr question type.","code":""},{"path":[]},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/mark_as_correct_incorrect.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Mark submission as correct or incorrect — correct","text":"","code":"# Radio button question implementation of `question_is_correct` question_is_correct.radio <- function(question, value, ...) { for (ans in question$answers) { if (as.character(ans$option) == value) { return(mark_as(ans$correct, ans$message)) } } mark_as(FALSE, NULL) }"},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/mock_exercise.html","id":null,"dir":"Reference","previous_headings":"","what":"Mock a learnr interactive exercise — mock_exercise","title":"Mock a learnr interactive exercise — mock_exercise","text":"Creates interactive exercise object can used tests without create learnr tutorial.","code":""},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/mock_exercise.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Mock a learnr interactive exercise — mock_exercise","text":"","code":"mock_exercise( user_code = \"1 + 1\", label = \"ex\", chunks = list(), engine = \"r\", global_setup = NULL, setup_label = NULL, solution_code = NULL, code_check = NULL, error_check = NULL, check = NULL, tests = NULL, exercise.checker = NULL, exercise.error.check.code = NULL, exercise.df_print = \"default\", exercise.warn_invisible = TRUE, exercise.timelimit = 10, fig.height = 4, fig.width = 6.5, fig.retina = 2, version = current_exercise_version, ... ) mock_chunk(label, code, exercise = FALSE, engine = \"r\", ...)"},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/mock_exercise.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Mock a learnr interactive exercise — mock_exercise","text":"user_code, solution_code, global_setup user, solution, global setup code, strings. label label exercise. chunks list chunks use exercise. Use mock_chunk() create chunks. engine knitr language engine used exercise, equivalent engine used chunk exercise = TRUE tutorial. setup_label label chunk contains setup code. chunk among list chunks provided chunks argument label setup chunk needs match label provided setup_label. check, code_check, error_check checking code, string, typically provided -check, -code-check -error-check chunks learnr tutorial. exercise.checker exercise checker function, string. default, debug exercise checker set used check, code_check error_check provided. exercise.error.check.code default code used error_check applied check code_check provided user's code throws error. exercise.df_print, exercise.warn_invisible, exercise.timelimit, fig.height, fig.width, fig.retina Common exercise chunk options. version exercise version emulate, default mock_exercise() return exercise matches current exercise version. ... Additional chunk options included exercise chunk. code mock_chunk(), code mocked chunk. exercise mock_chunk(), chunk exercise chunk? , mock_exercise() create exercise chunk .","code":""},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/mock_exercise.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Mock a learnr interactive exercise — mock_exercise","text":"exercise object.","code":""},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/mock_exercise.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Mock a learnr interactive exercise — mock_exercise","text":"mock_exercise(): Create learnr exercise object mock_chunk(): Create mock exercise-supporting chunk","code":""},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/mock_exercise.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Mock a learnr interactive exercise — mock_exercise","text":"","code":"mock_exercise( user_code = \"1 + 1\", solution_code = \"2 + 2\", label = \"two-plus-two\" ) #> ```{r \"two-plus-two\", exercise=TRUE} #> 1 + 1 #> ``` #> #> ```{r \"two-plus-two-solution\"} #> 2 + 2 #> ``` # Global Setup mock_exercise( user_code = 'storms %>% filter(name = \"Roxanne\")', solution_code = 'storms %>% filter(name == \"Roxanne\")', global_setup = 'library(learnr)\\nlibrary(dplyr)', label = \"filter-storms\" ) #> ```{r \"filter-storms\", exercise=TRUE} #> storms %>% filter(name = \"Roxanne\") #> ``` #> #> ```{r \"filter-storms-solution\"} #> storms %>% filter(name == \"Roxanne\") #> ``` # Chained setup chunks mock_exercise( user_code = \"roxanne\", solution_code = \"roxanne %>% group_by(year, month, day) %>% summarize(wind = mean(wind))\", chunks = list( mock_chunk( label = \"prep-roxanne\", code = 'roxanne <- storms %>% filter(name == \"Roxanne\")' ) ), setup_label = \"prep-roxanne\", global_setup = \"library(learnr)\\nlibrary(dplyr)\" ) #> ```{r \"prep-roxanne\"} #> roxanne <- storms %>% filter(name == \"Roxanne\") #> ``` #> #> ```{r \"ex\", exercise.setup=\"prep-roxanne\", exercise=TRUE} #> roxanne #> ``` #> #> ```{r \"ex-solution\"} #> roxanne %>% #> group_by(year, month, day) %>% #> summarize(wind = mean(wind)) #> ```"},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/one_time.html","id":null,"dir":"Reference","previous_headings":"","what":"Wrap an expression that will be executed one time in an event handler — one_time","title":"Wrap an expression that will be executed one time in an event handler — one_time","text":"wraps expression executed one time tutorial, based condition. first time condition true, expression executed; , expression evaluated . execution state stored expression executed, user quits tutorial returns , expression executed second time. common use one_time execute expression section viewed first time.","code":""},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/one_time.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Wrap an expression that will be executed one time in an event handler — one_time","text":"","code":"one_time(session, cond, expr, label = deparse(substitute(cond)))"},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/one_time.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Wrap an expression that will be executed one time in an event handler — one_time","text":"session Shiny session object. cond condition used filter. first time condition evaluates true, expr evaluated; , expr evaluated . expr expression evaluated , first time cond true. label unique identifier. used ID condition expression; two calls one_time() uses label, ID collision one execute. default, cond deparsed used label.","code":""},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/one_time.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Wrap an expression that will be executed one time in an event handler — one_time","text":"result evaluating expr (one_time() intended called within event handler).","code":""},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/one_time.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Wrap an expression that will be executed one time in an event handler — one_time","text":"","code":"if (FALSE) { # This goes in a {r context=\"server-start\"} chunk # The expression with message() will be executed the first time the user # sees the section with ID \"section-exercise-with-hint\". event_register_handler(\"section_viewed\", function(session, event, data) { one_time( session, data$sectionId == \"section-exercise-with-hint\", { message(\"Seeing \", data$sectionId, \" for the first time.\") } ) } ) }"},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/question_checkbox.html","id":null,"dir":"Reference","previous_headings":"","what":"Checkbox question — question_checkbox","title":"Checkbox question — question_checkbox","text":"Creates checkbox group tutorial quiz question. student may select one checkboxes submitting answer.","code":""},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/question_checkbox.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Checkbox question — question_checkbox","text":"","code":"question_checkbox( text, ..., correct = \"Correct!\", incorrect = \"Incorrect\", try_again = \"Incorrect. Be sure to select every correct answer.\", allow_retry = FALSE, random_answer_order = FALSE )"},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/question_checkbox.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Checkbox question — question_checkbox","text":"text Question option text ... Answers created answer() answer_fn(), extra parameters passed onto question(). Function answers appear checklist, checked first order specified. correct question, text print correct answer (defaults \"Correct!\"). answer, boolean indicating whether answer correct. incorrect Text print incorrect answer (defaults \"Incorrect\") allow_retry FALSE. try_again Text print incorrect answer (defaults \"Incorrect. sure select every correct answer.\") allow_retry TRUE. allow_retry Allow retry incorrect answers. Defaults FALSE. random_answer_order Display answers random order.","code":""},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/question_checkbox.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Checkbox question — question_checkbox","text":"Returns learnr question type \"learnr_checkbox\".","code":""},{"path":[]},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/question_checkbox.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Checkbox question — question_checkbox","text":"","code":"question_checkbox( \"Select all the toppings that belong on a Margherita Pizza:\", answer(\"tomato\", correct = TRUE), answer(\"mozzarella\", correct = TRUE), answer(\"basil\", correct = TRUE), answer(\"extra virgin olive oil\", correct = TRUE), answer(\"pepperoni\", message = \"Great topping! ... just not on a Margherita Pizza\"), answer(\"onions\"), answer(\"bacon\"), answer(\"spinach\"), random_answer_order = TRUE, allow_retry = TRUE, try_again = \"Be sure to select all four toppings!\" ) #> Question: \"Select all the toppings that belong on a Margherita Pizza:\" #> type: \"learnr_checkbox\" #> allow_retry: TRUE #> random_answer_order: TRUE #> answers: #> ✔: \"tomato\" #> ✔: \"mozzarella\" #> ✔: \"basil\" #> ✔: \"extra virgin olive oil\" #> X: \"pepperoni\"; \"Great topping! … just not on a Margherita Pizza\" #> X: \"onions\" #> X: \"bacon\" #> X: \"spinach\" #> messages: #> correct: \"Correct!\" #> incorrect: \"Incorrect\" #> try_again: \"Be sure to select all four toppings!\" # Set up a question where there's no wrong answer. The answer options are # always shuffled, but the answer_fn() answer is always evaluated first. question_checkbox( \"Which of the tidyverse packages is your favorite?\", answer(\"dplyr\"), answer(\"tidyr\"), answer(\"ggplot2\"), answer(\"tibble\"), answer(\"purrr\"), answer(\"stringr\"), answer(\"forcats\"), answer(\"readr\"), answer_fn(function(value) { if (length(value) == 1) { correct(paste(value, \"is my favorite tidyverse package, too!\")) } else { correct(\"Yeah, I can't pick just one favorite package either.\") } }), random_answer_order = TRUE ) #> Question: \"Which of the tidyverse packages is your favorite?\" #> type: \"learnr_checkbox\" #> allow_retry: FALSE #> random_answer_order: TRUE #> answers: #> X: \"dplyr\" #> X: \"tidyr\" #> X: \"ggplot2\" #> X: \"tibble\" #> X: \"purrr\" #> X: \"stringr\" #> X: \"forcats\" #> X: \"readr\" #> ?: \"\" #> messages: #> correct: \"Correct!\" #> incorrect: \"Incorrect\""},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/question_methods.html","id":null,"dir":"Reference","previous_headings":"","what":"Custom question methods — question_ui_initialize","title":"Custom question methods — question_ui_initialize","text":"five methods used define custom question. S3 method correspond type = TYPE supplied question. question_ui_initialize.TYPE(question, value, ...) Determines question initially displayed users. return shiny UI object can displayed using shiny::renderUI. example, case question_ui_initialize.radio, returns shiny::radioButtons object. method re-executed question attempted . question_ui_completed.TYPE(question, ...) Determines question displayed submission. Just like question_ui_initialize, method return shiny UI object can displayed using shiny::renderUI. question_is_valid.TYPE(question, value, ...) method return boolean determines input answer valid. Depending value, function enables disables submission button. question_is_correct.TYPE(question, value, ...) function return output correct, incorrect, mark_as. method allows custom messages addition determination answer correct. See correct, incorrect, mark_as details. question_ui_try_again <- function(question, value, ...) Determines question displayed users \"Try \" screen displayed. Usually function disable inputs question, .e. prevent student changing answer options. Similar question_ui_initialize, return shiny UI object can displayed using shiny::renderUI.","code":""},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/question_methods.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Custom question methods — question_ui_initialize","text":"","code":"question_ui_initialize(question, value, ...) question_ui_try_again(question, value, ...) question_ui_completed(question, value, ...) question_is_valid(question, value, ...) question_is_correct(question, value, ...) # S3 method for default question_ui_initialize(question, value, ...) # S3 method for default question_ui_try_again(question, value, ...) # S3 method for default question_ui_completed(question, value, ...) # S3 method for default question_is_valid(question, value, ...) # S3 method for default question_is_correct(question, value, ...)"},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/question_methods.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Custom question methods — question_ui_initialize","text":"question question object used value user input value ... future parameter expansion custom arguments used dispatched s3 methods.","code":""},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/question_methods.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Custom question methods — question_ui_initialize","text":"learnr question objects, UI elements, results server methods.","code":""},{"path":[]},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/question_methods.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Custom question methods — question_ui_initialize","text":"","code":"q <- question( \"Which package helps you teach programming skills?\", answer(\"dplyr\"), answer(\"learnr\", correct = TRUE), answer(\"base\") ) question_is_correct(q, \"dplyr\") #> $correct #> [1] FALSE #> #> $messages #> NULL #> #> attr(,\"class\") #> [1] \"learnr_mark_as\" question_is_correct(q, \"learnr\") #> $correct #> [1] TRUE #> #> $messages #> NULL #> #> attr(,\"class\") #> [1] \"learnr_mark_as\""},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/question_numeric.html","id":null,"dir":"Reference","previous_headings":"","what":"Number question — question_numeric","title":"Number question — question_numeric","text":"Creates tutorial question asking student submit number.","code":""},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/question_numeric.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Number question — question_numeric","text":"","code":"question_numeric( text, ..., correct = \"Correct!\", incorrect = \"Incorrect\", try_again = incorrect, allow_retry = FALSE, value = NULL, min = NA, max = NA, step = NA, options = list(), tolerance = 1.5e-08 )"},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/question_numeric.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Number question — question_numeric","text":"text Question option text ... Answers created answer() answer_fn(), extra parameters passed onto question(). correct question, text print correct answer (defaults \"Correct!\"). answer, boolean indicating whether answer correct. incorrect Text print incorrect answer (defaults \"Incorrect\") allow_retry FALSE. try_again Text print incorrect answer (defaults \"Incorrect\") allow_retry TRUE. allow_retry Allow retry incorrect answers. Defaults FALSE. value Initial value. min Minimum allowed value max Maximum allowed value step Interval use stepping min max options Extra options stored question object. useful using custom question types. See sortable::question_rank() example question implementation uses options parameter. tolerance Submitted values within absolute difference less equal tolerance considered equal answer value. Note tolerance answer() values. specific answer value grading, use answer_fn() provide evaluation code.","code":""},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/question_numeric.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Number question — question_numeric","text":"Returns learnr question type \"learnr_numeric\".","code":""},{"path":[]},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/question_numeric.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Number question — question_numeric","text":"","code":"question_numeric( \"What is pi rounded to 2 digits?\", answer(3, message = \"Don't forget to use the digits argument\"), answer(3.1, message = \"Too few digits\"), answer(3.142, message = \"Too many digits\"), answer(3.14, correct = TRUE), allow_retry = TRUE, min = 3, max = 4, step = 0.01 ) #> Question: \"What is pi rounded to 2 digits?\" #> type: \"learnr_numeric\" #> allow_retry: TRUE #> random_answer_order: FALSE #> answers: #> X: \"3\"; \"Don’t forget to use the digits argument\" #> X: \"3.1\"; \"Too few digits\" #> X: \"3.142\"; \"Too many digits\" #> ✔: \"3.14\" #> messages: #> correct: \"Correct!\" #> incorrect: \"Incorrect\" #> try_again: \"Incorrect\" #> Options: #> min: 3 #> max: 4 #> step: 0.01 #> tolerance: 1.5e-08 question_numeric( \"Can you think of an even number?\", answer_fn(function(value) { if (value %% 2 == 0) { correct(\"even\") } else if (value %% 2 == 1) { incorrect(\"odd\") } }, label = \"Is the number even?\"), step = 1 ) #> Question: \"Can you think of an even number?\" #> type: \"learnr_numeric\" #> allow_retry: FALSE #> random_answer_order: FALSE #> answers: #> ?: \"Is the number even?\" #> messages: #> correct: \"Correct!\" #> incorrect: \"Incorrect\" #> Options: #> min: NA #> max: NA #> step: 1 #> tolerance: 1.5e-08"},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/question_radio.html","id":null,"dir":"Reference","previous_headings":"","what":"Radio question — question_radio","title":"Radio question — question_radio","text":"Creates radio button tutorial quiz question. student can select one radio button submitting answer. Note: Multiple correct answers allowed.","code":""},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/question_radio.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Radio question — question_radio","text":"","code":"question_radio( text, ..., correct = \"Correct!\", incorrect = \"Incorrect\", try_again = incorrect, allow_retry = FALSE, random_answer_order = FALSE )"},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/question_radio.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Radio question — question_radio","text":"text Question option text ... Answers created answer() extra parameters passed onto question(). Function answers ignored radio questions user required select single answer. correct question, text print correct answer (defaults \"Correct!\"). answer, boolean indicating whether answer correct. incorrect Text print incorrect answer (defaults \"Incorrect\") allow_retry FALSE. try_again Text print incorrect answer (defaults \"Incorrect\") allow_retry TRUE. allow_retry Allow retry incorrect answers. Defaults FALSE. random_answer_order Display answers random order.","code":""},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/question_radio.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Radio question — question_radio","text":"Returns learnr question type \"learnr_radio\".","code":""},{"path":[]},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/question_radio.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Radio question — question_radio","text":"","code":"question_radio( \"Pick the letter B\", answer(\"A\"), answer(\"B\", correct = TRUE), answer(\"C\"), answer(\"D\"), allow_retry = TRUE, random_answer_order = TRUE ) #> Question: \"Pick the letter B\" #> type: \"learnr_radio\" #> allow_retry: TRUE #> random_answer_order: TRUE #> answers: #> X: \"A\" #> ✔: \"B\" #> X: \"C\" #> X: \"D\" #> messages: #> correct: \"Correct!\" #> incorrect: \"Incorrect\" #> try_again: \"Incorrect\""},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/question_text.html","id":null,"dir":"Reference","previous_headings":"","what":"Text box question — question_text","title":"Text box question — question_text","text":"Creates tutorial question asking student enter text. default text input appropriate short single-line text entry. longer text input, set rows /cols argument create larger text area. used answer(), student's submission must match answer exactly, minus whitespace trimming enabled trim = TRUE. complicated submission evaluation, use answer_fn() provide function checks student's submission. example, provide function evaluates user's submission using regular expressions.","code":""},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/question_text.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Text box question — question_text","text":"","code":"question_text( text, ..., correct = \"Correct!\", incorrect = \"Incorrect\", try_again = incorrect, allow_retry = FALSE, random_answer_order = FALSE, placeholder = \"Enter answer here...\", trim = TRUE, rows = NULL, cols = NULL, options = list() )"},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/question_text.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Text box question — question_text","text":"text Question option text ... Answers created answer() answer_fn(), extra parameters passed onto question(). Answers custom function checking correct question, text print correct answer (defaults \"Correct!\"). answer, boolean indicating whether answer correct. incorrect Text print incorrect answer (defaults \"Incorrect\") allow_retry FALSE. try_again Text print incorrect answer (defaults \"Incorrect\") allow_retry TRUE. allow_retry Allow retry incorrect answers. Defaults FALSE. random_answer_order Random answer order text questions automatically disabled ensure submission checked answer order provided author. placeholder character string giving user hint can entered control. Internet Explorer 8 9 support option. trim Logical determine whitespace answer removed. Defaults TRUE. rows, cols Defines size text input area terms number rows character columns visible user. either rows cols provided, quiz input use shiny::textAreaInput() text input, otherwise default input element single-line shiny::textInput(). options Extra options stored question object. useful using custom question types. See sortable::question_rank() example question implementation uses options parameter.","code":""},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/question_text.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Text box question — question_text","text":"Returns learnr question type \"learnr_text\".","code":""},{"path":[]},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/question_text.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Text box question — question_text","text":"","code":"question_text( \"Please enter the word 'C0rrect' below:\", answer(\"correct\", message = \"Don't forget to capitalize\"), answer(\"c0rrect\", message = \"Don't forget to capitalize\"), answer(\"Correct\", message = \"Is it really an 'o'?\"), answer(\"C0rrect \", message = \"Make sure you do not have a trailing space\"), answer(\"C0rrect\", correct = TRUE), allow_retry = TRUE, trim = FALSE ) #> Question: \"Please enter the word ‘C0rrect’ below:\" #> type: \"learnr_text\" #> allow_retry: TRUE #> random_answer_order: FALSE #> answers: #> X: \"correct\"; \"Don’t forget to capitalize\" #> X: \"c0rrect\"; \"Don’t forget to capitalize\" #> X: \"Correct\"; \"Is it really an ‘o’?\" #> X: \"C0rrect\"; \"Make sure you do not have a trailing space\" #> ✔: \"C0rrect\" #> messages: #> correct: \"Correct!\" #> incorrect: \"Incorrect\" #> try_again: \"Incorrect\" #> Options: #> placeholder: \"Enter answer here...\" #> trim: FALSE # This question uses an answer_fn() to give a hint when we think the # student is on the right track but hasn't found the value yet. question_text( \"What's the most popular programming interview question?\", answer(\"fizz buzz\", correct = TRUE, \"That's right!\"), answer_fn(function(value) { if (grepl(\"(fi|bu)zz\", value)) { incorrect(\"You're on the right track!\") } }, label = \"fizz or buzz\") ) #> Question: \"What’s the most popular programming interview question?\" #> type: \"learnr_text\" #> allow_retry: FALSE #> random_answer_order: FALSE #> answers: #> ✔: \"fizz buzz\"; \"That’s right!\" #> ?: \"fizz or buzz\" #> messages: #> correct: \"Correct!\" #> incorrect: \"Incorrect\" #> Options: #> placeholder: \"Enter answer here...\" #> trim: TRUE"},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/quiz.html","id":null,"dir":"Reference","previous_headings":"","what":"Tutorial quiz questions — quiz","title":"Tutorial quiz questions — quiz","text":"Add interactive quiz questions tutorial. quiz question executed within shiny runtime provide flexibility types questions offered. four default types quiz questions: learnr_radio Radio button question. question type allow single answer submission user. answer must marked user submit answer. learnr_checkbox Check box question. question type allow one answers submitted user. least one answer must marked user submit answer. learnr_text Text box question. question type allow free form text submitted user. least one non-whitespace character must added user submit answer. learnr_numeric Numeric question. question type allow number submitted user. least one number must added user submit answer. Note, print behavior changed runtime now Shiny based. questions quizes printed console, S3 structure information displayed.","code":""},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/quiz.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Tutorial quiz questions — quiz","text":"","code":"quiz(..., caption = rlang::missing_arg()) question( text, ..., type = c(\"auto\", \"single\", \"multiple\", \"learnr_radio\", \"learnr_checkbox\", \"learnr_text\", \"learnr_numeric\"), correct = \"Correct!\", incorrect = \"Incorrect\", try_again = NULL, message = NULL, post_message = NULL, loading = NULL, submit_button = rlang::missing_arg(), try_again_button = rlang::missing_arg(), allow_retry = FALSE, random_answer_order = FALSE, options = list() )"},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/quiz.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Tutorial quiz questions — quiz","text":"... One questions answers caption Optional quiz caption (defaults \"Quiz\") text Question option text type Type quiz question. Typically can automatically determined based provided answers. Pass \"radio\" indicate even though multiple correct answers specified inputs include one correct answer still correct. Pass \"checkbox\" force use checkboxes (opposed radio buttons) even though one correct answer provided. correct question, text print correct answer (defaults \"Correct!\"). answer, boolean indicating whether answer correct. incorrect Text print incorrect answer (defaults \"Incorrect\") allow_retry FALSE. try_again Text print incorrect answer allow_retry TRUE. Defaults \"Incorrect. sure select every correct answer.\" checkbox questions \"Incorrect\" non-checkbox questions. message Additional message display along correct/incorrect feedback. message always displayed question submission. post_message Additional message display along correct/incorrect feedback. allow_retry TRUE, message displayed correct submission. allow_retry FALSE, produce second message alongside message message value. loading Loading text display placeholder question loaded. provided, generic \"Loading...\" placeholder elements displayed. submit_button Label submit button. Defaults \"Submit Answer\" try_again_button Label try button. Defaults \"Submit Answer\" allow_retry Allow retry incorrect answers. Defaults FALSE. random_answer_order Display answers random order. options Extra options stored question object. useful using custom question types. See sortable::question_rank() example question implementation uses options parameter.","code":""},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/quiz.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Tutorial quiz questions — quiz","text":"learnr quiz, collection questions.","code":""},{"path":[]},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/quiz.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Tutorial quiz questions — quiz","text":"","code":"quiz( question(\"What number is the letter A in the alphabet?\", answer(\"8\"), answer(\"14\"), answer(\"1\", correct = TRUE), answer(\"23\"), incorrect = \"See [here](https://en.wikipedia.org/wiki/English_alphabet) and try again.\", allow_retry = TRUE ), question(\"Where are you right now? (select ALL that apply)\", answer(\"Planet Earth\", correct = TRUE), answer(\"Pluto\"), answer(\"At a computing device\", correct = TRUE), answer(\"In the Milky Way\", correct = TRUE), incorrect = paste0(\"Incorrect. You're on Earth, \", \"in the Milky Way, at a computer.\") ) ) #> Quiz: \"Quiz<\/span>\" #> #> Question: \"What number is the letter A in the alphabet?\" #> type: \"learnr_radio\" #> allow_retry: TRUE #> random_answer_order: FALSE #> answers: #> X: \"8\" #> X: \"14\" #> ✔: \"1\" #> X: \"23\" #> messages: #> correct: \"Correct!\" #> incorrect: \"See here<\/a> and try again.\" #> try_again: \"See here<\/a> and try again.\" #> #> Question: \"Where are you right now? (select ALL that apply)\" #> type: \"learnr_checkbox\" #> allow_retry: FALSE #> random_answer_order: FALSE #> answers: #> ✔: \"Planet Earth\" #> X: \"Pluto\" #> ✔: \"At a computing device\" #> ✔: \"In the Milky Way\" #> messages: #> correct: \"Correct!\" #> incorrect: \"Incorrect. You’re on Earth, in the Milky Way, at a computer.\""},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/random_phrases_add.html","id":null,"dir":"Reference","previous_headings":"","what":"Add phrases to the bank of random phrases — random_phrases_add","title":"Add phrases to the bank of random phrases — random_phrases_add","text":"Augment random phrases available random_praise() random_encouragement() phrases . Note phrases added existing phrases, rather overwriting .","code":""},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/random_phrases_add.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add phrases to the bank of random phrases — random_phrases_add","text":"","code":"random_phrases_add(language = \"en\", praise = NULL, encouragement = NULL)"},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/random_phrases_add.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add phrases to the bank of random phrases — random_phrases_add","text":"language language phrases added. praise, encouragement vector praising encouraging phrases, including final punctuation.","code":""},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/random_phrases_add.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add phrases to the bank of random phrases — random_phrases_add","text":"Returns previous custom phrases invisibly called global setup chunk interactively. Otherwise, returns shiny pre- rendered chunk.","code":""},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/random_phrases_add.html","id":"usage-in-learnr-tutorials","dir":"Reference","previous_headings":"","what":"Usage in learnr tutorials","title":"Add phrases to the bank of random phrases — random_phrases_add","text":"add random phrases learnr tutorial, can either include one calls random_phrases_add() global setup chunk: Alternatively, can call random_phrases_add() separate, standard R chunk (echo = FALSE):","code":"```{r setup, include = FALSE}`r ''` library(learnr) random_phrases_add( language = \"en\", praise = \"Great work!\", encouragement = \"I believe in you.\" ) ``` ```{r setup-phrases, echo = FALSE}`r ''` random_phrases_add( language = \"en\", praise = c(\"Great work!\", \"You're awesome!\"), encouragement = c(\"I believe in you.\", \"Yes we can!\") ) ```"},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/random_phrases_add.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add phrases to the bank of random phrases — random_phrases_add","text":"","code":"random_phrases_add(\"demo\", praise = \"Great!\", encouragement = \"Try again.\") random_praise(language = \"demo\") #> [1] \"Great!\" random_encouragement(language = \"demo\") #> [1] \"Try again.\""},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/random_praise.html","id":null,"dir":"Reference","previous_headings":"","what":"Random praise and encouragement — random_praise","title":"Random praise and encouragement — random_praise","text":"Random praises encouragements sayings compliment question quiz experience.","code":""},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/random_praise.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Random praise and encouragement — random_praise","text":"","code":"random_praise(language = NULL) random_encouragement(language = NULL)"},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/random_praise.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Random praise and encouragement — random_praise","text":"language language random phrase. currently supported languages include: en, es, pt, pl, tr, de, emo, testing (static phrases).","code":""},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/random_praise.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Random praise and encouragement — random_praise","text":"Character string random saying","code":""},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/random_praise.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Random praise and encouragement — random_praise","text":"","code":"random_praise() #> [1] \"Excellent!\" random_praise() #> [1] \"Beautiful!\" random_encouragement() #> [1] \"Don't give up now, try it one more time.\" random_encouragement() #> [1] \"Try it again. Perseverence is the key to success.\""},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/run_tutorial.html","id":null,"dir":"Reference","previous_headings":"","what":"Run a tutorial — run_tutorial","title":"Run a tutorial — run_tutorial","text":"Run tutorial provided installed R package.","code":""},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/run_tutorial.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Run a tutorial — run_tutorial","text":"","code":"run_tutorial( name = NULL, package = NULL, ..., shiny_args = NULL, clean = FALSE, as_rstudio_job = NULL )"},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/run_tutorial.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Run a tutorial — run_tutorial","text":"name Tutorial name (subdirectory within tutorials/ directory installed package). Alternatively, package provided, name may path local tutorial R Markdown file local directory containing learnr tutorial. package provided, name must tutorial name. package Name package. name path local directory containing learnr tutorial, package provided. ... Unused. Included future expansion ensure named arguments used. shiny_args Additional arguments forward shiny::runApp. clean TRUE, shiny prerendered HTML files removed tutorial re-rendered prior starting tutorial. as_rstudio_job Runs tutorial background RStudio job. default behavior run_tutorial() detects RStudio available can run jobs. Set FALSE disable run tutorial current R session. running RStudio job, run_tutorial() sets overrides launch.browser option shiny_args. can instead use shiny.launch.browser global option current R session set default behavior tutorial run. See shiny options documentation information.","code":""},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/run_tutorial.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Run a tutorial — run_tutorial","text":"Starts Shiny server running learnr tutorial.","code":""},{"path":[]},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/run_tutorial.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Run a tutorial — run_tutorial","text":"","code":"# display all \"learnr\" tutorials available_tutorials(\"learnr\") #> Available tutorials: #> * learnr #> - ex-data-basics : \"Data basics\" #> - ex-data-filter : \"Filter observations\" #> - ex-data-mutate : \"Create new variables\" #> - ex-data-summarise : \"Summarise Tables\" #> - ex-setup-r : \"Set Up\" #> - hello : \"Hello, Tutorial!\" #> - polyglot : \"Multi-language exercises\" #> - quiz_question : \"Tutorial Quiz Questions in `learnr`\" #> - setup-chunks : \"Chained setup chunks\" #> - slidy : \"Slidy demo\" #> - sql-exercise : \"Interactive SQL Exercises\" # run basic example within learnr if (FALSE) { run_tutorial(\"hello\", \"learnr\") }"},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/safe.html","id":null,"dir":"Reference","previous_headings":"","what":"Execute R code in a safe R environment — safe","title":"Execute R code in a safe R environment — safe","text":"rendering (running) document R markdown, inherits current R Global environment. produce unexpected behaviors, poisoning R Global environment existing variables. rendering document new, safe R environment, vanilla, rendered document produced.","code":""},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/safe.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Execute R code in a safe R environment — safe","text":"","code":"safe(expr, ..., show = TRUE, env = safe_env())"},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/safe.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Execute R code in a safe R environment — safe","text":"expr expression contains necessary library calls execute. Expressions within callr inherit existing, loaded libraries. ... parameters passed callr::r show Logical determines output displayed env Environment evaluate document ","code":""},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/safe.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Execute R code in a safe R environment — safe","text":"result expr.","code":""},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/safe.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Execute R code in a safe R environment — safe","text":"environment variable LEARNR_INTERACTIVE set \"1\" \"0\" depending calling session interactive . Using safe necessary locally deployed.","code":""},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/safe.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Execute R code in a safe R environment — safe","text":"","code":"if (FALSE) { # Direct usage safe(run_tutorial(\"hello\", package = \"learnr\")) # Programmatic usage library(rlang) expr <- quote(run_tutorial(\"hello\", package = \"learnr\")) safe(!!expr) tutorial <- \"hello\" safe(run_tutorial(!!tutorial, package = \"learnr\")) }"},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/safe_env.html","id":null,"dir":"Reference","previous_headings":"","what":"Safe R CMD environment — safe_env","title":"Safe R CMD environment — safe_env","text":"default, callr::rcmd_safe_env suppresses ability open browser window. default execution environment within callr::r. However, opening browser expected behavior within learnr package suppressed.","code":""},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/safe_env.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Safe R CMD environment — safe_env","text":"","code":"safe_env()"},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/safe_env.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Safe R CMD environment — safe_env","text":"list envvars, modified callr::rcmd_safe_env().","code":""},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/safe_env.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Safe R CMD environment — safe_env","text":"","code":"safe_env() #> CYGWIN R_TESTS R_PDFVIEWER #> \"nodosfilewarning\" \"\" \"false\""},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/tutorial.html","id":null,"dir":"Reference","previous_headings":"","what":"Tutorial document format — tutorial","title":"Tutorial document format — tutorial","text":"Long-form tutorial includes narrative, figures, videos, exercises, questions.","code":""},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/tutorial.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Tutorial document format — tutorial","text":"","code":"tutorial( fig_width = 6.5, fig_height = 4, fig_retina = 2, fig_caption = TRUE, progressive = FALSE, allow_skip = FALSE, dev = \"png\", df_print = \"paged\", smart = TRUE, theme = \"rstudio\", highlight = \"textmate\", ace_theme = \"textmate\", mathjax = \"default\", extra_dependencies = NULL, css = NULL, includes = NULL, md_extensions = NULL, pandoc_args = NULL, language = \"en\", lib_dir = NULL, ... )"},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/tutorial.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Tutorial document format — tutorial","text":"fig_width Default width (inches) figures fig_height Default height (inches) figures fig_retina Scaling perform retina displays (defaults 2, currently works widely used retina displays). Set NULL prevent retina scaling. Note always NULL keep_md specified (fig_retina relies outputting HTML directly markdown document). fig_caption TRUE render figures captions progressive Display sub-topics progressively (.e. wait previous topics either completed skipped displaying subsequent topics). allow_skip Allow users skip sub-topics (especially useful progressive TRUE). dev Graphics device use figure output (defaults png) df_print Method used printing data frames. Valid values include \"default\", \"kable\", \"tibble\", \"paged\". \"default\" method uses corresponding S3 method print, typically print.data.frame. \"kable\" method uses knitr::kable function. \"tibble\" method uses tibble package print summary data frame. \"paged\" method creates paginated HTML table (note method valid formats produce HTML). addition named methods can also pass arbitrary function used printing data frames. can disable df_print behavior entirely setting option rmarkdown.df_print FALSE. See Data frame printing section bookdown book examples. smart Produce typographically correct output, converting straight quotes curly quotes, --- em-dashes, -- en-dashes, ... ellipses. Deprecated rmarkdown v2.2.0. theme Visual theme (\"rstudio\", default\", \"cerulean\", \"journal\", \"flatly\", \"readable\", \"spacelab\", \"united\", \"cosmo\", \"lumen\", \"paper\", \"sandstone\", \"simplex\", \"yeti\"). highlight Syntax highlighting style. Supported styles include \"default\", \"tango\", \"pygments\", \"kate\", \"monochrome\", \"espresso\", \"zenburn\", \"haddock\", \"textmate\". Pass ‘NULL’ prevent syntax highlighting. Note, value pertains standard rmarkdown code, Ace editor highlighting. ace_theme Ace theme supplied ace code editor exercises. See learnr:::ACE_THEMES list possible values. Defaults \"textmate\". mathjax Include mathjax. \"default\" option uses https URL MathJax CDN. \"local\" option uses local version MathJax (copied output directory). can pass alternate URL pass NULL exclude MathJax entirely. extra_dependencies Extra dependencies list html_dependency class objects typically generated htmltools:htmlDependency(). css CSS /Sass files include. Files extension .sass .scss compiled CSS via sass::sass(). Also, theme bslib::bs_theme() object, Sass code may reference relevant Bootstrap Sass variables, functions, mixins, etc. includes Named list additional content include within document (typically created using includes function). md_extensions Markdown extensions added removed default definition R Markdown. See rmarkdown_format additional details. pandoc_args Additional command line options pass pandoc language Language custom text UI elements. See vignette(\"multilang\", package = \"learnr\") information available options formatting lib_dir Directory copy dependent HTML libraries (e.g. jquery, bootstrap, etc.) . default name document _files appended . ... Forward parameters html_document","code":""},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/tutorial.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Tutorial document format — tutorial","text":"rmarkdown::output_format() learnr tutorials.","code":""},{"path":"https://pkgs.rstudio.com/learnr/dev/reference/tutorial.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Tutorial document format — tutorial","text":"","code":"tutorial() #> $knitr #> $knitr$opts_chunk #> $knitr$opts_chunk$dev #> [1] \"png\" #> #> $knitr$opts_chunk$dpi #> [1] 96 #> #> $knitr$opts_chunk$fig.width #> [1] 6.5 #> #> $knitr$opts_chunk$fig.height #> [1] 4 #> #> $knitr$opts_chunk$fig.retina #> [1] 2 #> #> $knitr$opts_chunk$tutorial #> [1] TRUE #> #> $knitr$opts_chunk$max.print #> [1] 1000 #> #> #> $knitr$opts_knit #> NULL #> #> $knitr$knit_hooks #> $knitr$knit_hooks$tutorial #> function (before, options, envir) #> { #> if (!before) { #> .learnr_messages$flush() #> } #> exercise_wrapper_div <- function(suffix = NULL, extra_html = NULL) { #> if (before) { #> if (!is.null(suffix)) #> suffix <- paste0(\"-\", suffix) #> class <- paste0(\"exercise\", suffix) #> lines <- ifelse(is.numeric(options$exercise.lines), #> options$exercise.lines, 0) #> completion <- as.numeric(options$exercise.completion %||% #> 1 > 0) #> diagnostics <- as.numeric(options$exercise.diagnostics %||% #> 1 > 0) #> startover <- as.numeric(options$exercise.startover %||% #> 1 > 0) #> paste0(\" options$label, \"\\\" data-completion=\\\"\", completion, #> \"\\\" data-diagnostics=\\\"\", diagnostics, \"\\\" data-startover=\\\"\", #> startover, \"\\\" data-lines=\\\"\", lines, \"\\\">\") #> } #> else { #> c(extra_html, \"<\/div>\") #> } #> } #> if (is_exercise_chunk(options)) { #> extra_html <- NULL #> if (before) { #> verify_tutorial_chunk_label() #> knitr::knit_meta_add(list(list(ace_html_dependency()), #> list(clipboardjs_html_dependency()))) #> exercise_server_chunk(options$label) #> } #> else { #> options$engine <- knitr_engine(options$engine) #> options$exercise.df_print <- options$exercise.df_print %||% #> knitr::opts_knit$get(\"rmarkdown.df_print\") %||% #> \"default\" #> options$exercise.checker <- dput_to_string(options$exercise.checker) #> all_chunks <- get_all_chunks(options) #> code_check_chunk <- get_knitr_chunk(paste0(options$label, #> \"-code-check\")) #> error_check_chunk <- get_knitr_chunk(paste0(options$label, #> \"-error-check\")) #> check_chunk <- get_knitr_chunk(paste0(options$label, #> \"-check\")) #> solution <- get_knitr_chunk(paste0(options$label, #> \"-solution\")) #> tests <- get_knitr_chunk(paste0(options$label, \"-tests\")) #> class(options) <- NULL #> all_setup_code <- NULL #> if (length(all_chunks) > 1) { #> all_setup_code <- paste0(vapply(all_chunks[-length(all_chunks)], #> function(x) x$code, character(1)), collapse = \"\\n\") #> } #> this_exercise <- structure(list(label = options[[\"label\"]], #> global_setup = get_setup_global_exercise(), setup = all_setup_code, #> chunks = all_chunks, code_check = code_check_chunk, #> error_check = error_check_chunk, check = check_chunk, #> solution = solution, tests = tests, options = options[setdiff(names(options), #> \"tutorial\")], engine = options$engine, version = current_exercise_version), #> class = c(options$engine, \"tutorial_exercise\")) #> rmarkdown::shiny_prerendered_chunk(\"server\", sprintf(\"learnr:::store_exercise_cache(%s)\", #> dput_to_string(this_exercise))) #> caption <- if (!is.null(options$exercise.cap)) { #> as.character(options$exercise.cap) #> } #> else { #> cap_engine <- knitr_engine(options$engine) #> cap_engine_file <- system.file(file.path(\"internals\", #> \"icons\", paste0(cap_engine, \".svg\")), package = \"learnr\") #> if (file.exists(cap_engine_file)) { #> as.character(htmltools::div(class = \"tutorial_engine_icon\", #> htmltools::HTML(readLines(cap_engine_file)))) #> } #> else { #> cap_engine_val <- knitr_engine_caption(options[[\"engine\"]]) #> i18n_span(\"text.enginecap\", paste(cap_engine_val, #> \"Code\"), opts = list(engine = cap_engine_val)) #> } #> } #> ui_options <- list(engine = options$engine, has_checker = (!is.null(check_chunk) || #> !is.null(code_check_chunk)), caption = as.character(caption)) #> extra_html <- c(\"