danmarsden/moodle-plagiarism_turnitin — Issue #24: Students uploading the same filename more than once wedges processing
Author: jonof
Created: 2012-01-05 03:07:07+00:00
State: open

If a student uploads a file with the same filename more than once, the event queue processing will never proceed beyond the event for the second upload of the file. The only workaround to unstick the queue is to manually delete the blocked event handler record from mdl_events_queue_handlers.

This is the sequence of events I have observed:

1. File is uploaded by student.
2. File with the same filename (may be the same file content, maybe not) is uploaded again by the same student. Now two events are queued for with the same pathhash.
3. Cron job runs and the first event is processed. The plugin successfully sends the file to Turnitin and creates a record in mdl_plagiarism_turnitin_files with a status of 51.
4. The next event is attempted, but plagiarism_update_record() returns false in the event handler because a record already exists in mdl_plagiarism_turnitin_files with a status of 'success' or 'pending' or 51. This causes the event handler to return false to Moodle's event processing code which indicates a request to retry in the next cycle. No further events are processed by the event handler for this cron job run.
5. In subsequent cron job executions, the queue never processes later file uploads because the event at the head keeps requesting retries.

I don't know what the best solution is for this. I have tried changing plagiarism_update_record() to return the existing "$plagiarism_file->id" even if it does not make a change to the mdl_plagiarism_turnitin_files record, and this causes the plugin to reupload the file to Turnitin. Turnitin does not complain, but I don't know what the ramifications are of that.