-
Notifications
You must be signed in to change notification settings - Fork 239
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Store exercises and questions in list in cache env (#571)
* Store exercises and questions in list in cache env - Bring questions and exercises into an `objects` list in a single env `tutorial_cache_env` - Give `exercise` objects a `learnr_exercise` class - Refactor getters and setters to use `get_tutorial_cache()` and `set_tutorial_cache()` - Handle "__setup__" chunk directly in knitr hooks * Return tutorial state in order of appearance When `label = NULL` in `get_tutorial_state()`, the state is returned as a list in order of appearance of the interactive elements * Print `learnr_exercise` obejcts as Rmd chunks * Don't duplicate chunk labels * Update `mock_exercise()` with `learnr_exercise` class With custom format method to align appearance with typical exercise objects * Set `force = TRUE` when serializing exercises * Add data frame describing interactive items to `get_tutorial_info()` * devtools::document() * Include ex/q object in `data` of `$items` and fix order of setup chunk The `__setup__` chunk gets order 0 * Add `data` to description of `items` element * Protect `get_tutorial_info()` from being called by user code * Deprecate `clear_{exercise,question}_cache_env()` in favor of `clear_tutorial_cache()` * Only update question state when it is non-NULL * Inline `global_setup` into exercise objects on creation Previously we tried to store the global setup in a separate shiny prerendered chunk with the name "__setup__". This change avoids potential exercise id clashes with a user-created chunk labelled "__setup_-". It also avoids a tricky knitr source hook issue when calling `rmarkdown::run()` interactively that would cause the global setup chunk to be lost. * Rename exercise object class `tutorial_exercise` I'd prefer `learnr_exercise` but questions are super-classed `tutorial_question` (and have been for a while) * Remove old source knitr hook * Fix typo * Refactor `prepare_tutorial_cache_from_source()` * Remove unused knitr hooks tests * Fix removal of tutorial knitr hooks and don't store `tutorial` in `exercise$options` * Properly handle `setup-global-exercise` chunks - Treat as exercise support - Force evaluation of `global_setup` if used in exercises - Add related tests * Avoid rcmdcheck issues with `getFromNamespace()` * `setup-global-exercise` chunk is the external setup chunk it shouldn't be evaluated locally, but it should be used by external evaluators with `evaluate_global_setup = TRUE` * Add NEWS for #571
- Loading branch information
Showing
15 changed files
with
390 additions
and
191 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.