diff --git a/app/models/task.rb b/app/models/task.rb index db5778d76..3d847c165 100644 --- a/app/models/task.rb +++ b/app/models/task.rb @@ -149,6 +149,10 @@ def extensions_must_end_with_due_date end end + def description + "#{task_definition.abbreviation} for #{project.student.username}" + end + def all_comments if group_submission.nil? comments diff --git a/app/models/turn_it_in/tii_action_upload_submission.rb b/app/models/turn_it_in/tii_action_upload_submission.rb index 192878381..8518911d1 100644 --- a/app/models/turn_it_in/tii_action_upload_submission.rb +++ b/app/models/turn_it_in/tii_action_upload_submission.rb @@ -18,7 +18,7 @@ def update_from_pdf_report_status(response) when 'SUCCESS' # Similarity report is complete entity.status = :similarity_pdf_requested entity.save - save_and_reset_retry + save_progress download_similarity_report_pdf(skip_check: true) # else # pending or unknown... end @@ -41,13 +41,12 @@ def update_from_submission_status(response) when 'COMPLETE' # Submission processing is complete entity.status = :submission_complete entity.save - save_and_reset_retry + save_and_reschedule # Request the similarity report request_similarity_report when 'ERROR' # An error occurred during submission processing; see error_code for details save_and_log_custom_error response.error_code Doubtfire::Application.config.logger.error "Error with tii submission: #{id} #{self.custom_error_message}" - save_and_reset_retry end end @@ -78,16 +77,17 @@ def update_from_similarity_status(response) similarity.save end - # Reset for new request - save_and_reset_retry - - # Request the PDF if flagged - request_similarity_report_pdf if flag + # If we need to get the pdf report... request it + if flag + save_and_reschedule + # Request the PDF if flagged + request_similarity_report_pdf + else + save_and_mark_complete + end end end - private - # Run is designed to be run in a background job, polling in # case of the need to retry actions. This will ensure submissions progress # through turn it in when web hooks fails. @@ -150,7 +150,7 @@ def fetch_tii_submission_id entity.status = :has_id entity.save - save_and_reset_retry + save_and_reschedule # If we had to indicate the eula was accepted, then we need to update the user unless submitted_by_user.tii_eula_version_confirmed @@ -337,7 +337,7 @@ def request_similarity_report_pdf entity.similarity_pdf_id = result.id entity.save - save_and_reset_retry + save_and_reschedule end end @@ -363,16 +363,21 @@ def download_similarity_report_pdf(skip_check: false) ) filename = similarity_pdf_path - file = File.new(filename, 'wb') - begin - file.write(result) - ensure - file.close + + if result.instance_of? Tempfile + FileUtils.mv(result.path, filename) + else + file = File.new(filename, 'wb') + begin + file.write(result) + ensure + file.close + end end entity.status = :similarity_pdf_downloaded entity.save - save_and_reset_retry + save_and_mark_complete true end diff --git a/app/models/turn_it_in/tii_action_upload_task_resources.rb b/app/models/turn_it_in/tii_action_upload_task_resources.rb index 9a21bedd3..631c96308 100644 --- a/app/models/turn_it_in/tii_action_upload_task_resources.rb +++ b/app/models/turn_it_in/tii_action_upload_task_resources.rb @@ -16,13 +16,12 @@ def update_from_attachment_status(response) entity.status = :complete entity.save - self.complete = true - save_and_reset_retry + save_and_mark_complete when 'ERROR' self.error_code = :custom_tii_error self.custom_error_message = response.error_code Doubtfire::Application.config.logger.error "Error with tii submission: #{id} #{self.custom_error_message}" - save_and_reset_retry + save_and_log_custom_error end end @@ -78,7 +77,7 @@ def fetch_tii_group_attachment_id entity.status = :has_id entity.save - save_and_reset_retry + save_and_reschedule end end @@ -101,8 +100,7 @@ def upload_attachment_to_tii ) entity.update(status: :uploaded) - - save_and_reset_retry + save_and_reschedule end end