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
Multi-language chunks and chained setup chunks #390
Merged
Merged
Conversation
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
schloerke
reviewed
Jun 17, 2020
inst/tutorials/hello/learnr-folder-for-debug/exercise.knit.html
Outdated
Show resolved
Hide resolved
schloerke
reviewed
Jun 17, 2020
schloerke
reviewed
Jun 17, 2020
schloerke
reviewed
Jun 17, 2020
schloerke
reviewed
Jun 17, 2020
schloerke
reviewed
Jun 17, 2020
schloerke
reviewed
Jun 17, 2020
schloerke
reviewed
Jun 17, 2020
schloerke
reviewed
Jun 17, 2020
schloerke
reviewed
Jun 17, 2020
schloerke
reviewed
Jun 17, 2020
schloerke
reviewed
Jun 17, 2020
schloerke
reviewed
Jun 17, 2020
schloerke
reviewed
Jun 17, 2020
schloerke
reviewed
Jun 17, 2020
schloerke
reviewed
Jun 17, 2020
schloerke
reviewed
Jun 17, 2020
schloerke
reviewed
Jun 17, 2020
schloerke
reviewed
Jun 17, 2020
schloerke
reviewed
Jun 17, 2020
schloerke
reviewed
Jun 17, 2020
schloerke
reviewed
Jul 7, 2020
schloerke
reviewed
Jul 7, 2020
schloerke
reviewed
Jul 7, 2020
cpsievert
reviewed
Jul 8, 2020
cpsievert
reviewed
Jul 8, 2020
cpsievert
reviewed
Jul 8, 2020
cpsievert
reviewed
Jul 8, 2020
cpsievert
reviewed
Jul 8, 2020
cpsievert
reviewed
Jul 8, 2020
cpsievert
reviewed
Jul 8, 2020
cpsievert
reviewed
Jul 8, 2020
cpsievert
reviewed
Jul 13, 2020
cpsievert
approved these changes
Jul 13, 2020
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 fix to last comment
This was referenced Jul 14, 2020
Merged
This was referenced Jul 14, 2020
sjgknight
pushed a commit
to sjgknight/learnr
that referenced
this pull request
Aug 10, 2021
* initial working version of chained setup chunks * fixed a setup chain bug and added error handling for exercise.setup label * better error handling of cycles, and added tests for cycles * addressed some suggestions and handled default exercise.setup case * move knitr setting to rmd, dont process empty chunks * addressing suggestions and fixing issue with losing chunk structure * Update NEWS.md Co-authored-by: Barret Schloerke <barret@rstudio.com> * cleaning up code * Updates: - fixed a bug where exercise checker was not grabbed as character - now storing exercise along with its setup chunks to cache - added some documentation of chaining setup chunks and exercises * More updates: - Restructured exercise cache - Minimized preserved options forwarding to browser to just engine - Better handling of exercise and setup chunks processing in knitr hooks - Better handling of constructing the Rmd for evaluating exercises - Fixed issue with dput_to_string so that it properly retains code structure - Slight enhancement to chained setup chunk docs * Updates: - We longer forward checking code to browser, and instead cache it - The exercise cache now includes the checking code * Update R/initialize.R Co-authored-by: Barret Schloerke <barret@rstudio.com> * Updates: - We only forward hint and solution chunks to browser - We rely on a boolean variable for checking if we need to run versus check - Remove check and code check logic on browser side and use flag for submit button * Updates: - set proper environment for exercise rmd rendering - cleanup of code * remove checker_fn_exists variable and use explicit check instead * change envir_result to envir in exercise.R * variable assignment cleanup for output_file Co-authored-by: Barret Schloerke <barret@rstudio.com> * Merge master
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.
Description
This PR introduces a behavior change as well as minor improvements for exercise and setup chunks and the way they are handled in the backend.
Behavior Additions
exercise.setup = 'label'
exercise.setup = 'label'
exercise.R
now generates anexercise.Rmd
using a duplicate of all the relevant setup chunks.Given these changes, there are some things to consider when constructing lessons with chained setup chunks. For example, only the
exercise.setup
option can be used in order to form a chain between setup chunks and exercises. The-setup
labelling scheme is not considered for chaining purposes (1). When chaining exercises, pre-filled code is used to serve as the setup code for another exercise (2), not user input code.These additions also have several benefits for both reducing repetition for the instructor and a step towards polyglot lessons. First, we retain the same mechanism for providing a setup chunk for an exercise using the
exercise.setup
. Being able to build on setup code can alleviate previously mentioned issues (see #72 and #170) reducing the need to copy-paste previous setup code, which can be tedious. Second, sinceexercise.R
now produces a properexercise.Rmd
which is constructed from raw knitr chunk information (3), it is a BIG step towards multi-language support because we have access to all knitr options, such asengine
(see #213 and #310).Minor improvements
include=FALSE
option is set on setup chunks by default to prevent printing output (if any)exercise.setup = 'label'
will now throw an errorMinimal reproducible example
There is a demo available in the tutorials folder which demonstrates chaining of setup chunks, as well as chaining of exercise chunks with pre-filled code.
Tasks: