Module: AssignmentResultHelper

Defined in:
app/helpers/assignment_result_helper.rb

Instance Method Summary collapse

Instance Method Details

#assignment_status(assignment) ⇒ Object



14
15
16
17
18
19
20
21
22
# File 'app/helpers/assignment_result_helper.rb', line 14

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


38
39
40
# File 'app/helpers/assignment_result_helper.rb', line 38

def community_link
  Organization.current.community_link
end

#community_link?Boolean

Returns:

  • (Boolean)


42
43
44
# File 'app/helpers/assignment_result_helper.rb', line 42

def community_link?
  community_link.present?
end


46
47
48
49
50
# File 'app/helpers/assignment_result_helper.rb', line 46

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

#render_feedback?(assignment) ⇒ Boolean

Returns:

  • (Boolean)


6
7
8
# File 'app/helpers/assignment_result_helper.rb', line 6

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

#render_test_results(assignment) ⇒ Object



24
25
26
27
28
29
30
# File 'app/helpers/assignment_result_helper.rb', line 24

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


32
33
34
35
36
# File 'app/helpers/assignment_result_helper.rb', line 32

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

#t_assignment_status(assignment) ⇒ Object



10
11
12
# File 'app/helpers/assignment_result_helper.rb', line 10

def t_assignment_status(assignment)
  t assignment_status assignment
end

#t_expectation(expectation) ⇒ Object



2
3
4
# File 'app/helpers/assignment_result_helper.rb', line 2

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