Auto grading script

I’m now teaching a section of sixth grade technology class. In a nutshelll – it’s typing. Not to demean that – I believe good typing skills are essential. They certainly have served me well.

I’m using moodle to collect everything from my students, because I can’t stand using paper – I’ll lose it faster than you can imagine. Still, that left me with the unpleasant task of grading these files. Essentially, I end up with about 20 files that should be exactly identical to the key. At first, I thought I would use Word’s built in compare documents feature. While this certainly would be better than grading by hand, it was tedious and the results were still difficult to translate into a reasonable grade.

After being recently introduced to the for loop, I figured that a bash script had to be the answer. I wrote this script last night and revised it throughout the day today. I learned how to pass arguments from the command line thanks to help from my brother. He also helped me clean up the code a bit, for which I’m grateful.

For this script to work, you need to have docx2txt installed as well as dwdiff. if you’re on ubuntu, it’s just a simple “sudo apt-get install” and you’re on your way.

Usage –

autograde /path/to/files/to/be/graded /path/to/answerkey.txt

This will output files with a percentage common, inserted, and deleted all in the filename. Yeah, it makes a huge filename, but I like having all that info right there.

Feel free to modify it for your own needs or make suggestions on how I can improve it. For what it’s worth, the usage statement is correct in the actual script, but somehow I can’t get the arguments to display in wordpress.


# first check if there are two arguments:
if [ "$#" -ne 2 ]; then
    echo "usage: $0   "

#checks to see if $GRADEDDIR exists and creates it if it does not
if [ ! -d "$GRADEDDIR" ]; then
        mkdir -p "$GRADEDDIR"

#converts MS Word format to plain text
for UNGRADED in $WORKDIR/*.docx; do $UNGRADED;

#compares text files against key and outputs to .GRADED.txt file
for GRADED in $WORKDIR/*.txt; do

#renames .GRADED.txt file with information dwdiff writes to end of file
for RENAMED in $WORKDIR/*.GRADED.txt; do
mv $RENAMED "$RENAMED.$(grep "old:" $RENAMED).txt"

#moves graded files to graded directory
for MOVED in $WORKDIR/*old:*.txt; do

#removes ungraded.txt files from $WORKDIR
rm $WORKDIR/*.txt

I’m really enjoying learning how to script. This one will save me many hours of valuable time. The next thing I want to do is to have the script echo the proper usage when entered without arguments. That’s probably just a few google searches away, but that’s for another day.  (done). Next I want to see if there’s a way I can save the color output. I can do output in color using “dwdiff -c” within the script, but I need to figure out if there’s a way that I can save that color coding into a file format that retains the color information so I can give it to students as feedback. Thus far, I have only succeeded at seeing the color within the terminal window.

Abstaining from political topics

At the moment, I’m going through a bit of a purging, as a friend of mine likes to call it. Specifically, I’m not allowing myself to log into facebook for any reason – I even deactivated my account. I am also preventing myself from posting anything anywhere online about anything political until November 1.

Why? It was just getting the better of me. I’ll get back to shouting out my opinions later on, but right now, I just need the break.

Start mythtv from remote control

I’ve been trying to find a way to start mythtv from the remote control for quite a while now. While I love Mythtv, it is definitely not ready for mainstream yet. I don’t mind tinkering with stuff – ok, I actually really enjoy it. My family however, does not appreciate it when something goes wrong and I’m not there to fix it.

It’s rare when the frontend crashes, but it does happen. My usual solution is just to vnc into the box and restart it (no keyboard or mouse, it’s an htpc hooked up to our tv). Although not too difficult, that’s really more of a pain than you can reasonably expect your family to endure.

First, I had to figure out why lirc wasn’t working every time the system rebooted. After much searching, it turns out I had to comment out the following lines in /lib/udev/rules.d

ACTION=="add", KERNEL=="lirc[0-9]", RUN="/etc/init.d/lirc restart udev"
ACTION=="remove", KERNEL=="lirc[0-9]", RUN="/etc/init.d/lirc stop udev"

Upon rebooting, that solved the problem of no lirc. That was a relief, because prior to this edit, I had to restart lirc and then restart the front end. That’s just a pain.

I went about things a little backwards and went ahead and mapped a button to a script that was executed via irexec. I added the following to my ~/.lircrc

        remote = mceusb
        Button = Blue
        prog = irexec
        repeat = 0
        config = /usr/local/bin/

Naturally, you’ll want to change that to whatever matches your remote, button and script name that you’re using.

After a great deal of searching, experimentation, and learning how to use “if” in a bash script, I came up with the following script:

if [ $LOGNAME == "root" ]; then
echo "Hello root, you should be running this script as \"mythtv\" user, goodbye.";

if [  $(pidof mythfrontend.real) ]; then
echo "mythfrontend is already started"; else
echo "starting mythfrontend"
DISPLAY=:0 mythfrontend > /var/log/mythtv/mythfrontend.log 2>&1 &

I modified a script on the mythtv wiki to come up with one to meet my needs. I saved it as and did a

sudo chmod +x

After that, I realized that this wasn’t going to do me any good if I couldn’t get an irexec daemon to always run. I tried messing with the init.d, but my script writing skills aren’t quite up to that point yet. Instead, I just added this line at the beginning of /usr/bin/mythfrontend


Then, I wrote the following script, named it startirexec and then chmodded it +x :

if [ ! $(pidof irexec) ]; then
echo "starting irexec daemon"
irexec -d
else echo "irexec already started"

Now whenever I press the right button on my remote, the frontend starts if it isn’t started, and nothing happens if it’s already started.

I’m a beginning scripter, so let me know if there’s anything I can do more efficiently or elegantly.

Passing of a loved one

Recently, I learned that my Aunt Phyllis had passed away. My dad was the youngest of 10 kids, and my Aunt Phyllis was the oldest, so she was old enough to be my grandmother. While her death did not come as a shock, I was still saddened. Even though I hadn’t seen her in about 5 years, she will be missed.

After I heard, I couldn’t help but think back of all the memories I have of her. All of the memories I can think of are good ones.

Now that’s something worth blogging about.

Taking a break from politics & social networking

I’ve never really had much use for social networking. I deleted my myspace page about 2 years ago, and never really did much with facebook. This summer, I started to dabble more and sort of enjoyed it.

Alas, it was not to be. I ended up with about 150 or so friends, most of whom I knew a very long time ago and none of whom really know me very well. Most didn’t know me all that well when they did know me. Let’s just say I got frustrated by the small mindedness that exists.

I don’t care whether or not you agree with me, but one should always be open to the possibility that you might be wrong. If you can’t do that, I’m not interested in having political discussion with you. I most certainly believe I might be wrong in some cases, despite strong beliefs and opinions.

So anyway, for the next while, I’m going to try to get back to blogging about things that really matter – like food and family.

Has it been that long?

Hard to believe that it’s been April since my last post. I’ll see if I can do better about that. Just found this app that lets me post from my iphone. Perhaps I’ll be able to do more frequent, shorter posts. Kind of like this one.

A break that went my way

Today as I was reviewing some of the material for the unit I’m still teaching for entry 1, I stumbled across a wonderful thing – a useable video for my portfolio. I had only taken it as a means of peer critique. I took a video of student performance (using miniDV camera captured it straight to my laptop), converted it into wmv format (prefer divx, but I windows media player is the only thing that I could be certain would be on all of the school computers), got the site up and running using my googlepages account and then created a free domain name so the students could use it (hooray for!). I then used a site to create a web based evaluation form that emailed me the results. Its a pretty sweet little setup.

At any rate, I was reviewing the video after the fact today and thought – crap, I can use this! This means that as of this moment, I’m almost halfway finished with the commentary for entry 1 at this moment and will have it finished before I go to bed tonight (miles to go before I sleep).

Now I can spend the rest of this week doing heavy editing and physical assembly of the portfolio instead of sweating it out to actually continue teaching the unit and writing the commentary at the 11th hour. Now I’m looking pretty comfortable with sending it next day air on Wednesday.

It’s nice to have a break go my way, I really needed this . . .

In unrelated news, I have two posts that I’ve had in my drafts folder for a while. One is titled “if life were more like star trek” and the other “concert etiquette or lack thereof.” The star trek one may not see the light of day, but the concert etiquette one definitely will. Just give me time.

2 Down, 2 to Go

Entry 4 (Documented Accomplishments: Contributing to Student Learning): Done. Simply needs to be re-read and edited as time allows.

Entry 3 (Demonstrating and Developing Musicianship): No change since last post. It’s on the docket for Thursday of this week.

Entry 2 (Delivering Instruction): Done.

Entry 1 (Planning): Taught first lesson of new unit, filmed first video. Went rather well. Since I’m on spring break now I’ve got time to actually write the rest of the unit, then film the 2nd video on the 28th or so, write the commentary that night, give it to a reader on the 29th – make changes, have it at FedEx by 6pm on the 29th.

1 Down, 3 to go

I now have 1 of my 4 portfolio entries finished for all practical purposes. I have recorded the video, edited, and burned it to DVD, as well as writing my 11 page commentary for Entry 2. This entry documents my ability to effectively deliver instruction. That one is done. Here’s where I stand with the rest:

Entry 4 (Documented Accomplishments: Contributing to Student Learning): I’ve done all of the items needed for this, just need to write the commentary and physically gather the evidence. I plan to do this on Saturday and Sunday.

Entry 3 (Demonstrating and Developing Musicianship): I have recorded, edited, and burned to DVD my teaching video for this entry, but still need to write the commentary. That’s the project for Thursday and if need be, Friday (though I’d rather watch Battlestar Galactica).

Entry 2 (Delivering Instruction): Done. I have given this to two different national board certified teachers and asked them to critique it for me. Unless they recommend a major rewrite, all I should have to do is edit.

Entry 1 (Planning): Major problem. The videos I’ve shot thus far suck. The unit I planned revolves around a piece of literature that frankly, turned out to be of lesser quality than I intiially thought. This means I have to start from scratch. The problem is next week is spring break and the portfolio is due in Ewing, NJ on March 31. Looking on the bright side, I have a week to thoroughly plan the unit, but only 7-8 class periods to execute the unit, record two videos each three minutes of length (before and after the unit) and write the commentary. Looks like FedEx will be getting some big bucks out of me that week.

So that’s where I stand at the moment. It’s not where I’d like to be, but at least I know where I am.