Module: Decidim::Forms::Admin::QuestionnaireAnswersHelper

Defined in:
app/helpers/decidim/forms/admin/questionnaire_answers_helper.rb

Overview

Custom helpers for questionnaire answers

Instance Method Summary collapse

Instance Method Details

#display_percentage(number) ⇒ Object



24
25
26
# File 'app/helpers/decidim/forms/admin/questionnaire_answers_helper.rb', line 24

def display_percentage(number)
  number_to_percentage(number, precision: 0, strip_insignificant_zeros: true, locale: I18n.locale)
end

#first_table_td(answer) ⇒ Object



18
19
20
21
22
# File 'app/helpers/decidim/forms/admin/questionnaire_answers_helper.rb', line 18

def first_table_td(answer)
  return answer.first_short_answer&.body if @first_short_answer

  answer.session_token
end

#first_table_th(answer) ⇒ Object



9
10
11
12
13
14
15
16
# File 'app/helpers/decidim/forms/admin/questionnaire_answers_helper.rb', line 9

def first_table_th(answer)
  if answer.first_short_answer
    @first_short_answer = answer.first_short_answer
    return translated_attribute @first_short_answer.question.body
  end

  t("session_token", scope: "decidim.forms.user_answers_serializer")
end