-
Notifications
You must be signed in to change notification settings - Fork 242
Progressively render the exercise Rmd to accurately capture prep and result environments #480
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
Merged
Conversation
This file contains hidden or 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
1287c7f to
14d1492
Compare
Contributor
nischalshrestha
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good! Just had a comment + question.
schloerke
approved these changes
Jan 29, 2021
Collaborator
schloerke
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM pending the learnr::: in the test is removed
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixing
envir_prepandenvir_resultThis PR fixes rstudio/gradethis#199, namely we use a two-step rendering process to ensure that we accurately return the prep environment in
envir_prep.Previously the
envir_prepenvironment contained the results of evaluating the global setup chunk, but not the exercise-specific setup chunks. With the two step evaluation viarmarkdown::render(), we now guarantee thatenvir_prepcontains the results of the global setup and the exercise setup.We also ensure that
envir_resultis a cousin environment duplicated fromenvir_prep. If an error occurs in the setup code,envir_resultandenvir_prepare identical. If an error occurs in the user code,envir_resultreflects evaluated code up to the error.New Testing Infrastructure 🏗️
This PR also adds exercise mocking functions that let us create mock exercises without having to write and evaluate a tutorial Rmd. This simplifies testing and lets us directly test
render_exercise()andevaluate_exercise(). I focused mostly on testingrender_exercise(), so we'll likely want to increase testing onevaluate_exercise()in the near future.Exercise Checker for Debugging 🚫 🐛
As part of this testing infrastructure, I added a new internal function
debug_exercise_checker(). It serves as a counterpart todebug_event_recorder()and may be helpful to tutorial authors who are trying to write custom error checking functions.Here's a small reprex. By setting the default
exercise.checkertodebug_exercise_checker, Submit Answer returns the values of the arguments expected by a custom exercise checking function.PR task list:
devtools::document()