☔️ autograder for apsc 160 💤
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
LICENSE.md
README.md
grd.py
in.txt
keywords.txt
out.txt
sample.c

README.md

grd

grd is a simple tool to help me grade C programming labs.

Basics

Requirements

  • gcc 5.3
  • Python 3.5

Probably works on earlier versions too. Definitely does not work on Python 2.

Installation

$ cd ~/stuff/
$ git clone https://github.com/eyqs/grd.git/

Preview

$ cd ~/stuff/grd/
$ python grd.py
$ python grd.py -c
$ python grd.py -a

Usage

$ cd ~/labs/
$ ls
lab1.c  Source.c    'Source (1).c'
$ cp ~/stuff/grd/*.txt .
$ ls
in.txt  keywords.txt    lab1.c  out.txt Source.c    'Source (1).c'
$ vim in.txt
$ vim out.txt
$ python ~/stuff/grd/grd.py
$ python ~/stuff/grd/grd.py -a

About

grd stores a list of all the files in your current directory. When a new file appears, grd adds that file to the end of the list. You can move around with h, j, k, l between different files, so you can quickly grade a new lab simply by downloading the source file to your current folder and pressing l in grd to move to the last-added file.

grd works best when opening python grd.py and python grd.py -a at the same time, to show the lab's output and source code simultaneously. Actually it basically only works like that, so remember to open two windows when using grd, and always skim through the source code before compiling! It is your responsibility to make sure that your students don't make you run system("rm -rf /home") because you didn't read their code beforehand.

grd was developed to help when grading in Blackboard Learn, so you can move through a list of students' labs, download a lab, press l in grd, grade that lab, and move on to the next student's. No more mass imports or exports, no more time wasted typing in the same test cases over and over, no more waiting for Visual Studio to open a new lab, because grd is here!

Options

Running python grd.py without any options will print out the lab, equivalent to running cat lab1.c but with keywords highlighted.

Running python grd.py -c will compile and run the lab, equivalent to running gcc lab1.c -o a.out && ./a.out.

Running python grd.py -a will compile and run the lab automatically, based on the cases in the input and output files.

Any following command line options are passed to the compiler, so running python grd.py -c -lm is like gcc lab1.c -o a.out -lm && ./a.out.

Configuration

You can adjust the names of the input, output, keywords, and executable files by adjusting INFILE, OUTFILE, KEYFILE, and AOUT in grd.py.

Each input and output case must end with a line containing only --- (three hyphens), even the last one. Each input case is fed literally into the compiled lab, so make sure you include newlines where you need them. Avoiding infinite loops is your responsibility (press Ctrl+C to stop them).

Each output case contains a single keyword on each line, which is actually not matched as a word, so 1 will colour 10 and int will colour ninth. You can have multiple lines for each case and all of them will be coloured. You may also need to escape certain sequences such as \. or \?.

Each keyword colour contains a series of keywords on each line, which are actually matched as words, so 2 will colour (2} but not 02 and ubc will colour alumni.ubc.ca but not pubco. You can change what counts as a word boundary by adding or removing characters to ENDS in grd.py.

Bugs

There's lots of them. Sorry. You can add an issue to this repo if you want.

Probably the worst one is that the regex word-matching is horrible, and a match separated by a space from another match will not be highlighted.

Another bad one is trying to open basically every file in the directory. It's best to start in an empty directory and only add C source code to it.

Not a bug: not having an autograder work with Visual Studio. No thank you.

History

I was a teaching assistant for the University of British Columbia's APSC 160: Introduction to Computation in Engineering Design in 2015 Winter Term Two, where they made me grade 79 labs a week.

Compiling all those labs manually was a pain, so I automated that.

Testing all those labs manually was a pain, so I automated that.

Checking that everybody included their UBC emails with their lab was a pain, so I highlighted keywords with different colours and now I'm happy. It works for me and I don't care if it works for you!

License

Copyright © 2016 Eugene Y. Q. Shen.

grd is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

grd is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License in LICENSE.md for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.