Skip to content

Commit

Permalink
Merge pull request #177 from jhudsl/student-config
Browse files Browse the repository at this point in the history
Attempt at student config
  • Loading branch information
avahoffman authored Dec 21, 2022
2 parents 11630f2 + ad30bcd commit 49fc970
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 4 deletions.
24 changes: 20 additions & 4 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ jobs:
toggle_render_preview: "${{ env.RENDER_PREVIEW }}"
toggle_docker_build: "${{ env.DOCKER_BUILD }}"
rendering_docker_image: "${{ env.RENDERING_DOCKER_IMAGE }}"
render_student_guide: "${{ env.RENDER_STUDENT_GUIDE }}"
dockerfiles_changed: steps.verify-changed-files.outputs.files_changed

anvil-library-build:
Expand Down Expand Up @@ -155,6 +156,21 @@ jobs:
id: bookdown
run: Rscript -e "bookdown::render_book('index.Rmd', output_format = 'all')"

# Render a student guide if specified. This is a bit clunky because
# Bookdown does not work well if the files aren't named as such in the
# root directory
- name: Run student guide render
if: ${{needs.yaml-check.outputs.render_student_guide == 'yes'}}
id: student_guide
run: |
mkdir tmp1
mv _bookdown.yml _output.yml tmp1
mv student-guide/_bookdown.yml student-guide/_output.yml .
Rscript -e "bookdown::render_book('index.Rmd', output_format = 'all')"
mv _bookdown.yml _output.yml student-guide
mv tmp1/_bookdown.yml tmp1/_output.yml .
rm -r tmp1
# Run TOC-less version
# Rendered content for Leanpub and Coursera is very similar.
# This job creates a shared scaffold for both.
Expand Down Expand Up @@ -195,13 +211,13 @@ jobs:
- name: Build components of the comment
id: build-components
run: |
course_name=$(head -n 1 _bookdown.yml | cut -d'"' -f 2| tr " " "-")
course_name=$(head -n 1 student-guide/_bookdown.yml | cut -d'"' -f 2| tr " " "-")
bookdown_link=$(echo "https://htmlpreview.github.io/?https://raw.githubusercontent.com/$GITHUB_REPOSITORY/preview-${{ github.event.pull_request.number }}/docs/index.html")
tocless_link=$(echo "https://htmlpreview.github.io/?https://raw.githubusercontent.com/$GITHUB_REPOSITORY/preview-${{ github.event.pull_request.number }}/docs/no_toc/index.html")
docx_link=$(echo "https://github.com/$GITHUB_REPOSITORY/raw/preview-${{ github.event.pull_request.number }}/docs/$course_name.docx")
student_docx_link=$(echo "https://github.com/$GITHUB_REPOSITORY/raw/preview-${{ github.event.pull_request.number }}/student-guide/$course_name.docx")
echo ::set-output name=bookdown_link::$bookdown_link
echo ::set-output name=tocless_link::$tocless_link
echo ::set-output name=docx_link::$docx_link
echo ::set-output name=student_docx_link::$student_docx_link
echo ::set-output name=time::$(date +'%Y-%m-%d')
echo ::set-output name=commit_id::$GITHUB_SHA
echo ${{steps.commit.outputs.changes}}
Expand All @@ -216,7 +232,7 @@ jobs:
Re-rendered previews from the latest commit:
- See [preview of Bookdown here](${{ steps.build-components.outputs.bookdown_link }})
- See [preview of Coursera/Leanpub version here](${{ steps.build-components.outputs.tocless_link }})
- Download the [preview of .docx file](${{ steps.build-components.outputs.docx_link }})
- Download the [preview of the Student Guide .docx file](${{ steps.build-components.outputs.student_docx_link }})
_Updated at ${{ steps.build-components.outputs.time }} with changes from ${{ steps.build-components.outputs.commit_id }}_
edit-mode: replace
Expand Down
16 changes: 16 additions & 0 deletions .github/workflows/render-all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ jobs:
toggle_leanpub: "${{ env.RENDER_LEANPUB }}"
rendering_docker_image: "${{ env.RENDERING_DOCKER_IMAGE }}"
toggle_quiz_check: "${{ env.CHECK_QUIZZES }}"
render_student_guide: "${{ env.RENDER_STUDENT_GUIDE }}"

anvil-library-build:
name: AnVIL Library Build
Expand Down Expand Up @@ -73,6 +74,21 @@ jobs:
run: |
Rscript -e "bookdown::render_book('index.Rmd', output_format = 'all');
file.copy(from = 'assets', to = 'docs/assets', overwrite = TRUE)"
# Render a student guide if specified. This is a bit clunky because
# Bookdown does not work well if the files aren't named as such in the
# root directory
- name: Run student guide render
if: ${{needs.yaml-check.outputs.render_student_guide == 'yes'}}
id: student_guide
run: |
mkdir tmp1
mv _bookdown.yml _output.yml tmp1
mv student-guide/_bookdown.yml student-guide/_output.yml .
Rscript -e "bookdown::render_book('index.Rmd', output_format = 'all')"
mv _bookdown.yml _output.yml student-guide
mv tmp1/_bookdown.yml tmp1/_output.yml .
rm -r tmp1
# This checks on the steps before it and makes sure that they completed.
# If the renders didn't complete we don't want to commit the file changes
Expand Down
10 changes: 10 additions & 0 deletions 09-student_guide.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

# Student Guide

## Activity One

You might want to create a student guide that contains a different subset of Rmd files from your book, or renders to a different output format (e.g. word document). You can specify the output and Rmd files that will be used for the student guide using the `_output.yml` and `_bookdown.yml` files in the student-guide directory.

## Activity Two

Steps of the guide could go here.
3 changes: 3 additions & 0 deletions _bookdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,6 @@ language:
ui:
chapter_name: "Chapter"
output_dir: "docs"
output:
bookdown::html_book

3 changes: 3 additions & 0 deletions config_automation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ render-bookdown: yes
render-leanpub: no
render-coursera: no

##### Rendering of student guide (if applicable)
render-student-guide: yes

# What docker image should be used for rendering?
# The default is jhudsl/course_template:main
rendering-docker-image: 'jhudsl/course_template:main'
13 changes: 13 additions & 0 deletions student-guide/_bookdown.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
book_filename: "Course_Name"
chapter_name: "Chapter "
repo: https://github.com/jhudsl/AnVIL_Template/
rmd_files: ["index.Rmd",
"09-student_guide.Rmd",
"References.Rmd"]
new_session: yes
bibliography: [book.bib]
delete_merged_file: true
language:
ui:
chapter_name: "Chapter"
output_dir: "student-guide"
2 changes: 2 additions & 0 deletions student-guide/_output.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bookdown::word_document2:
toc: true

0 comments on commit 49fc970

Please sign in to comment.