Using Git to get assignments for grading

Overview

For the basics, look at the instructions for student checkins. Note that these instructions assume a bash shell, with commands run in a terminal window (e.g. ssh or putty) on the gl.umbc.edu linux system.

Variables

First create some shell variables to make the later commands easier.

WORK=grading-directory
REPO=base-directory-for-class-repositories
TAG=tag-for-assignment-to-grade

Initial checkout

Instead of checking out a single user directory, you want a copy of all of the directories

mkdir $WORK
cd $WORK
for i in $(<$REPO/students.txt); do git clone $REPO/$i.git; done

Getting student work

To get the latest work from all students (e.g. to refer to their work in office hours)

cd $WORK
for i in *; do (cd $i; git checkout master; git pull); done

To check which students forgot to tag their work

cd $WORK
for i in *; do (cd $i; git rev-parse -q --verify "refs/tags/$TAG" >/dev/null || echo $i no $TAG tag); done

To set up a new grading branch for whatever they tagged as their submission for the current assignment

cd $WORK
for i in *; do (cd $i; git pull; git checkout $TAG -b grade-$TAG); done

To grade a particular student, and locally commit grading rubric, but not push it to the student yet

cd $WORK/studentID
git checkout grade-$TAG   # switch to grading branch for this assignment
git log                   # see when they committed
# create grade.txt with grades for this assignment
git add grade.txt         # tell git that this file needs to be committed
git commit -m "$TAG grades"

Pushing grades

The above only creates grade files on a branch in the TA's local copy. For the student to see the graded rubric (if this is the way you are communicating grades to the students), you need to merge it back into their master branch and push it to the server:

cd $WORK
for i in *; do 
  cd $WORK/$i                           # switch to student's repository
  git checkout master                   # switch to master branch
  git pull                              # get their latest changes
  git merge grade-$TAG -m "$TAG grades" # merge grade branch back into master
  git push origin master                # push grades so student can see them
done

Remote access

It is possible to access the student repositories from another system instead of being logged directly into gl.umbc.edu. Unfortunately, I only have rough instructions for that.

Option 1:

Install an AFS driver (e.g. OpenAFS). Use your UMBC credentials to obtain an AFS token to mount /afs/umbc.edu. Follow other directions as for the GL system.

Note that I no longer use this method on my laptop because the OpenAFS driver prevented the laptop from ever sleeping and killed my battery life.

Option 2:

Add TAusername@gl.umbc.edu: to the beginning of the repository path, and use command-line git commands on your local system. You will need to change the $(<$REPO/students.txt) instruction to use a local copy of the student list. You will also need re-enter your password for each clone, push or pull operation.

Option 3:

Use the same ssh-based repository path with a git graphical user interface. SourceTree runs on Windows and Mac, can deal with ssh-based repositories and will remember an ssh password. GitHub desktop cannot deal with an ssh repository that requires a password, but you can launch a "git shell" from the github program, follow Option 2 for cloning, then use the GUI for any add or commit operations. You will still need to use the git shell again for any operation that does require a password (push or pull).