Sha256: b872d0a33a679f4c1c57998c2cd8022918d48050bcd8205ca1b2cd3ee460ed08

Contents?: true

Size: 975 Bytes

Versions: 66

Compression:

Stored size: 975 Bytes

Contents

module Solvable
  def submit_solution!(user, submission_attributes={})
    assignment, _ = find_assignment_and_submit! user, solution_for(submission_attributes)
    try_solve_discussions!(user) if assignment.solved?
    assignment
  end

  def run_tests!(params)
    language.run_tests!(params.merge(locale: locale, expectations: expectations, custom_expectations: custom_expectations))
  end

  def solution_for(submission_attributes)
    submission_attributes[:content]
      .to_mumuki_solution(language)
      .with_client_result(submission_attributes[:client_result])
  end
end

class NilClass
  def to_mumuki_solution(language)
    Mumuki::Domain::Submission::Solution.new
  end
end

class String
  def to_mumuki_solution(language)
    Mumuki::Domain::Submission::Solution.new content: normalize_whitespaces
  end
end

class Hash
  def to_mumuki_solution(language)
    language
      .directives_sections
      .join(self)
      .to_mumuki_solution(language)
  end
end

Version data entries

66 entries across 66 versions & 2 rubygems

Version Path
mumuki-domain-9.7.0 app/models/concerns/submittable/solvable.rb
mumuki-domain-9.6.0 app/models/concerns/submittable/solvable.rb
mumuki-domain-9.5.0 app/models/concerns/submittable/solvable.rb
mumuki-domain-9.4.0 app/models/concerns/submittable/solvable.rb
mumuki-domain-9.3.0 app/models/concerns/submittable/solvable.rb
mumuki-domain-9.2.1 app/models/concerns/submittable/solvable.rb
mumuki-domain-9.2.0 app/models/concerns/submittable/solvable.rb
mumuki-domain-9.1.2 app/models/concerns/submittable/solvable.rb
mumuki-domain-9.1.1 app/models/concerns/submittable/solvable.rb
mumuki-domain-9.1.0 app/models/concerns/submittable/solvable.rb
mumuki-domain-9.0.6 app/models/concerns/submittable/solvable.rb
mumuki-domain-9.0.5 app/models/concerns/submittable/solvable.rb
mumuki-domain-9.0.4 app/models/concerns/submittable/solvable.rb
mumuki-domain-9.0.3 app/models/concerns/submittable/solvable.rb
mumuki-domain-9.0.2 app/models/concerns/submittable/solvable.rb
mumuki-domain-9.0.0 app/models/concerns/submittable/solvable.rb
mumuki-domain-8.6.1 app/models/concerns/submittable/solvable.rb
mumuki-domain-8.6.0 app/models/concerns/submittable/solvable.rb
mumuki-domain-8.5.0 app/models/concerns/submittable/solvable.rb
mumuki-domain-8.4.0 app/models/concerns/submittable/solvable.rb