diff --git a/README.md b/README.md index 5f7f3cc..448d50c 100644 --- a/README.md +++ b/README.md @@ -3,24 +3,23 @@ Simple scripts to automate a bit of the homework grading process for instructors and TA's. Scripts include: -* ```batch_submit_issues.sh``` +* `batch_submit_issues.sh` ## batch_submit_issues.sh -This script will batch submit the homeowrk grading issues for all github repos (student homework repos) in the current path. This is to be used after you have graded all the homework repos on your local machine by modifying the ```ISSUE_TEMPLATE.md``` file that is automatically generated in the homework repos. It eliminates the need to manually create an issue and fill out the grade online in github/github classroom. +This script will batch submit the homework grades (github issues) for all the student homework repos. The script should be placed in the parent directory where you have all the homework repos stored locally. Grade all the homeworks by modifying the `ISSUE_TEMPLATE.md` file in each repo. Then, run the shell script _once_ in the parent directory (one level above all homework repos) to batch submit all the grades. See the __Usage__ section below for more details. -### Installation of Required Tools +#### Installation of Required Tools -The shell script relies on the ``` github/hub ``` tool to create issues by command line. Follow the [installation instructions] (https://github.com/github/hub) found at their github page to install the tool on your device. +The shell script relies on the `github/hub` tool to create issues by command line. Follow the [installation instructions](https://github.com/github/hub) found at their github page to install the tool on your device. -User documentation for the Hub tool can be found [here] (https://hub.github.com/hub.1.html). It extends many git commands and also provides new commands of its own. +User documentation for the Hub tool can be found [here](https://hub.github.com/hub.1.html). It extends many git commands and also provides new commands of its own. -### Usage +#### Usage 1. Download all the homework repos to your local machine. When grading the homework, modify the ```ISSUE_TEMPLATE.md``` file in each repo rather than making an issue through the github webiste. -2. Copy ```push_hw_issues.sh``` into the parent directory of all the homework repos. -3. Modify the ```title``` variable in the shell script as the issue title you want to specify, e.g. "SEDS HW 1 Grade". -4. Once you are ready to send out the issues to _all_ the students, simply run the shell script. +2. Copy ```batch_submit_issues.sh``` into the parent directory of all the homework repos. +3. Decide on your title for the issues, e.g. "SEDS HW1 Feedback" +4. Once you are ready to send out the issues to _all_ the students, simply run the shell script using your issue title as the first and only argument. Don't forget to use quotes to encapsulate the argument if it has spaces. +_NOTE: only student homework repos can be located in this directory. The shell script moves into each sub-directory (homework repo) and tries to submit an issue. It will do this even for directories that are not github repos._ _NOTE: the hub command for creating issues will automatically copy the url of the new issue to your computer's clipboard. This can be avoided by using the alternative command provided in the script. However, you will get an error as the function tries to print the url to your terminal. The issue will still be created, but it will print the url and followed by 'No such file or directory'._ - - diff --git a/batch_submit_issues.sh b/batch_submit_issues.sh index ff0eb39..33589ba 100644 --- a/batch_submit_issues.sh +++ b/batch_submit_issues.sh @@ -1,32 +1,55 @@ #!/bin/bash -# Change variable 'title' to set a common name of all issues. -title="SEDS HW 1 Grade" +# +# This script will batch submit the homeowrk grading issues for all github +# repos (student homework repos) in the current path. This is to be used +# after you have graded all the homework repos on your local machine by +# modifying the ```ISSUE_TEMPLATE.md``` file that is automatically generated +# in the homework repos. It eliminates the need to manually create an issue +# and fill out the grade online in github/github classroom. +# + +# set variable 'title' to set a common name of all issues. +if [ "$1" != "" ]; then + title="$1" + echo "using '$title' as the issue title" +else + echo "usage: $0 " + exit 1 +fi + +# get a temporary file for preparing the issue text +tmpfile=$(mktemp /tmp/bash_submit_issues.sh.XXXXXXXXXX) || { echo "failed to create a tmp file"; exit 1; } # Issues will be sent for all github repos (homework repos) in this parent directory. # Alternatively, you can set a leading path to all the homework repos on your local machine. hwdir="`PWD`/*/" # loop through each student's homework repo in this directory -for i in $hwdir +for dir in $hwdir do -echo $i -cd $i + echo $dir + cd $dir -# A temporary file is needed to specify both issue title and content at once. -# The title needs to be the first line separated by an empty line from content. -echo $title > temp_issue_header.txt -echo "" >> temp_issue_header.txt -cat ISSUE_TEMPLATE.md >> temp_issue_header.txt + if [ ! -e ISSUE_TEMPLATE.md ]; then + echo "WARNING: unable to find an ISSUE_TEMPLATE.md file, skipping this directory..." + continue + fi -# removing the temporary file -`mv temp_issue_header.txt ISSUE_TEMPLATE.md` + # A temporary file is needed to specify both issue title and content at once. + # The title needs to be the first line separated by an empty line from content. + echo $title > $tmpfile + echo "" >> $tmpfile + cat ISSUE_TEMPLATE.md >> $tmpfile -# creating the issue, url of new issue will be copied to your computer clipboard -# using the alternative command will not copy to your clipboard, but will print an error line insted -`hub issue create -c -F ISSUE_TEMPLATE.md` -#`hub issue create -F ISSUE_TEMPLATE.md` # alternative command + # creating the issue, url of new issue will be copied to your computer clipboard + # using the alternative command will not copy to your clipboard, but will print an error line insted + hub issue create -c -F $tmpfile + # uncomment below for debugging + # cat $tmpfile + # removing the temporary file + rm $tmpfile done diff --git a/print_grade.sh b/print_grade.sh new file mode 100644 index 0000000..96c9518 --- /dev/null +++ b/print_grade.sh @@ -0,0 +1,12 @@ +# A quick utility script to print the grade from each repo +# after the grade has been filled in the ISSUE_TEMPLATE.md +# file. + +for d in ls -d */ +do + # print directory name + echo $d + # prints the 9th line of the ISSUE_TEMPLATE.md file. + # assumes the grade is on the 9th line of the file. + sed '9q;d' $d/ISSUE_TEMPLATE.md +done