Sha256: 04114bde9088cfd4f7724d5eb8ac2bcb910b55eb1801f4ff8b3f53387d4f7ddb

Contents?: true

Size: 1.53 KB

Versions: 15

Compression:

Stored size: 1.53 KB

Contents

module AssignmentResultHelper
  def t_expectation(expectation)
    raw Mumukit::Inspection::Expectation.parse(expectation).translate
  end

  def render_feedback?(assignment)
    StatusRenderingVerbosity.render_feedback?(assignment.feedback)
  end

  def t_assignment_status(assignment)
    t assignment_status assignment
  end

  def assignment_status(assignment)
    if assignment.exercise.hidden?
      :hidden_done
    elsif assignment.exercise.choices?
      assignment.passed? ? :correct_answer : :wrong_answer
    else
      assignment.status
    end
  end

  def render_test_results(assignment)
    if assignment.test_results.present?
      render partial: 'layouts/test_results', locals: { assignment: assignment }
    else
      render partial: 'layouts/result', locals: { assignment: assignment }
    end
  end

  def solution_download_link(assignment)
    link_to fa_icon(:download, text: t(:download)),
            solution_octet_data(assignment),
            download: solution_filename(assignment) if assignment.exercise.upload?
  end

  def community_link
    Organization.current.community_link
  end

  def community_link?
    community_link.present?
  end

  def render_community_link
    if community_link?
      link_to fa_icon(:facebook, text: I18n.t(:ask_community), class: 'fa-fw'), community_link, target: '_blank'
    end
  end

  private

  def solution_octet_data(assignment)
    "data:application/octet-stream,#{URI.encode assignment.solution}"
  end

  def solution_filename(assignment)
    "solution.#{assignment.extension}"
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
mumuki-laboratory-5.1.1 app/helpers/assignment_result_helper.rb
mumuki-laboratory-5.1.0 app/helpers/assignment_result_helper.rb
mumuki-laboratory-5.0.12 app/helpers/assignment_result_helper.rb
mumuki-laboratory-5.0.11 app/helpers/assignment_result_helper.rb
mumuki-laboratory-5.0.10 app/helpers/assignment_result_helper.rb
mumuki-laboratory-5.0.9 app/helpers/assignment_result_helper.rb
mumuki-laboratory-5.0.8 app/helpers/assignment_result_helper.rb
mumuki-laboratory-5.0.7 app/helpers/assignment_result_helper.rb
mumuki-laboratory-5.0.6 app/helpers/assignment_result_helper.rb
mumuki-laboratory-5.0.5 app/helpers/assignment_result_helper.rb
mumuki-laboratory-5.0.4 app/helpers/assignment_result_helper.rb
mumuki-laboratory-5.0.3 app/helpers/assignment_result_helper.rb
mumuki-laboratory-5.0.2 app/helpers/assignment_result_helper.rb
mumuki-laboratory-5.0.1 app/helpers/assignment_result_helper.rb
mumuki-laboratory-5.0.0 app/helpers/assignment_result_helper.rb