fixing moodle

As a PhD student I take pride in doing a job properly. And putting more effort into avoiding work than doing it in the first place. Therefore I am proud to present the sketch of a method to download a (java) assignment from the University of Glasgow's moodle site, run it against a marker, and create a pdf file (via latex) of the output for marking.

This process isn't easy or well polished. It will take a bit of hacking to get it to work for you. But it'll probably save you time over a few weeks of marking. It's hard wired to work on the first assignment for Patrick's ADS2 course.

From moodle, we need two things. The first is a class list, log into the moodle course, view grades, and set the "visible groups" to your tutor group. Then download the webpage (save as...) as class.php in a folder.


The second thing you need are all the files. To grab these, use the tool Download them All! for the firefox web browser. Navigate to the page assignment page, and click "view 999 submitted assignments", and use the "show submitted assignments" field (at the bottom) to put all the submissions on one page.

Now we start Download them all:

Screenshot-ADS2: Exercise 1: A Small Face Book - Mozilla Firefox

And we're given the following box. We need to download all .java and (sometimes) .zip files for this assignment, so we set the "fast-filtering" field accordingly. We also want to specify the file-names to include the url, so we set the "renaming mask" to *curl*_*name*.*ext*. Then click start, and wait for the magic.


If any students have zipped their work, you currently have to unzip it and find the file they should have submitted manually. The name it using the moodle naming convention (obvious from the other files in the directory!).

We now setup the java program and run it. The code is here (file, paste.org), you need to change:
  • class.php to whatever the class-list file you downloaded is called
  • "/home/twak/Downloads/ads2/fims.moodle.gla.ac.uk/file.php/158/moddata/assignment/50"to wherever the assignments were downloaded to
  • setup a subfolder with the assignment in it. I've called it "./problem".
  • "javac -cp problem problem/FBook.java" to whatever command you use to compile their code with
  • "java -cp problem" Marker to whatever command you want to run on the code
  • you may want to edit "pdflatex output.tex" to your favourite latex command to create the final output.

Issues with the script:
  • Quite untested at the moment. Use at your own risk.
  • Assignments not run in a sandbox - malicious code can blow your system away.
  • The script doesn't currently truncate overly-long outputs. I've had students work go into infinite loops when attached to a printer before...
  • It should really be a single greasemonkey script to run...but this would have taken more effort.
  • For a script that's used on the Advanced Data Structures and Software Engineering courses, the code is really awful.