Skip to content

Commit 8af781a

Browse files
v0.11.0 (#735)
Co-authored-by: Alex Rossell Hayes <44556601+rossellhayes@users.noreply.github.com>
1 parent 6508e36 commit 8af781a

File tree

96 files changed

+1117
-266
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

96 files changed

+1117
-266
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Type: Package
22
Package: learnr
33
Title: Interactive Tutorials for R
4-
Version: 0.10.7.9000
4+
Version: 0.11.0
55
Authors@R: c(
66
person("Garrick", "Aden-Buie", , "garrick@rstudio.com", role = c("aut", "cre"),
77
comment = c(ORCID = "0000-0002-7111-0077")),

NEWS.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# learnr (development version)
1+
# learnr 0.11.0
22

33
## Authoring
44

@@ -48,7 +48,7 @@
4848

4949
- The `exercise.cap` exercise/chunk option now accepts HTML input. If no `exercise.cap` is provided, the `exercise.cap` will default to the combination of the exercise engine and `" code"` (#397, #429).
5050

51-
- Improved support for SQL exercises makes it possible to check student submissions for SQL exercises (#668).
51+
- Improved support for SQL exercises makes it possible to check student submissions for SQL exercises. See `run_tutorial("sql-exericse", "learnr")` or the [online SQL exercise demo](https://learnr-examples.shinyapps.io/sql-exercise) for an example tutorial with graded SQL exercises (#668).
5252

5353
- Exercise editors now use syntax highlighting and basic autocompletion for exercises in languages other than R with syntax highlighting support for JavaScript, Julia, Python and SQL (#693).
5454

@@ -165,7 +165,7 @@
165165
- `run_tutorial()` now renders tutorials in a temp directory if the R user does not have write permissions (#347).
166166

167167
- Many of the HTML dependencies used by learnr have been updated to more recent versions (#655). learnr now uses:
168-
- [Ace](https://ace.c9.io/) version [1.4.14](https://github.com/ajaxorg/ace/blob/HEAD/ChangeLog.txt)
168+
- [Ace](https://ace.c9.io/) version [1.10.1](https://github.com/ajaxorg/ace/blob/ff3dd698/CHANGELOG.md)
169169
- [clipboard.js](https://clipboardjs.com/) version [2.0.10](https://github.com/zenorocha/clipboard.js/releases)
170170
- [Bootbox](http://bootboxjs.com/) version [5.5.2](https://github.com/makeusabrew/bootbox/blob/master/CHANGELOG.md)
171171
- [i18next](https://www.i18next.com/) version [21.6.10](https://github.com/i18next/i18next/blob/master/CHANGELOG.md)
@@ -182,11 +182,11 @@
182182

183183
- Support the updated Bootstrap 4+ popover dispose method name, previously destroy (#560).
184184

185-
- Forked evaluator (used by default on Linux and [shinyapps.io](https://shinyapps.io)) now only collects the exercise evaluation result once, avoiding a "cannot wait for child" warning (thanks @tombeesley #449, #631).
185+
- Forked evaluator (used by default on Linux and [shinyapps.io](https://www.shinyapps.io/)) now only collects the exercise evaluation result once, avoiding a "cannot wait for child" warning (thanks @tombeesley #449, #631).
186186

187187
- `learnr::tutorial()` now allows authors to adjust the value of `lib_dir` (#648).
188188

189-
- learnr now uses and suggests [shinytest2](https://rstudio.github.io/shinytest2) for automated testing of tutorials in the browser. If you were previously using [shinytest](https://rstudio.github.io/shinytest) to test your tutorials, you may find the [Migrating from shinytest](https://rstudio.github.io/shinytest2/articles/z-migration.html) article to be helpful (#694).
189+
- learnr now uses and suggests [shinytest2](https://rstudio.github.io/shinytest2/) for automated testing of tutorials in the browser. If you were previously using [shinytest](https://rstudio.github.io/shinytest/) to test your tutorials, you may find the [Migrating from shinytest](https://rstudio.github.io/shinytest2//articles/z-migration.html) article to be helpful (#694).
190190

191191
# learnr 0.10.1
192192

@@ -250,7 +250,7 @@
250250

251251
- Added a fail-safe to try-catch bad student code that would crash the tutorial (@adamblake #229).
252252

253-
- Replaced references to `checkthat` and `grader` in docs with [gradethis](https://github.com/rstudio-education/gradethis) (#269)
253+
- Replaced references to `checkthat` and `grader` in docs with [gradethis](https://github.com/rstudio/gradethis) (#269)
254254

255255
- Removed a warning created by pandoc when evaluating exercises where pandoc was wanting a title or pagetitle. #303
256256

R/ace.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# This file was autogenerated by 'tools/update-ace.R'
2-
ACE_VERSION <- "1.4.14"
3-
ACE_THEMES <- c("ambiance", "chaos", "chrome", "clouds_midnight", "clouds", "cobalt", "crimson_editor", "dawn", "dracula", "dreamweaver", "eclipse", "github", "gob", "gruvbox", "idle_fingers", "iplastic", "katzenmilch", "kr_theme", "kuroir", "merbivore_soft", "merbivore", "mono_industrial", "monokai", "nord_dark", "one_dark", "pastel_on_dark", "solarized_dark", "solarized_light", "sqlserver", "terminal", "textmate", "tomorrow_night_blue", "tomorrow_night_bright", "tomorrow_night_eighties", "tomorrow_night", "tomorrow", "twilight", "vibrant_ink", "xcode")
2+
ACE_VERSION <- "1.10.1"
3+
ACE_THEMES <- c("ambiance", "chaos", "chrome", "cloud9_day", "cloud9_night_low_color", "cloud9_night", "clouds_midnight", "clouds", "cobalt", "crimson_editor", "dawn", "dracula", "dreamweaver", "eclipse", "github", "gob", "gruvbox_dark_hard", "gruvbox_light_hard", "gruvbox", "idle_fingers", "iplastic", "katzenmilch", "kr_theme", "kuroir", "merbivore_soft", "merbivore", "mono_industrial", "monokai", "nord_dark", "one_dark", "pastel_on_dark", "solarized_dark", "solarized_light", "sqlserver", "terminal", "textmate", "tomorrow_night_blue", "tomorrow_night_bright", "tomorrow_night_eighties", "tomorrow_night", "tomorrow", "twilight", "vibrant_ink", "xcode")

R/debug_exercise_checker.R

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
#' @param engine The engine of the exercise chunk
2020
#' @param ... Not used (future compatibility)
2121
#'
22+
#' @return Feedback for use in exercise debugging.
23+
#'
2224
#' @keywords internal
2325
debug_exercise_checker <- function(
2426
label,

R/evaluators.R

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,16 +158,21 @@ forked_evaluator <- setup_forked_evaluator_factory(max_forked_procs = Inf)
158158

159159
#' External execution evaluator
160160
#'
161-
#' [Lifecycle: experimental](https://www.tidyverse.org/lifecycle/#experimental)
161+
#' [Lifecycle: experimental](https://lifecycle.r-lib.org/articles/stages.html)
162+
#'
162163
#' @param endpoint The HTTP(S) endpoint to POST the exercises to
163164
#' @param max_curl_conns The maximum number of simultaneous HTTP requests to the
164165
#' endpoint.
166+
#'
167+
#' @return A function that takes an expression (`expr`), `timelimit`, `exercise`
168+
#' and `session`.
169+
#'
165170
#' @import curl
166171
#' @export
167172
external_evaluator <- function(
168173
endpoint = getOption("tutorial.external.host", Sys.getenv("TUTORIAL_EXTERNAL_EVALUATOR_HOST", NA)),
169-
max_curl_conns = 50){
170-
174+
max_curl_conns = 50
175+
){
171176
internal_external_evaluator(endpoint, max_curl_conns)
172177
}
173178

R/events.R

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ event_trigger <- function(session, event, data = list()) {
112112

113113
#' Wrap an expression that will be executed one time in an event handler
114114
#'
115+
#' @description
115116
#' This wraps an expression so that it will be executed one time for a tutorial,
116117
#' based on some condition. The first time the condition is true, the expression
117118
#' will be executed; after that, the expression will not be evaluated again.
@@ -123,17 +124,6 @@ event_trigger <- function(session, event, data = list()) {
123124
#' A common use for `one_time` is to execute an expression when a section is
124125
#' viewed for the first time.
125126
#'
126-
#' @param session A Shiny session object.
127-
#' @param cond A condition that is used as a filter. The first time the
128-
#' condition evaluates to true, `expr` will be evaluated; after that, `expr`
129-
#' will not be evaluated again.
130-
#' @param expr An expression that will be evaluated once, the first time that
131-
#' `cond` is true.
132-
#' @param label A unique identifier. This is used as an ID for the condition and
133-
#' expression; if two calls to `one_time()` uses the same label, there will be
134-
#' an ID collision and only one of them will execute. By default, `cond` is
135-
#' deparsed and used as the label.
136-
#'
137127
#' @examples
138128
#' \dontrun{
139129
#' # This goes in a {r context="server-start"} chunk
@@ -154,6 +144,21 @@ event_trigger <- function(session, event, data = list()) {
154144
#'
155145
#'
156146
#' }
147+
#'
148+
#' @param session A Shiny session object.
149+
#' @param cond A condition that is used as a filter. The first time the
150+
#' condition evaluates to true, `expr` will be evaluated; after that, `expr`
151+
#' will not be evaluated again.
152+
#' @param expr An expression that will be evaluated once, the first time that
153+
#' `cond` is true.
154+
#' @param label A unique identifier. This is used as an ID for the condition and
155+
#' expression; if two calls to `one_time()` uses the same label, there will be
156+
#' an ID collision and only one of them will execute. By default, `cond` is
157+
#' deparsed and used as the label.
158+
#'
159+
#' @return The result of evaluating `expr` (`one_time()` is intended to be
160+
#' called within an event handler).
161+
#'
157162
#' @export
158163
one_time <- function(session, cond, expr, label = deparse(substitute(cond))) {
159164
# This is meant to be called within an event handler, instead of being

R/html-dependencies.R

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11

22
#' Tutorial HTML dependency
33
#'
4-
#' @details HTML dependency for core tutorial JS and CSS. This should be included as a
4+
#' HTML dependency for core tutorial JS and CSS. This should be included as a
55
#' dependency for custom tutorial formats that wish to ensure that that
6-
#' tutorial.js and tutorial.css are loaded prior their own scripts and stylesheets.
6+
#' `tutorial.js` and `tutorial.css` are loaded prior their own scripts and
7+
#' stylesheets.
8+
#'
9+
#' @return \pkg{learnr}'s HTML dependencies
710
#'
811
#' @export
912
tutorial_html_dependency <- function() {

R/initialize.R

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
#' \pkg{learnr} package. This function is typically called automatically
88
#' as a result of using exercises or questions.
99
#'
10+
#' @return If not previously run, initializes knitr hooks and provides the
11+
#' required [rmarkdown::shiny_prerendered_chunk()]s to initialize \pkg{learnr}.
12+
#'
1013
#' @export
1114
initialize_tutorial <- function() {
1215

R/mock_exercise.R

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#' Creates an interactive exercise object that can be used in tests without
44
#' having to create a learnr tutorial.
55
#'
6-
#' @examples
6+
#' @examplesIf identical(Sys.getenv("IN_PKGDOWN"), "true")
77
#' mock_exercise(
88
#' user_code = "1 + 1",
99
#' solution_code = "2 + 2",
@@ -60,6 +60,8 @@
6060
#' @param ... Additional chunk options as if there were included in the
6161
#' exercise chunk.
6262
#'
63+
#' @return An exercise object.
64+
#'
6365
#' @describeIn mock_exercise Create a learnr exercise object
6466
#' @keywords internal
6567
#' @export

R/mutate_tags.R

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,6 @@ disable_tags <- function(ele, selector) {
123123
#'
124124
#' Method to disable all html tags to not allow users to interact with the html.
125125
#'
126-
#' @param ele html tag element
127-
#' @export
128126
#' @examples
129127
#' # add an href to all a tags
130128
#' disable_all_tags(
@@ -133,6 +131,13 @@ disable_tags <- function(ele, selector) {
133131
#' htmltools::a()
134132
#' )
135133
#' )
134+
#'
135+
#' @param ele html tag element
136+
#'
137+
#' @return An \pkg{htmltools} HTML object with appended `class = "disabled"` and
138+
#' `disabled` attributes on all tags.
139+
#'
140+
#' @export
136141
disable_all_tags <- function(ele) {
137142
mutate_tags(ele, "*", disable_element_fn)
138143
}
@@ -154,6 +159,10 @@ disable_all_tags <- function(ele) {
154159
#' )
155160
#'
156161
#' @inheritParams disable_all_tags
162+
#'
163+
#' @return An \pkg{htmltools} HTML object with appropriately appended classes
164+
#' such that a tutorial question is marked as the final answer.
165+
#'
157166
#' @export
158167
finalize_question <- function(ele) {
159168
ele <- disable_all_tags(ele)

R/options.R

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44
#' Set various tutorial options that control the display and evaluation of
55
#' exercises.
66
#'
7+
#' @examples
8+
#' if (interactive()) {
9+
#' tutorial_options(exercise.eval = TRUE, exercise.timelimt = 10)
10+
#' }
11+
#'
712
#' @param exercise.cap Caption for exercise chunk (defaults to the engine's icon or the combination of the engine and \code{" code"}).
813
#' @param exercise.eval Whether to pre-evaluate the exercise so the reader can
914
#' see some default output (defaults to \code{FALSE}).
@@ -25,6 +30,8 @@
2530
#' @param exercise.reveal_solution Whether to reveal the exercise solution if
2631
#' a solution chunk is provided.
2732
#'
33+
#' @return Nothing. Invisibly sets [knitr::opts_chunk] settings.
34+
#'
2835
#' @export
2936
tutorial_options <- function(exercise.cap = NULL,
3037
exercise.eval = FALSE,

R/praise.R

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@
44
#' Random praises and encouragements sayings to compliment your question and
55
#' quiz experience.
66
#'
7+
#' @examples
8+
#' random_praise()
9+
#' random_praise()
10+
#'
11+
#' random_encouragement()
12+
#' random_encouragement()
13+
#'
714
#' @param language The language for the random phrase. The currently supported
815
#' languages include: `en`, `es`, `pt`, `pl`, `tr`, `de`, `emo`, and `testing`
916
#' (static phrases).

R/question_answers.R

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
#' numeric questions, `answer_fn()` can be used to provide a function that
99
#' evaluates the student's submission and returns a custom result.
1010
#'
11+
#' @examples
12+
#' answer(32, correct = FALSE)
13+
#' answer(42, correct = TRUE, message = "The meaning of life.")
14+
#'
1115
#' @param text The answer text or value; for selection-type questions this value
1216
#' is shown to the user.
1317
#' @param fn A function used to evaluate the submitted answer. The function is

R/question_methods.R

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,25 @@
2424
#'
2525
#' - Determines how the question is displayed to the users while the "Try again" screen is displayed. Usually this function will disable inputs to the question, i.e. prevent the student from changing the answer options. Similar to `question_ui_initialize`, this should should return a shiny UI object that can be displayed using [shiny::renderUI].
2626
#'
27+
#' @examples
28+
#' q <- question(
29+
#' "Which package helps you teach programming skills?",
30+
#' answer("dplyr"),
31+
#' answer("learnr", correct = TRUE),
32+
#' answer("base")
33+
#' )
34+
#' question_is_correct(q, "dplyr")
35+
#' question_is_correct(q, "learnr")
36+
#'
2737
#' @param question [question] object used
2838
#' @param value user input value
2939
#' @param ... future parameter expansion and custom arguments to be used in dispatched s3 methods.
3040
#'
41+
#' @return learnr question objects, UI elements, results or server methods.
42+
#'
3143
#' @seealso For more information and question type extension examples, please
3244
#' see the **Custom Question Types** section of the `quiz_question` tutorial:
3345
#' `learnr::run_tutorial("quiz_question", "learnr")`.
34-
#'
3546
#' @export
3647
#' @rdname question_methods
3748
question_ui_initialize <- function(question, value, ...) {

0 commit comments

Comments
 (0)