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: calculate_exp_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
class Course::Assessment::Submission::CalculateExpService
  class << self
    # Updates the exp for an autograded submission that will be awarded by the system
    # and the awarding time is the current time.
    # @param [Course::Assessment::Submission] submission The answer to be graded.
    def upda
    
    def calculate_exp(submission)
      assessment = submission.assessment
      assessment_time = assessment.time_for(submission.course_user)

      end_at = assessment_time.end_at
      bonus_end_at = assessment_time.bonus_end_at
      total_exp = assessment.base_exp

      return 0 if end_at && submission.submitted_at > end_at

      total_exp += assessment.time_bonus_exp if bonus_end_at && submission.submitted_at <= bonus_end_at

      maximum_grade = submission.questions.sum(:maximum_grade).to_f

      (maximum_grade == 0) ? total_exp : (submission.grade.to_f / maximum_grade * total_exp)
    end