Class: Decidim::Forms::Admin::QuestionnaireParticipantPresenter
- Inherits:
-
Rectify::Presenter
- Object
- Rectify::Presenter
- Decidim::Forms::Admin::QuestionnaireParticipantPresenter
- Defined in:
- app/presenters/decidim/forms/admin/questionnaire_participant_presenter.rb
Overview
Presenter for questionnaire response
Instance Method Summary collapse
- #answered_at ⇒ Object
- #answers ⇒ Object
- #completion ⇒ Object
- #first_short_answer ⇒ Object
- #ip_hash ⇒ Object
- #registered? ⇒ Boolean
- #session_token ⇒ Object
- #status ⇒ Object
Instance Method Details
#answered_at ⇒ Object
20 21 22 |
# File 'app/presenters/decidim/forms/admin/questionnaire_participant_presenter.rb', line 20 def answered_at participant.created_at end |
#answers ⇒ Object
34 35 36 |
# File 'app/presenters/decidim/forms/admin/questionnaire_participant_presenter.rb', line 34 def answers sibilings.map { |answer| QuestionnaireAnswerPresenter.new(answer: answer) } end |
#completion ⇒ Object
43 44 45 46 47 48 49 50 |
# File 'app/presenters/decidim/forms/admin/questionnaire_participant_presenter.rb', line 43 def completion with_body = sibilings.where(decidim_forms_questions: { question_type: %w(short_answer long_answer) }) .where.not(body: "").count with_choices = sibilings.where.not("decidim_forms_questions.question_type in (?)", %w(short_answer long_answer)) .where("decidim_forms_answers.id IN (SELECT decidim_answer_id FROM decidim_forms_answer_choices)").count (with_body + with_choices).to_f / questionnaire.questions.not_separator.not_title_and_description.count * 100 end |
#first_short_answer ⇒ Object
38 39 40 41 |
# File 'app/presenters/decidim/forms/admin/questionnaire_participant_presenter.rb', line 38 def first_short_answer short = sibilings.where(decidim_forms_questions: { question_type: %w(short_answer) }) short.first end |
#ip_hash ⇒ Object
16 17 18 |
# File 'app/presenters/decidim/forms/admin/questionnaire_participant_presenter.rb', line 16 def ip_hash participant.ip_hash || "-" end |
#registered? ⇒ Boolean
26 27 28 |
# File 'app/presenters/decidim/forms/admin/questionnaire_participant_presenter.rb', line 26 def registered? participant.decidim_user_id.present? end |
#session_token ⇒ Object
12 13 14 |
# File 'app/presenters/decidim/forms/admin/questionnaire_participant_presenter.rb', line 12 def session_token participant.session_token || "-" end |
#status ⇒ Object
30 31 32 |
# File 'app/presenters/decidim/forms/admin/questionnaire_participant_presenter.rb', line 30 def status t(registered? ? "registered" : "unregistered", scope: "decidim.forms.user_answers_serializer") end |