python
programs
We describe here a very simple method that enables us to autocorrect student submitted python
programs, in the context
of a first programming course at University level.
This method is not automated as much as it could be, but it is very easy to set up and extremely flexible.
Each assigned problem (program to be written) is created by the teacher in one directory. This directory will contain three files, at least:
myuser.py
, user.py
and tester.py
.
One can see two examples of such problems at
histogram
and robot
.myuser.py
:myuser.py
file.
user.py
:myuser.py
by erasing the code written by the teacher that the student is supposed to come up with.
In other words, the code written by the teacher between the START and STOP lines is erased, and the student must write his own code between these two lines,
and only there.
tester.py
:user.py
program for correctness by trying it on a few cases.myuser.py
he creates the tester by modifying a previously used tester.py
file.
The workflow of the student is as follows:
user.py
and tester.py
files in there.
user.py
, reads the description of the problem therein and writes the code necessary between the START and STOP
lines. The user tests his program by giving the command
python user.py
and inspecting the results. The user repeats until satisfied that the program is correct.
python tester.py
If any of the test cases leads to an error the student goes back to the previous step.
user.py
to be graded. How this is done depends on the implementation. It could be by uploading
the file to a server, by emailing the teach with the file, or by other means.
For correction the teacher adds one or two more cases to his copy of the tester (to defeat students who might cheat by looking into their tester and make their program return the corresponding outputs for each value of the input listed in there) and uses a script to apply the tester to each submitted program and record the results to a file or database.