-
Notifications
You must be signed in to change notification settings - Fork 239
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
Code boxes don't run if opened for a second time #598
Comments
It turns out that it works fine if the |
`tutorial_knitr_options()` now prepares a list of knitr options with the knitr options and hooks that are used during the tutorial pre-render. This list is in the same format as the knitr options expected by `rmarkdown::output_format()` so we can set the knitr options directly in the `tutorial` output format. This ensures that the hooks are set for each `rmarkdown::render()` call. Previously, by only relying on `.onAttach()`, these hooks might be reset at the end of the first `render()` and wouldn't be re-installed for subsequent renders, resulting in the behavior seen in #598. I haven't removed the `.onAttach()` mechanism because it is still useful for catching learnr component usage outside of the `learnr::tutorial()` format.
I have the same issue! Fresh R session:
If I restart R and load learnr from the beginning it all works fine
If I restart R session but load learnr after the first tutorial, none of the tutorials after the first one are interactive anymore:
Clicking "Start Over" doesn't solve this. So, it seems that learn needs to be explicitly attached (which is annoying) AND that needs to happen before any tutorial is run, as any tutorial after the first one is no longer interactive.
The quizzes always work, they are not affected by this. |
Thanks @czucca and @SNAnalyst for the reports. The issue is that learnr requires specific knitr hooks to be installed to process the interactive exercise chunks. We've historically installed these when attaching learnr because technically learnr can be used in shiny prerendered Where that approach runs into problems, however, is when running the tutorial interactively, because devtools::install_github("rstudio/learnr@knitr-hooks-in-format") |
@gadenbuie thank you so much for addressing the problem so quickly and smoothly! |
@gadenbuie Wonderful, it works beautifully, thanks Garrick! |
Hi there,
I coauthor a teaching package depending on
learnr
that offers tutorials for students enrolled in our course. We are encountering problems when running the tutorials.mypackage
depending onlearnr
andgradethis
R
In order to explore the origin of the problem
System details
These are my system details, but we tried with more than one machine consistently getting the same error.
Output of
sessioninfo::session_info()
:Describe the problem in detail
After installation, any tutorial correctly runs only one time. After the first run, tutorials are no longer interactive. They directly show output.
image one: tutorial opened for the first time.
image two: tutorial opened for the second time. No longer interactive.
image 1:
image 2:
The text was updated successfully, but these errors were encountered: