Module: Decidim::Demographics
- Defined in:
- lib/decidim/demographics.rb,
lib/decidim/demographics/admin.rb,
lib/decidim/demographics/engine.rb,
lib/decidim/demographics/version.rb,
lib/decidim/demographics/admin_engine.rb,
app/models/decidim/demographics/demographic.rb,
app/permissions/decidim/demographics/permissions.rb,
app/models/decidim/demographics/application_record.rb,
app/permissions/decidim/demographics/admin/permissions.rb,
app/commands/decidim/demographics/delete_demographic_data.rb,
app/helpers/decidim/demographics/publish_responses_helper.rb,
app/controllers/decidim/demographics/application_controller.rb,
app/controllers/decidim/demographics/demographics_controller.rb,
app/controllers/decidim/demographics/admin/settings_controller.rb,
app/controllers/decidim/demographics/admin/questions_controller.rb,
app/controllers/decidim/demographics/admin/responses_controller.rb,
app/forms/decidim/demographics/admin/demographics_settings_form.rb,
app/controllers/decidim/demographics/admin/application_controller.rb,
app/commands/decidim/demographics/admin/update_demographics_settings.rb,
app/controllers/decidim/demographics/admin/publish_responses_controller.rb
Overview
This holds the decidim-demographics version.
Defined Under Namespace
Modules: Admin, PublishResponsesHelper Classes: AdminEngine, ApplicationController, ApplicationRecord, DeleteDemographicData, Demographic, DemographicsController, Engine, Permissions
Class Method Summary collapse
-
.create_default_questionnaire!(questionnaire) ⇒ Object
i18n-tasks-use t(‘decidim.demographics.questions.age.question’) i18n-tasks-use t(‘decidim.demographics.questions.age.options’) i18n-tasks-use t(‘decidim.demographics.questions.gender.question’) i18n-tasks-use t(‘decidim.demographics.questions.gender.options’) i18n-tasks-use t(‘decidim.demographics.questions.postal.question’).
- .version ⇒ Object
Class Method Details
.create_default_questionnaire!(questionnaire) ⇒ Object
i18n-tasks-use t(‘decidim.demographics.questions.age.question’) i18n-tasks-use t(‘decidim.demographics.questions.age.options’) i18n-tasks-use t(‘decidim.demographics.questions.gender.question’) i18n-tasks-use t(‘decidim.demographics.questions.gender.options’) i18n-tasks-use t(‘decidim.demographics.questions.postal.question’)
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/decidim/demographics.rb', line 16 def self.create_default_questionnaire!(questionnaire) return if questionnaire.persisted? questionnaire.save! locales = questionnaire.questionnaire_for.organization.available_locales scope = "decidim.demographics.questions" first_question = questionnaire.questions.create!( position: 0, question_type: "single_option", body: locales.index_with { |key| I18n.with_locale(key) { I18n.t("age.question", scope:) } } ) I18n.t("age.options", scope:).each_with_index do |_o, index| first_question..create!(body: locales.index_with { |key| I18n.with_locale(key) { I18n.t("age.options", scope:)[index] } }, free_text: false) end second_question = questionnaire.questions.create!( position: 1, question_type: "single_option", body: locales.index_with { |key| I18n.with_locale(key) { I18n.t("gender.question", scope:) } } ) I18n.t("gender.options", scope:).each_with_index do |_o, index| second_question..create!(body: locales.index_with { |key| I18n.with_locale(key) { I18n.t("gender.options", scope:)[index] } }, free_text: false) end questionnaire.questions.create!( position: 2, question_type: "short_response", body: locales.index_with { |key| I18n.with_locale(key) { I18n.t("postal.question", scope:) } } ) end |
.version ⇒ Object
6 7 8 |
# File 'lib/decidim/demographics/version.rb', line 6 def self.version "0.32.0.rc1" end |