Skip to content

Commit

Permalink
update handouts
Browse files Browse the repository at this point in the history
  • Loading branch information
zkamvar committed Nov 20, 2023
1 parent e7279ca commit d3dcb2f
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
31 changes: 31 additions & 0 deletions vignettes/intro-episode.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,37 @@ We can see that the chunks now have names, but the proof is in the rendering:
intro$show()
```

## Handouts

**NOTE: This will change in version 0.8.0**. It is possible to generate a code
handout by using the `$handout()` method. This will grab all challenge blocks
along with any code block that contains `purl = TRUE` and strip out everything
else. You can also specifiy `solution = TRUE` to include the solutions:

```{r handout-basic}
writeLines(intro$handout())
writeLines(intro$handout(solution = TRUE))
```

I want to show that the `purl = TRUE` method actually works, so I'll take the
`chunks` from above and include the last one:

```{r handout-purl}
xml2::xml_set_attr(chunks[chunk_names == "pyramid"], "purl", TRUE)
writeLines(intro$handout())
```

The `path` arguments allows this to be written to a file so that it can be
converted to a script using `knitr::purl`

```{r handout-file}
tmp <- tempfile()
intro$handout(path = tmp)
writeLines(readLines(tmp))
```

## Reset

One of the things about manipulating these documents in code is that it is
possible to go back and reset if things are not correct, which is why we have
the `$reset()` method:
Expand Down
11 changes: 11 additions & 0 deletions vignettes/intro-lesson.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,16 @@ to_check <- c("page", "code", "output", "images", "warning", "error")
wb_lesson$summary(collection = c("episodes", "built"))[to_check]
```

## Handouts

This is another method wrapped from the Episode method, where it combines the
output into a single file and prepends the Episode title before each section:

```{r handouts}
writeLines(wb_lesson$handout())
```


## Creating a New Lesson with Child Documents

If you are unfamiliar with the concept of child documents, please read
Expand Down Expand Up @@ -294,6 +304,7 @@ glue("The lineage of {path_rel(parent, start = rel)} is:
{pretty_lineage}")
```


## Jekyll Lessons

There are some methods that are specific to lessons that are built with Jekyll.
Expand Down

0 comments on commit d3dcb2f

Please sign in to comment.