Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display available tutorials #234

Merged
merged 22 commits into from
Jun 6, 2019
Merged

Display available tutorials #234

merged 22 commits into from
Jun 6, 2019

Conversation

schloerke
Copy link
Collaborator

@schloerke schloerke commented May 15, 2019

Fixes #224
Fixes #223

learnr::available_tutorials()
#> Available tutorials:
#> * grader
#>   - grading-demo   : "Grading demo"
#>   - recording-demo : "Recording demo"
#>   - scoping-rules  : "What do exercise chunks have access to?"
#>   - setup-rules    : "learnr Setup Rules v 0.9.2"
#>   - solutions-demo : "Solutions demo"
#> * learnr
#>   - hello         : "Hello, Tutorial!"
#>   - question_type : "Question Types in Learnr"
#>   - slidy         : "Slidly demo"

learnr::available_tutorials("learnr")
#> Available tutorials:
#> * learnr
#>   - hello         : "Hello, Tutorial!"
#>   - question_type : "Question Types in Learnr"
#>   - slidy         : "Slidly demo"

learnr::run_tutorial()
#> Available tutorials:
#> * grader
#>   - grading-demo   : "Grading demo"
#>   - recording-demo : "Recording demo"
#>   - scoping-rules  : "What do exercise chunks have access to?"
#>   - setup-rules    : "learnr Setup Rules v 0.9.2"
#>   - solutions-demo : "Solutions demo"
#> * learnr
#>   - hello         : "Hello, Tutorial!"
#>   - question_type : "Question Types in Learnr"
#>   - slidy         : "Slidly demo"

learnr::run_tutorial(package = "learnr")
#> Available tutorials:
#> * learnr
#>   - hello         : "Hello, Tutorial!"
#>   - question_type : "Question Types in Learnr"
#>   - slidy         : "Slidly demo"

learnr::run_tutorial("not found")
#> Error: `package` must be provided if `name` is provided.

learnr::run_tutorial("not found", package = "learnr")
#> Error: Tutorial "not found" was not found in the "learnr" package.
#> Available tutorials:
#> * learnr
#>   - hello         : "Hello, Tutorial!"
#>   - question_type : "Question Types in Learnr"
#>   - slidy         : "Slidly demo"

Created on 2019-05-29 by the reprex package (v0.2.1)

@schloerke schloerke requested a review from wch May 15, 2019 14:28
@wch
Copy link
Collaborator

wch commented May 15, 2019

May want to use adist to find the closest match, and say something like "Did you mean <closest match>?"

```
❯❯ dev_load(); run_tutorial("helloo", "learnr")
Loading learnr
Error: 	Tutorial "helloo" was not found in the "learnr" package.
	Did you mean "hello"?
	Available "learnr" tutorials: "hello", "question_type", "slidy"
```
@schloerke schloerke requested review from wch and removed request for wch May 29, 2019 14:30
R/run.R Outdated Show resolved Hide resolved
R/run.R Outdated Show resolved Hide resolved
R/run.R Outdated Show resolved Hide resolved
@schloerke schloerke requested a review from wch May 29, 2019 18:30
R/available_tutorials.R Outdated Show resolved Hide resolved
R/available_tutorials.R Show resolved Hide resolved
@schloerke schloerke merged commit e41ee8b into master Jun 6, 2019
@schloerke schloerke deleted the available_tutorials branch June 6, 2019 20:07
sjgknight pushed a commit to sjgknight/learnr that referenced this pull request Aug 10, 2021
* add an available tutorials method

* return unique tutorials only

* Tests for available_tutorials

* check if package exists

* make available tutorials invisible when returning from run_tutorial

* add `stop.` which equals `stop(..., call. = FALSE)`

* add tests

* document

* add close matching if within 3 letters

```
❯❯ dev_load(); run_tutorial("helloo", "learnr")
Loading learnr
Error: 	Tutorial "helloo" was not found in the "learnr" package.
	Did you mean "hello"?
	Available "learnr" tutorials: "hello", "question_type", "slidy"
```

* import adist from utils

* added new news item and rearranged the news order

* ignore case within adist to give best match

* give slidy a title

* comment why using 'missing'

* add an example in run_tutorial.  Also display all available learnr tutorials

Fixes rstudio#223

* use NULL default values for run_tutorial to avoid "missing" issues

* extract out available_tutorial methods to a single file. Add formatting methods

return an invisible data.frame of the information

* cleaner error formatting

* minor code feedback
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ability to discover tutorials from a package run_tutorial() needs an example
2 participants