Move Canvas Files
Canvas is good for a lot of things, but turning in source code in a computer science class is not one of them.
Our district requires us to use Canvas, and for the most part that's a good thing. But when students need to turn in Java files there's a pretty significant issue. When you download submitted files they've all been renamed and stored in the root of the zip file.
Since they're Java files, they need to be named the same thing as the class which breaks by renaming the files
A Bit of Python
Yesterday I finally got frustrated enough to kick up a little Python script to fix the problem. It's the
move_files.py file that's attached to this Gist.
What it does is find any file in the current directory that matches the regex
[a-z]*?_[0-9]*?_[0-9]*?_ and then splits on the underscores to break out the pieces. First part is the student name, and is used for the folder name. Piece of the last underscore is the filename and what the file is renamed to as it's moved into the student's folder.
You'll need Python 3 somewhere in your path for this to work.
move_files.py file to the folder where you downloaded all of your students' work and then run the script. If you've installed Python you can probably just double click on it.
Updates & Quirks
I really need to make this work so that you don't have to copy the
move_files.py file to every directory you want to fix.
The other issue that's come up is the way Canvas handles multiple submissions. If a student submits a file with the same name as a previous submission it tacks
-1 on the end of the filename. That messes up Java when you try to run, and I probably should work out a way to strip that out. Best thing would probably be to read any file that ends with
.java and look for the class name.
More About Me
And if you're interested, I blog about teaching computer science at CompSci.rocks.