collate_hw_answers: collate answers given in a bunch of pull requests

Description Usage Arguments Examples

Description

Given a lot of pull requests for a particular homework and the name of the homework file, this function cycles over the pull requests and for each 1) checks out the commit associated with the pull request, 2) makes a temporary file that is like the committed homework, but it includes some additional variable assignments in it and some code at the bottom, 3) renders that file to an html that goes into the /tmp directory (might not work on a PC), 4) saves the resulting answers in a data frame that gets saved by saveRDS in /tmp with the name githubuser-homework_basename (whatever those are for the particular commit that we are doing this for), 5) at the end it goes back and rbinds all those data frames together and returns them. We have to go through all this rigamarole because knitr knits stuff in a totally separate R process.

Usage

1
2
collate_hw_answers(pr, hw_path, out_dir = ".rr_tmp", InsertPattern,
  InsertDrift)

Arguments

pr

The data frame of pull requests like that produced by grab_open_pull_requests. You should be sure to restrict it to just the lines that relate to the particular homework you want to be squashing out.

hw_path

The path to the homework set to be collating results for.

out_dir

The directory to write all the (temporary) output to.

InsertPattern

The text pattern (regex) in the hw_path file at which you want to insert (+/- the InsertDrift lines) the variable assignments for rr_github_name and rr_commit.

InsertDrift

The number of lines up or down from the InsertPattern line that you want to actually to insert the lines.

Examples

1
2
3
4
# imagine we are in the rep-res-course repository at the top level
pr <- grab_open_pull_requests()
pr <- pr[pr$branch == "ex-test", ] # restrict focus to just those on the ex-test branches
ans <- collate_hw_answers(pr, hw_path = "exercises/trial_homework.rmd", InsertPattern = "```\\{r insert-ids,", InsertDrift = 1) #

eriqande/rrhw documentation built on May 16, 2019, 8:47 a.m.