From 2ff085ab607ea6767ffff91049c1011233a14db6 Mon Sep 17 00:00:00 2001 From: Jack Date: Wed, 4 Dec 2024 14:30:08 +0000 Subject: [PATCH 1/6] Don't reuse TCA submissionid --- classes/task.class.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/classes/task.class.php b/classes/task.class.php index 7abc7a9..83c68ae 100644 --- a/classes/task.class.php +++ b/classes/task.class.php @@ -120,13 +120,13 @@ public function send_queued_submissions() { if ($tssubmission->getstatus() == TURNITINSIM_SUBMISSION_STATUS_QUEUED) { $tssubmission->create_submission_in_turnitin(); - } - if (!empty($tssubmission->getturnitinid())) { - $tssubmission->upload_submission_to_turnitin(); + if (tssubmission->getstatus() == TURNITINSIM_HTTP_CREATED) { + $tssubmission->upload_submission_to_turnitin(); - // Set the time for the report to be generated. - $tssubmission->calculate_generation_time(); + // Set the time for the report to be generated. + $tssubmission->calculate_generation_time(); + } } $tssubmission->update(); From b7a95cf890c8cac4de73f5c087c527705a6b3f50 Mon Sep 17 00:00:00 2001 From: Jack Date: Wed, 4 Dec 2024 14:54:17 +0000 Subject: [PATCH 2/6] Checking for CREATED status before uploading --- classes/task.class.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/classes/task.class.php b/classes/task.class.php index 83c68ae..bc5592d 100644 --- a/classes/task.class.php +++ b/classes/task.class.php @@ -120,13 +120,13 @@ public function send_queued_submissions() { if ($tssubmission->getstatus() == TURNITINSIM_SUBMISSION_STATUS_QUEUED) { $tssubmission->create_submission_in_turnitin(); + } - if (tssubmission->getstatus() == TURNITINSIM_HTTP_CREATED) { - $tssubmission->upload_submission_to_turnitin(); + if ($tssubmission->getstatus() == TURNITINSIM_SUBMISSION_STATUS_CREATED && !empty($tssubmission->getturnitinid())) { + $tssubmission->upload_submission_to_turnitin(); - // Set the time for the report to be generated. - $tssubmission->calculate_generation_time(); - } + // Set the time for the report to be generated. + $tssubmission->calculate_generation_time(); } $tssubmission->update(); From be20577427acc920abc8f119d32b88547288c19e Mon Sep 17 00:00:00 2001 From: Jack Date: Wed, 4 Dec 2024 15:19:29 +0000 Subject: [PATCH 3/6] Checking tiiattempts --- classes/task.class.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/classes/task.class.php b/classes/task.class.php index bc5592d..15cddff 100644 --- a/classes/task.class.php +++ b/classes/task.class.php @@ -122,11 +122,18 @@ public function send_queued_submissions() { $tssubmission->create_submission_in_turnitin(); } - if ($tssubmission->getstatus() == TURNITINSIM_SUBMISSION_STATUS_CREATED && !empty($tssubmission->getturnitinid())) { + if (!empty($tssubmission->getturnitinid())) { + // If this is a retry, generate a new submissionid + if ($tssubmission->gettiiattempts() > 0) { + $tssubmission->create_submission_in_turnitin(); + } + $tssubmission->upload_submission_to_turnitin(); // Set the time for the report to be generated. $tssubmission->calculate_generation_time(); + + mtrace(json_encode($tssubmission, JSON_PRETTY_PRINT)); } $tssubmission->update(); From fca86747e1695a41eb512891e12a43076ed3dbbc Mon Sep 17 00:00:00 2001 From: Jack Date: Wed, 4 Dec 2024 15:20:00 +0000 Subject: [PATCH 4/6] Delete mtrace --- classes/task.class.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/classes/task.class.php b/classes/task.class.php index 15cddff..706a2cc 100644 --- a/classes/task.class.php +++ b/classes/task.class.php @@ -132,8 +132,6 @@ public function send_queued_submissions() { // Set the time for the report to be generated. $tssubmission->calculate_generation_time(); - - mtrace(json_encode($tssubmission, JSON_PRETTY_PRINT)); } $tssubmission->update(); From 872a5e108a34dab8f43360263761a2aafe240a05 Mon Sep 17 00:00:00 2001 From: Jack Date: Wed, 4 Dec 2024 15:23:23 +0000 Subject: [PATCH 5/6] Moving retry logic --- classes/task.class.php | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/classes/task.class.php b/classes/task.class.php index 706a2cc..0c9193f 100644 --- a/classes/task.class.php +++ b/classes/task.class.php @@ -118,16 +118,11 @@ public function send_queued_submissions() { continue; } - if ($tssubmission->getstatus() == TURNITINSIM_SUBMISSION_STATUS_QUEUED) { + if ($tssubmission->getstatus() == TURNITINSIM_SUBMISSION_STATUS_QUEUED || $tssubmission->gettiiattempts() > 0) { $tssubmission->create_submission_in_turnitin(); } if (!empty($tssubmission->getturnitinid())) { - // If this is a retry, generate a new submissionid - if ($tssubmission->gettiiattempts() > 0) { - $tssubmission->create_submission_in_turnitin(); - } - $tssubmission->upload_submission_to_turnitin(); // Set the time for the report to be generated. From 7e70ee52f11be2859de3fc648636eed1d5ea416f Mon Sep 17 00:00:00 2001 From: Jack Date: Mon, 16 Dec 2024 13:28:17 +0000 Subject: [PATCH 6/6] Only attempt to send queued submissions --- classes/task.class.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/classes/task.class.php b/classes/task.class.php index 0c9193f..3c83861 100644 --- a/classes/task.class.php +++ b/classes/task.class.php @@ -118,15 +118,15 @@ public function send_queued_submissions() { continue; } - if ($tssubmission->getstatus() == TURNITINSIM_SUBMISSION_STATUS_QUEUED || $tssubmission->gettiiattempts() > 0) { + if ($tssubmission->getstatus() == TURNITINSIM_SUBMISSION_STATUS_QUEUED) { $tssubmission->create_submission_in_turnitin(); - } - if (!empty($tssubmission->getturnitinid())) { - $tssubmission->upload_submission_to_turnitin(); + if (!empty($tssubmission->getturnitinid())) { + $tssubmission->upload_submission_to_turnitin(); - // Set the time for the report to be generated. - $tssubmission->calculate_generation_time(); + // Set the time for the report to be generated. + $tssubmission->calculate_generation_time(); + } } $tssubmission->update();