Class: Decidim::Forms::Admin::QuestionnaireParticipantPresenter
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- Decidim::Forms::Admin::QuestionnaireParticipantPresenter
show all
- Defined in:
- app/presenters/decidim/forms/admin/questionnaire_participant_presenter.rb
Overview
Presenter for questionnaire response
Instance Method Summary
collapse
Instance Method Details
#completion ⇒ Object
45
46
47
48
49
50
51
52
|
# File 'app/presenters/decidim/forms/admin/questionnaire_participant_presenter.rb', line 45
def completion
with_body = siblings.where(decidim_forms_questions: { question_type: %w(short_response long_response) })
.where.not(body: "").count
with_choices = siblings.where.not(decidim_forms_questions: { question_type: %w(short_response long_response) })
.where("decidim_forms_responses.id IN (SELECT decidim_response_id FROM decidim_forms_response_choices)").count
(with_body + with_choices).to_f / questionnaire.questions.not_separator.not_title_and_description.count * 100
end
|
#first_short_response ⇒ Object
40
41
42
43
|
# File 'app/presenters/decidim/forms/admin/questionnaire_participant_presenter.rb', line 40
def first_short_response
short = siblings.where(decidim_forms_questions: { question_type: %w(short_response) })
short.first
end
|
#ip_hash ⇒ Object
18
19
20
|
# File 'app/presenters/decidim/forms/admin/questionnaire_participant_presenter.rb', line 18
def ip_hash
participant.ip_hash || "-"
end
|
#participant ⇒ Object
10
11
12
|
# File 'app/presenters/decidim/forms/admin/questionnaire_participant_presenter.rb', line 10
def participant
__getobj__.fetch(:participant)
end
|
#registered? ⇒ Boolean
28
29
30
|
# File 'app/presenters/decidim/forms/admin/questionnaire_participant_presenter.rb', line 28
def registered?
participant.decidim_user_id.present?
end
|
#responded_at ⇒ Object
22
23
24
|
# File 'app/presenters/decidim/forms/admin/questionnaire_participant_presenter.rb', line 22
def responded_at
participant.created_at
end
|
#responses ⇒ Object
36
37
38
|
# File 'app/presenters/decidim/forms/admin/questionnaire_participant_presenter.rb', line 36
def responses
siblings.map { |response| QuestionnaireResponsePresenter.new(response:) }
end
|
#session_token ⇒ Object
14
15
16
|
# File 'app/presenters/decidim/forms/admin/questionnaire_participant_presenter.rb', line 14
def session_token
participant.session_token || "-"
end
|
#status ⇒ Object
32
33
34
|
# File 'app/presenters/decidim/forms/admin/questionnaire_participant_presenter.rb', line 32
def status
I18n.t(registered? ? "registered" : "unregistered", scope: "decidim.forms.user_responses_serializer")
end
|