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-8.3.1 app/models/concerns/submittable/solvable.rb
mumuki-domain-8.2.0 app/models/concerns/submittable/solvable.rb
mumuki-domain-8.1.3 app/models/concerns/submittable/solvable.rb
mumuki-domain-8.1.2 app/models/concerns/submittable/solvable.rb
mumuki-domain-8.1.1 app/models/concerns/submittable/solvable.rb
mumuki-domain-8.1.0 app/models/concerns/submittable/solvable.rb
mumuki-domain-8.0.0 app/models/concerns/submittable/solvable.rb
mumuki-domain-7.12.2 app/models/concerns/submittable/solvable.rb
mumuki-domain-7.12.1 app/models/concerns/submittable/solvable.rb
mumuki-domain-7.12.0 app/models/concerns/submittable/solvable.rb
mumuki-domain-7.11.1 app/models/concerns/submittable/solvable.rb
mumuki-laboratory-7.11.1 vendor/bundle/ruby/2.6.0/bundler/gems/mumuki-domain-c92f2a7212e2/app/models/concerns/submittable/solvable.rb
mumuki-laboratory-7.11.0 vendor/bundle/ruby/2.6.0/bundler/gems/mumuki-domain-2e15c3330133/app/models/concerns/submittable/solvable.rb
mumuki-domain-7.11.0 app/models/concerns/submittable/solvable.rb
mumuki-domain-7.10.1 app/models/concerns/submittable/solvable.rb
mumuki-domain-7.10.0 app/models/concerns/submittable/solvable.rb
mumuki-laboratory-7.9.2 vendor/bundle/ruby/2.6.0/bundler/gems/mumuki-domain-7082a83493eb/app/models/concerns/submittable/solvable.rb
mumuki-domain-7.9.2 app/models/concerns/submittable/solvable.rb
mumuki-laboratory-7.9.1 vendor/bundle/ruby/2.6.0/bundler/gems/mumuki-domain-b162dc91aa77/app/models/concerns/submittable/solvable.rb
mumuki-domain-7.9.1 app/models/concerns/submittable/solvable.rb