So, in the last post, I introduced a little Python script that I use to process the output of Scantron forms. So how do you go about actually using it?
Python
The script is written in Python. I decided to pick it up a few years ago as a way to get back into simple computer programming and haven’t looked back. I use it a lot for little projects like this one and for some simple applications in my group’s publications (like nonlinear curve fitting). Unfortunately, Python’s not a compiled language so you’ll have to have it installed in order to use the script, which is written in Python 3, not Python 2.[1. Right now a slow transition is taking place from Python 2 to 3. There’s still a lot done in 2, but I chose to learn 3 because my need for external packages is limited. Also, Python 3 is the scripting language for Blender, which will be the subject of many future posts.]
Python is free and installation is fairly straightforward if you don’t have it already. You can get it from Python.org directly without much trouble. However, before doing that please note that you’ll also need the NumPy module. The easiest way to do this is probably to skip installing standalone Python and instead install one of the Scientific Python Distributions listed on the SciPy site. I’ve used Anaconda in the past without much trouble.[2. I’m a Mac user, and right now I install Python through the wonderful Homebrew. Adding NumPy is easy using pip3. This is the easiest way to do this if you’re at all comfortable on the command line.] Again, make sure you’re installing Python 3, not 2.
Running the script
Once you have Python (and NumPy) installed, the script is easy to run. I’m afraid everything will be done on the command line (using Terminal on a Mac or the Command Prompt on Windows), but there’s not a lot to it. Set up a folder with four things (I’ve uploaded samples if you’d like to test this out):
- The script file
- The raw MC output (example)
- The grading key (example)
- Optional: the test scramble (example)
Open the command prompt and navigate to the folder (“cd” to change directories, etc.). Running the script is then pretty simple. Assuming the Python 3 executable is in your path, it’s as simple as typing
python3 grade_mc_2.py
and then following the prompts. Here’s what this looks like on my computer:
Once it’s run, you should end up with an output file like this one, assuming all goes well. The script will also output the following to the command line:
Check: the Scantron key (uniqueID = 00000000) scores 80.00.
This is a little internal check. The key is always submitted along with the student forms, and obviously should get a perfect score according to the key file given to the program. If it doesn’t, there must be a typo somewhere.
If this isn’t working, feel free to leave a comment! In the next post, I’ll go through the formats of these files.