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:
One can see two examples of such problems at
myuser.pyby 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.
user.pyprogram for correctness by trying it on a few cases.
myuser.pyhe creates the tester by modifying a previously used
The workflow of the student is as follows:
tester.pyfiles 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
and inspecting the results. The user repeats until satisfied that the program is correct.
If any of the test cases leads to an error the student goes back to the previous step.
user.pyto 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.