turnitin / moodle-plagiarism_turnitin

Turnitin Plagiarism plugin for Moodle
http://www.turnitin.com
45 stars 65 forks source link

Exception when making group submission #566

Open ghost opened 3 years ago

ghost commented 3 years ago

When making a submission to a Moodle assignment as a student, with "Student submit in groups" set to yes, we get a database exception. This prevents the submission from being sent to TurnItIn.

Exception encountered in event observer 'plagiarism_turnitin_observer::assignsubmission_file_uploaded': Error writing to database (Column 'userid' cannot be null INSERT INTO mdl_plagiarism_turnitin_files (cm,userid,identifier,statuscode,similarityscore,attempt,transmatch,submissiontype) VALUES(?,?,?,?,?,?,?,?) [array ( 0 => '346853', 1 => NULL, 2 => '9b950e84112cafa4c666f2c48e82ccc63fde6097', 3 => 'queued', 4 => NULL, 5 => 1, 6 => 0, 7 => 'file', )])
  line 1357 of /lib/dml/mysqli_native_moodle_database.php: call to moodle_database->query_end()
  line 1403 of /lib/dml/mysqli_native_moodle_database.php: call to mysqli_native_moodle_database->insert_record_raw()
  line 2615 of /plagiarism/turnitin/lib.php: call to mysqli_native_moodle_database->insert_record()
  line 2383 of /plagiarism/turnitin/lib.php: call to plagiarism_plugin_turnitin->create_new_tii_submission()
  line 2591 of /plagiarism/turnitin/lib.php: call to plagiarism_plugin_turnitin->queue_submission_to_turnitin()
  line 61 of /plagiarism/turnitin/classes/observer.php: call to plagiarism_plugin_turnitin->event_handler()
  line ? of unknownfile: call to plagiarism_turnitin_observer::assignsubmission_file_uploaded()
  line 155 of /lib/classes/event/manager.php: call to call_user_func()
  line 75 of /lib/classes/event/manager.php: call to core\event\manager::process_buffers()
  line 834 of /lib/classes/event/base.php: call to core\event\manager::dispatch()
  line 260 of /mod/assign/submission/file/locallib.php: call to core\event\base->trigger()
  line 7436 of /mod/assign/locallib.php: call to assign_submission_file->save()
  line 7521 of /mod/assign/locallib.php: call to assign->save_submission()
  line 492 of /mod/assign/locallib.php: call to assign->process_save_submission()
  line 55 of /mod/assign/view.php: call to assign->view()

We also receive notices on the assignment list page, which appear to be related:

Notice: Trying to get property 'userid' of non-object in /var/www/deployments/moodle-619/plagiarism/turnitin/lib.php on line 781
ghost commented 3 years ago

This looks like a regression. On our production Moodle site (3.6.3), using plagiarism plugin 2019031301, this all works correctly.

ghost commented 3 years ago

We've done some further testing and investigation. The cause seems to be when a user has both the student and teacher role within a course. The plugins cannot determine which individual user to attribute the submission to. I believe this is a result of checking for the mod/assign:grade capability in https://github.com/turnitin/moodle-plagiarism_turnitin/blob/master/lib.php#L1628.