<commit_before>require 'turnitin_api'
module Turnitin
  class OutcomeResponseProcessor

    MAX_ATTEMPTS=11.freeze  # this one goes to 11
    INTERVAL=5.minutes.freeze
    def initialize(tool, assignment, user, outcomes_response_json)
      @tool = tool
      @assignment = assignment
      @user = user
      @outcomes_response_json = outcomes_response_json
    end

    def process
      attachment = create_attachment
      submission = @assignment.submit_homework(@user, attachments:[attachment], submission_type: 'online_upload')
      asset_string = attachment.asset_string
      update_turnitin_data!(submission, asset_string, status: 'pending', outcome_response: @outcomes_response_json)
      self.send_later(:update_originality_data, submission, asset_string)
    end
    handle_asynchronously :process, max_attempts: 1, priority: Delayed::LOW_PRIORITY

    def resubmit(submission, asset_string)
      self.send_later(:update_originality_data, submission, asset_string)
    end

    def turnitin_client
      @turnitin_client ||= (
        lti_params = {
          'user_id' => Lti::Asset.opaque_identifier_for(@user),
          'context_id' => Lti::Asset.opaque_identifier_for(@assignment.context),
          'context_title' => @assignment.context.name,
          'lis_person_contact_email_primary' => @user.email
        }
<commit_msg>delay retrieving submission from TII for 1 minute<commit_after>require 'turnitin_api'
module Turnitin
  class OutcomeResponseProcessor

    MAX_ATTEMPTS=11.freeze  # this one goes to 11
    INTERVAL=5.minutes.freeze
    def initialize(tool, assignment, user, outcomes_response_json)
      @tool = tool
      @assignment = assignment
      @user = user
      @outcomes_response_json = outcomes_response_json
    end

    def process
      attachment = create_attachment
      submission = @assignment.submit_homework(@user, attachments:[attachment], submission_type: 'online_upload')
      asset_string = attachment.asset_string
      update_turnitin_data!(submission, asset_string, status: 'pending', outcome_response: @outcomes_response_json)
      self.send_later(:update_originality_data, submission, asset_string)
    end
    handle_asynchronously :process, max_attempts: 1, run_at: 1.minutes.from_now, priority: Delayed::LOW_PRIORITY

    def resubmit(submission, asset_string)
      self.send_later(:update_originality_data, submission, asset_string)
    end

    def turnitin_client
      @turnitin_client ||= (
        lti_params = {
          'user_id' => Lti::Asset.opaque_identifier_for(@user),
          'context_id' => Lti::Asset.opaque_identifier_for(@assignment.context),
          'context_title' => @assignment.context.name,
          'lis_person_contact_email_primary' => @user.email
        }

{'fraction_non_alphanumeric': 0.08768115942028985, 'fraction_numerical': 0.005072463768115942, 'mean_word_length': 3.9658273381294964, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5888973', 'n_tokens_mistral': 853, 'n_tokens_neox': 806, 'n_words': 155}