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.23.0 app/models/concerns/submittable/solvable.rb
mumuki-domain-9.22.1 app/models/concerns/submittable/solvable.rb
mumuki-domain-9.22.0 app/models/concerns/submittable/solvable.rb
mumuki-domain-9.21.0 app/models/concerns/submittable/solvable.rb
mumuki-domain-9.20.0 app/models/concerns/submittable/solvable.rb
mumuki-domain-9.19.0 app/models/concerns/submittable/solvable.rb
mumuki-domain-9.18.0 app/models/concerns/submittable/solvable.rb
mumuki-domain-9.17.0 app/models/concerns/submittable/solvable.rb
mumuki-domain-9.16.0 app/models/concerns/submittable/solvable.rb
mumuki-domain-9.15.0 app/models/concerns/submittable/solvable.rb
mumuki-domain-9.14.1 app/models/concerns/submittable/solvable.rb
mumuki-domain-9.14.0 app/models/concerns/submittable/solvable.rb
mumuki-domain-9.13.1 app/models/concerns/submittable/solvable.rb
mumuki-domain-9.13.0 app/models/concerns/submittable/solvable.rb
mumuki-domain-9.12.0 app/models/concerns/submittable/solvable.rb
mumuki-domain-9.11.0 app/models/concerns/submittable/solvable.rb
mumuki-domain-9.10.0 app/models/concerns/submittable/solvable.rb
mumuki-domain-9.9.0 app/models/concerns/submittable/solvable.rb
mumuki-domain-9.8.1 app/models/concerns/submittable/solvable.rb
mumuki-domain-9.8.0 app/models/concerns/submittable/solvable.rb