You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: auto_grading_service.rb
    path of file: ./repos/coursemology2/app/services/course/assessment/submission
    
    the code of the file until where you have to start completion: # frozen_string_literal: true
#
# Service to execute Course::Assessment::Submission::AutoGradingJob
class Course::Assessment::Submission::AutoGradingService
  class << self
    # Grades into the given submission.
    #
    # @param [Course::Assessment::Submission] submission The submission to grade.
    delegate :grade, to: :new
  end

  class SubJobError < StandardError
  e
    
  def grade_answers(submission, only_ungraded: false)
    tries, jobs_by_qn = 0, {}
    # Force re-grade all current answers (even when they've been graded before).
    answers_to_grade = only_ungraded ? ungraded_answers(submission) : submission.current_answers
    while answers_to_grade.any? && tries <= MAX_TRIES
      new_jobs = build_answer_grading_jobs(answers_to_grade)

      jobs_by_qn.merge!(new_jobs)
      answers_to_grade = ungraded_answers(submission)
      tries += 1
    end