AlexsLemonade / AlexsLemonade/exrcise
Feature idea: Allow some code a block to be retained/uncommented
- Dominant language
- R
- Stars
- 4
- Forks
- 0
- PR merge metrics
- No merged PRs in 30d
Description
While #2 addresses the idea of leaving comments in code block as a guide to people completing the notebook, sometimes it may be desirable to have some working code retained, or a skeleton of the working code included, and _not_ commented out. To accomplish this, it may be nice to have a way to designate lines that should be retained.
[`learnr`](https://rstudio.github.io/learnr/index.html) accomplishes something like this with [separate solution blocks](https://rstudio.github.io/learnr/exercises.html#Hints_and_Solutions), but that seems too heavyweight for this application, and potentially allows drift between the exercise block and the solution.
In the Jupyter world, [`nbgrader`](https://nbgrader.readthedocs.io/) instead uses [specific comments](https://nbgrader.readthedocs.io/en/stable/user_guide/creating_and_grading_assignments.html#autograded-answer-cells) to designate the start and end of a solution section, retaining the code outside those comments, and replacing only the code within the comments with a code stub:
`### BEGIN SOLUTION` and `### END SOLUTION`. This solution has the advantage that the solved code chunk will run in the original document as a check that it is correct behaving as intended.
Under this scheme code of the following form:
```
### BEGIN SOLUTION
plot(data)
### END SOLUTION
```
would become:
```
### YOUR CODE HERE
```
or similar.
One other alternative is an indicator that a specific line should be replaced by commenting at the end of the line that would indicate that particular line should be replaced.
This could look like this:
```
plot(data) ### SOLUTION
```
to get the same result as above.
One other implementation might include a way to strip a commented line. Something like this:
```
### BEGIN SOLUTION
plot(data)
#> plot()
### END SOLUTION
```
could turn into:
```
plot()
```
Contributor guide
No contributing guide indexed for this repository
Research direction
The issue names no files, tests, or entry points. First resolve whether solution blocks, line markers, or stripping commented lines is the intended syntax, then locate the repository's code-chunk transformation path and add tests covering the chosen markers and the resulting exercise code.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- jupyter, r
- Domain
- developer-experience
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100