Question Authors' Forum

Python3 Database programming?

Re: Python3 Database programming?

von Richard Lobb -
Anzahl Antworten: 0

Support files supplied by the question author are always write-locked to prevent inadvertent or deliberate corruption by the student. The solution is to make a copy of the database file at the start of each test; the student code should run using that copy, not the original. You need to make a fresh copy for each test to avoid interactions between the tests. 

You may find it helpful to look at the sql question template, which you can see by creating a question of type sql and clicking the Customise checkbox. The test loop begins

{% for TEST in TESTCASES %}
shutil.copyfile(db_files[0], db_working)  # Copy clean writeable db file

The best approach longer term is to create yourself a new question type but for a start you could experiment by using the standard python3 question type and customising each question, inserting something like the above file-copy line into the test loop.