decidim-surveys 0.10.1 → 0.11.0.pre1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -2
  3. data/app/assets/config/decidim_surveys_manifest.js +1 -0
  4. data/app/assets/javascripts/decidim/surveys/admin/auto_buttons_by_min_items.component.js.es6 +25 -0
  5. data/app/assets/javascripts/decidim/surveys/admin/auto_select_options_by_total_items.component.js.es6 +23 -0
  6. data/app/assets/javascripts/decidim/surveys/admin/surveys.js.es6 +146 -43
  7. data/app/assets/javascripts/decidim/surveys/autosortable_checkboxes.component.js.es6 +65 -0
  8. data/app/assets/javascripts/decidim/surveys/option_attached_inputs.component.js.es6 +32 -0
  9. data/app/assets/javascripts/decidim/surveys/surveys.js.es6 +20 -0
  10. data/app/assets/stylesheets/decidim/surveys/surveys.scss +20 -3
  11. data/app/commands/decidim/surveys/admin/update_survey.rb +36 -15
  12. data/app/commands/decidim/surveys/answer_survey.rb +12 -1
  13. data/app/commands/decidim/surveys/create_survey.rb +5 -5
  14. data/app/controllers/decidim/surveys/admin/application_controller.rb +2 -2
  15. data/app/controllers/decidim/surveys/admin/surveys_controller.rb +3 -3
  16. data/app/controllers/decidim/surveys/application_controller.rb +2 -2
  17. data/app/controllers/decidim/surveys/surveys_controller.rb +1 -1
  18. data/app/forms/decidim/surveys/admin/survey_answer_option_form.rb +23 -0
  19. data/app/forms/decidim/surveys/admin/survey_form.rb +7 -1
  20. data/app/forms/decidim/surveys/admin/survey_question_form.rb +12 -2
  21. data/app/forms/decidim/surveys/survey_answer_choice_form.rb +15 -0
  22. data/app/forms/decidim/surveys/survey_answer_form.rb +40 -6
  23. data/app/forms/decidim/surveys/survey_form.rb +1 -1
  24. data/app/helpers/decidim/surveys/admin/application_helper.rb +3 -19
  25. data/app/jobs/decidim/surveys/settings_change_job.rb +4 -4
  26. data/app/models/decidim/surveys/abilities/current_user_ability.rb +8 -8
  27. data/app/models/decidim/surveys/abilities/participatory_process_admin_ability.rb +1 -1
  28. data/app/models/decidim/surveys/survey.rb +2 -2
  29. data/app/models/decidim/surveys/survey_answer.rb +9 -1
  30. data/app/models/decidim/surveys/survey_answer_choice.rb +15 -0
  31. data/app/models/decidim/surveys/survey_answer_option.rb +9 -0
  32. data/app/models/decidim/surveys/survey_question.rb +21 -5
  33. data/app/views/decidim/surveys/admin/surveys/_answer_option.html.erb +28 -11
  34. data/app/views/decidim/surveys/admin/surveys/_form.html.erb +18 -14
  35. data/app/views/decidim/surveys/admin/surveys/_question.html.erb +74 -31
  36. data/app/views/decidim/surveys/admin/surveys/edit.html.erb +1 -1
  37. data/app/views/decidim/surveys/surveys/_answer.html.erb +94 -0
  38. data/app/views/decidim/surveys/surveys/show.html.erb +15 -42
  39. data/config/locales/ca.yml +33 -13
  40. data/config/locales/en.yml +33 -13
  41. data/config/locales/es.yml +33 -13
  42. data/config/locales/eu.yml +33 -13
  43. data/config/locales/fi.yml +33 -13
  44. data/config/locales/fr.yml +33 -13
  45. data/config/locales/gl.yml +33 -13
  46. data/config/locales/it.yml +33 -13
  47. data/config/locales/nl.yml +36 -16
  48. data/config/locales/pl.yml +33 -13
  49. data/config/locales/pt-BR.yml +33 -13
  50. data/config/locales/pt.yml +33 -13
  51. data/config/locales/ru.yml +0 -6
  52. data/config/locales/sv.yml +33 -13
  53. data/config/locales/uk.yml +0 -6
  54. data/db/migrate/20180305133837_rename_features_to_components_at_surveys.rb +11 -0
  55. data/db/migrate/20180314225829_add_max_choices_to_survey_questions.rb +7 -0
  56. data/db/migrate/20180321141024_add_description_to_decidim_survey_questions.rb +7 -0
  57. data/db/migrate/20180405014929_add_choices_to_decidim_survey_answers.rb +48 -0
  58. data/db/migrate/20180405015012_create_decidim_survey_answer_options.rb +43 -0
  59. data/db/migrate/20180405015147_create_decidim_survey_answer_choices.rb +61 -0
  60. data/db/migrate/20180405015258_add_free_text_to_survey_answer_options.rb +7 -0
  61. data/db/migrate/20180405015314_add_custom_body_to_survey_answer_choices.rb +7 -0
  62. data/db/migrate/20180406201818_add_position_to_decidim_survey_answer_choices.rb +7 -0
  63. data/lib/decidim/surveys.rb +1 -1
  64. data/lib/decidim/surveys/admin_engine.rb +0 -2
  65. data/lib/decidim/surveys/{feature.rb → component.rb} +38 -26
  66. data/lib/decidim/surveys/engine.rb +5 -1
  67. data/lib/decidim/surveys/test/factories.rb +22 -6
  68. data/lib/decidim/surveys/version.rb +1 -1
  69. metadata +33 -30
  70. data/app/assets/javascripts/decidim/surveys/admin/auto_label_by_position.component.js.es6 +0 -33
  71. data/app/assets/javascripts/decidim/surveys/admin/dynamic_fields.component.js.es6 +0 -95
  72. data/app/forms/decidim/surveys/admin/survey_question_answer_option_form.rb +0 -15
@@ -7,10 +7,6 @@ ru:
7
7
  mandatory: Обязательно
8
8
  question_type: Тип
9
9
  decidim:
10
- features:
11
- surveys:
12
- actions:
13
- answer: Ответить
14
10
  surveys:
15
11
  admin:
16
12
  exports:
@@ -22,7 +18,6 @@ ru:
22
18
  surveys:
23
19
  answer_option:
24
20
  answer_option: Вариант ответа
25
- remove_answer_option: Удалить вариант ответа
26
21
  statement: Высказывание
27
22
  edit:
28
23
  save: Сохранить
@@ -33,7 +28,6 @@ ru:
33
28
  question:
34
29
  add_answer_option: Добавить вариант ответа
35
30
  question: Вопрос
36
- remove_question: Удалить вопрос
37
31
  statement: Высказывание
38
32
  update:
39
33
  invalid: При сохранении опроса произошли ошибки.
@@ -5,8 +5,27 @@ sv:
5
5
  body: Svar
6
6
  survey_question:
7
7
  mandatory: Obligatorisk
8
+ max_choices: Max antal val
8
9
  question_type: Typ
10
+ errors:
11
+ models:
12
+ survey_answer:
13
+ attributes:
14
+ choices:
15
+ missing: är inte fullständiga
16
+ too_many: är för många
9
17
  decidim:
18
+ components:
19
+ surveys:
20
+ actions:
21
+ answer: Svara
22
+ name: Undersökning
23
+ settings:
24
+ global:
25
+ announcement: Meddelande
26
+ step:
27
+ allow_answers: Tillåta svar
28
+ announcement: Meddelande
10
29
  events:
11
30
  surveys:
12
31
  survey_closed:
@@ -19,17 +38,10 @@ sv:
19
38
  email_outro: Du har fått den här meddelandet eftersom du följer %{participatory_space_title}. Du kan sluta ta emot meddelanden efter föregående länk.
20
39
  email_subject: En ny undersökning i %{participatory_space_title}
21
40
  notification_title: Undersökningen <a href="%{resource_path}">%{resource_title}</a> i <a href="%{participatory_space_url}">%{participatory_space_title}</a> är nu öppen.
22
- features:
23
- surveys:
24
- actions:
25
- answer: Svar
26
- name: Undersökning
27
- settings:
28
- global:
29
- announcement: Meddelande
30
- step:
31
- allow_answers: Tillåta svar
32
- announcement: Meddelande
41
+ forms:
42
+ errors:
43
+ survey_answer:
44
+ body: Kroppen kan inte vara tomt
33
45
  surveys:
34
46
  admin:
35
47
  exports:
@@ -41,7 +53,8 @@ sv:
41
53
  surveys:
42
54
  answer_option:
43
55
  answer_option: Svaralternativ
44
- remove_answer_option: Ta bort svaralternativet
56
+ free_text: Fri text
57
+ remove: Avlägsna
45
58
  statement: Påstående
46
59
  edit:
47
60
  save: Spara
@@ -51,9 +64,13 @@ sv:
51
64
  already_answered_warning: Undersökningen är redan besvarad av vissa användare så att du inte kan ändra sina frågor.
52
65
  question:
53
66
  add_answer_option: Lägg till svaralternativ
67
+ any: Några
68
+ description: Beskrivning
69
+ down: Ner
54
70
  question: Fråga
55
- remove_question: Ta bort fråga
71
+ remove: Avlägsna
56
72
  statement: Påstående
73
+ up: Upp
57
74
  update:
58
75
  invalid: Det har varit fel när du sparat undersökningen.
59
76
  success: Undersökningen sparades framgångsrikt.
@@ -62,10 +79,13 @@ sv:
62
79
  multiple_option: Flera alternativ
63
80
  short_answer: Kort svar
64
81
  single_option: Enkelt alternativ
82
+ sorting: Sortering
65
83
  surveys:
66
84
  answer:
67
85
  invalid: Det har förekommit fel vid besvarandet av undersökningen.
68
86
  success: Undersökningen svarades framgångsrikt.
87
+ question:
88
+ max_choices: 'Max val: %{n}'
69
89
  show:
70
90
  answer_survey:
71
91
  anonymous_user_message: <a href="%{sign_in_link}"> Logga in med ditt konto</a> eller <a href="%{sign_up_link}">sign up</a> för att svara på enkäten.
@@ -7,10 +7,6 @@ uk:
7
7
  mandatory: Обов’язкове поле
8
8
  question_type: Різновид
9
9
  decidim:
10
- features:
11
- surveys:
12
- actions:
13
- answer: Відповісти
14
10
  surveys:
15
11
  admin:
16
12
  exports:
@@ -22,7 +18,6 @@ uk:
22
18
  surveys:
23
19
  answer_option:
24
20
  answer_option: Варіант відповіді
25
- remove_answer_option: Вилучити варіант відповіді
26
21
  statement: Висловлювання
27
22
  edit:
28
23
  save: Зберегти
@@ -33,7 +28,6 @@ uk:
33
28
  question:
34
29
  add_answer_option: Додати варіант відповіді
35
30
  question: Питання
36
- remove_question: Видалити питання
37
31
  statement: Висловлювання
38
32
  update:
39
33
  invalid: При збереженні цього опитування сталися помилки.
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ class RenameFeaturesToComponentsAtSurveys < ActiveRecord::Migration[5.1]
4
+ def change
5
+ rename_column :decidim_surveys_surveys, :decidim_feature_id, :decidim_component_id
6
+
7
+ if index_name_exists?(:decidim_surveys_surveys, "index_decidim_surveys_surveys_on_decidim_feature_id")
8
+ rename_index :decidim_surveys_surveys, "index_decidim_surveys_surveys_on_decidim_feature_id", "index_decidim_surveys_surveys_on_decidim_component_id"
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ class AddMaxChoicesToSurveyQuestions < ActiveRecord::Migration[5.1]
4
+ def change
5
+ add_column :decidim_surveys_survey_questions, :max_choices, :integer
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ class AddDescriptionToDecidimSurveyQuestions < ActiveRecord::Migration[5.1]
4
+ def change
5
+ add_column :decidim_surveys_survey_questions, :description, :jsonb
6
+ end
7
+ end
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ class AddChoicesToDecidimSurveyAnswers < ActiveRecord::Migration[5.1]
4
+ class SurveyAnswer < ApplicationRecord
5
+ self.table_name = :decidim_surveys_survey_answers
6
+ end
7
+
8
+ class SurveyQuestion < ApplicationRecord
9
+ self.table_name = :decidim_surveys_survey_questions
10
+ end
11
+
12
+ def up
13
+ add_column :decidim_surveys_survey_answers, :text_body, :text
14
+ add_column :decidim_surveys_survey_answers, :choices, :jsonb, default: []
15
+
16
+ SurveyAnswer.find_each do |answer|
17
+ question = SurveyQuestion.find_by(id: answer.decidim_survey_question_id)
18
+
19
+ if %w(single_option multiple_option).include?(question.question_type)
20
+ answer.update!(choices: answer.body)
21
+ else
22
+ answer.update!(text_body: answer.body.first)
23
+ end
24
+ end
25
+
26
+ remove_column :decidim_surveys_survey_answers, :body
27
+ rename_column :decidim_surveys_survey_answers, :text_body, :body
28
+ end
29
+
30
+ def down
31
+ add_column :decidim_surveys_survey_answers, :jsonb_body, :jsonb, default: []
32
+
33
+ SurveyAnswer.find_each do |answer|
34
+ question = SurveyQuestion.find_by(id: answer.decidim_survey_question_id)
35
+
36
+ if %w(single_option multiple_option).include?(question.question_type)
37
+ answer.update!(jsonb_body: answer.choices)
38
+ else
39
+ answer.update!(jsonb_body: [answer.body])
40
+ end
41
+ end
42
+
43
+ remove_column :decidim_surveys_survey_answers, :choices
44
+
45
+ remove_column :decidim_surveys_survey_answers, :body
46
+ rename_column :decidim_surveys_survey_answers, :jsonb_body, :body
47
+ end
48
+ end
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ class CreateDecidimSurveyAnswerOptions < ActiveRecord::Migration[5.1]
4
+ class SurveyQuestion < ApplicationRecord
5
+ self.table_name = :decidim_surveys_survey_questions
6
+ end
7
+
8
+ class SurveyAnswerOption < ApplicationRecord
9
+ self.table_name = :decidim_surveys_survey_answer_options
10
+ end
11
+
12
+ def up
13
+ create_table :decidim_surveys_survey_answer_options do |t|
14
+ t.references :decidim_survey_question, index: { name: "index_decidim_surveys_answer_options_question_id" }
15
+ t.jsonb :body
16
+ end
17
+
18
+ SurveyQuestion.find_each do |question|
19
+ question.answer_options.each do |answer_option|
20
+ SurveyAnswerOption.create!(
21
+ decidim_survey_question_id: question.id,
22
+ body: answer_option["body"]
23
+ )
24
+ end
25
+ end
26
+
27
+ remove_column :decidim_surveys_survey_questions, :answer_options
28
+ end
29
+
30
+ def down
31
+ add_column :decidim_surveys_survey_questions, :answer_options, :jsonb, default: []
32
+
33
+ SurveyAnswerOption.find_each do |answer_option|
34
+ question = SurveyQuestion.find(answer_option.decidim_survey_question_id)
35
+
36
+ question.answer_options << { "body" => answer_option.body }
37
+
38
+ question.save!
39
+ end
40
+
41
+ drop_table :decidim_surveys_survey_answer_options
42
+ end
43
+ end
@@ -0,0 +1,61 @@
1
+ # frozen_string_literal: true
2
+
3
+ class CreateDecidimSurveyAnswerChoices < ActiveRecord::Migration[5.1]
4
+ class SurveyAnswer < ApplicationRecord
5
+ self.table_name = :decidim_surveys_survey_answers
6
+ end
7
+
8
+ class SurveyAnswerChoice < ApplicationRecord
9
+ self.table_name = :decidim_surveys_survey_answer_choices
10
+ end
11
+
12
+ class SurveyQuestion < ApplicationRecord
13
+ self.table_name = :decidim_surveys_survey_questions
14
+ end
15
+
16
+ class SurveyAnswerOption < ApplicationRecord
17
+ self.table_name = :decidim_surveys_survey_answer_options
18
+ end
19
+
20
+ def up
21
+ create_table :decidim_surveys_survey_answer_choices do |t|
22
+ t.references :decidim_survey_answer, index: { name: "index_decidim_surveys_answer_choices_answer_id" }
23
+ t.references :decidim_survey_answer_option, index: { name: "index_decidim_surveys_answer_choices_answer_option_id" }
24
+ t.jsonb :body
25
+ end
26
+
27
+ SurveyAnswer.find_each do |answer|
28
+ question = SurveyQuestion.find_by(id: answer.decidim_survey_question_id)
29
+
30
+ answer.choices.each do |answer_choice|
31
+ answer_options = SurveyAnswerOption.where(decidim_survey_question_id: question.id)
32
+
33
+ answer_option = answer_options.find do |option|
34
+ option.body.values.include?(answer_choice)
35
+ end
36
+
37
+ SurveyAnswerChoice.create!(
38
+ decidim_survey_answer_id: answer.id,
39
+ decidim_survey_answer_option_id: answer_option.id,
40
+ body: answer_choice
41
+ )
42
+ end
43
+ end
44
+
45
+ remove_column :decidim_surveys_survey_answers, :choices
46
+ end
47
+
48
+ def down
49
+ add_column :decidim_surveys_survey_answers, :choices, :jsonb, default: []
50
+
51
+ SurveyAnswerChoice.find_each do |answer_choice|
52
+ answer = SurveyAnswer.find_by(id: answer_choice.decidim_survey_answer_id)
53
+
54
+ answer.choices << answer_choice.body
55
+
56
+ answer.save!
57
+ end
58
+
59
+ drop_table :decidim_surveys_survey_answer_choices
60
+ end
61
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ class AddFreeTextToSurveyAnswerOptions < ActiveRecord::Migration[5.1]
4
+ def change
5
+ add_column :decidim_surveys_survey_answer_options, :free_text, :boolean
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ class AddCustomBodyToSurveyAnswerChoices < ActiveRecord::Migration[5.1]
4
+ def change
5
+ add_column :decidim_surveys_survey_answer_choices, :custom_body, :text
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ class AddPositionToDecidimSurveyAnswerChoices < ActiveRecord::Migration[5.1]
4
+ def change
5
+ add_column :decidim_surveys_survey_answer_choices, :position, :integer
6
+ end
7
+ end
@@ -3,7 +3,7 @@
3
3
  require "decidim/surveys/admin"
4
4
  require "decidim/surveys/engine"
5
5
  require "decidim/surveys/admin_engine"
6
- require "decidim/surveys/feature"
6
+ require "decidim/surveys/component"
7
7
 
8
8
  module Decidim
9
9
  # This namespace holds the logic of the `Surveys` component. This component
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "jquery-tmpl-rails"
4
-
5
3
  module Decidim
6
4
  module Surveys
7
5
  # This is the engine that runs on the public interface of `Surveys`.
@@ -1,32 +1,32 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "decidim/features/namer"
3
+ require "decidim/components/namer"
4
4
 
5
- Decidim.register_feature(:surveys) do |feature|
6
- feature.engine = Decidim::Surveys::Engine
7
- feature.admin_engine = Decidim::Surveys::AdminEngine
8
- feature.icon = "decidim/surveys/icon.svg"
9
- feature.stylesheet = "decidim/surveys/surveys"
5
+ Decidim.register_component(:surveys) do |component|
6
+ component.engine = Decidim::Surveys::Engine
7
+ component.admin_engine = Decidim::Surveys::AdminEngine
8
+ component.icon = "decidim/surveys/icon.svg"
9
+ component.stylesheet = "decidim/surveys/surveys"
10
10
 
11
- feature.on(:create) do |instance|
11
+ component.on(:create) do |instance|
12
12
  Decidim::Surveys::CreateSurvey.call(instance) do
13
13
  on(:invalid) { raise "Can't create survey" }
14
14
  end
15
15
  end
16
16
 
17
- feature.on(:before_destroy) do |instance|
18
- raise "Can't destroy this feature when there are surveys" if Decidim::Surveys::Survey.where(feature: instance).any?
17
+ component.on(:before_destroy) do |instance|
18
+ raise "Can't destroy this component when there are surveys" if Decidim::Surveys::Survey.where(component: instance).any?
19
19
  end
20
20
 
21
- feature.register_stat :surveys_count do |features, start_at, end_at|
22
- surveys = Decidim::Surveys::Survey.where(feature: features)
21
+ component.register_stat :surveys_count do |components, start_at, end_at|
22
+ surveys = Decidim::Surveys::Survey.where(component: components)
23
23
  surveys = surveys.where("created_at >= ?", start_at) if start_at.present?
24
24
  surveys = surveys.where("created_at <= ?", end_at) if end_at.present?
25
25
  surveys.count
26
26
  end
27
27
 
28
- feature.register_stat :answers_count, priority: Decidim::StatsRegistry::MEDIUM_PRIORITY do |features, start_at, end_at|
29
- surveys = Decidim::Surveys::Survey.where(feature: features)
28
+ component.register_stat :answers_count, priority: Decidim::StatsRegistry::MEDIUM_PRIORITY do |components, start_at, end_at|
29
+ surveys = Decidim::Surveys::Survey.where(component: components)
30
30
  answers = Decidim::Surveys::SurveyAnswer.where(survey: surveys)
31
31
  answers = answers.where("created_at >= ?", start_at) if start_at.present?
32
32
  answers = answers.where("created_at <= ?", end_at) if end_at.present?
@@ -34,46 +34,46 @@ Decidim.register_feature(:surveys) do |feature|
34
34
  end
35
35
 
36
36
  # These actions permissions can be configured in the admin panel
37
- feature.actions = %w(answer)
37
+ component.actions = %w(answer)
38
38
 
39
- feature.settings(:global) do |settings|
39
+ component.settings(:global) do |settings|
40
40
  settings.attribute :announcement, type: :text, translated: true, editor: true
41
41
  end
42
42
 
43
- feature.settings(:step) do |settings|
43
+ component.settings(:step) do |settings|
44
44
  settings.attribute :allow_answers, type: :boolean, default: false
45
45
  settings.attribute :announcement, type: :text, translated: true, editor: true
46
46
  end
47
47
 
48
- # feature.register_resource do |resource|
48
+ # component.register_resource do |resource|
49
49
  # # Register a optional resource that can be references from other resources.
50
50
  # resource.model_class_name = "Decidim::Surveys::SomeResource"
51
51
  # resource.template = "decidim/surveys/some_resources/linked_some_resources"
52
52
  # end
53
53
 
54
- # feature.register_stat :some_stat do |context, start_at, end_at|
54
+ # component.register_stat :some_stat do |context, start_at, end_at|
55
55
  # # Register some stat number to the application
56
56
  # end
57
57
 
58
- feature.exports :survey_user_answers do |exports|
58
+ component.exports :survey_user_answers do |exports|
59
59
  exports.collection do |f|
60
- survey = Decidim::Surveys::Survey.where(feature: f).first
60
+ survey = Decidim::Surveys::Survey.find_by(component: f)
61
61
  Decidim::Surveys::SurveyUserAnswers.for(survey)
62
62
  end
63
63
 
64
64
  exports.serializer Decidim::Surveys::SurveyUserAnswersSerializer
65
65
  end
66
66
 
67
- feature.seeds do |participatory_space|
68
- feature = Decidim::Feature.create!(
69
- name: Decidim::Features::Namer.new(participatory_space.organization.available_locales, :surveys).i18n_name,
67
+ component.seeds do |participatory_space|
68
+ component = Decidim::Component.create!(
69
+ name: Decidim::Components::Namer.new(participatory_space.organization.available_locales, :surveys).i18n_name,
70
70
  manifest_name: :surveys,
71
71
  published_at: Time.current,
72
72
  participatory_space: participatory_space
73
73
  )
74
74
 
75
75
  survey = Decidim::Surveys::Survey.create!(
76
- feature: feature,
76
+ component: component,
77
77
  title: Decidim::Faker::Localized.paragraph,
78
78
  description: Decidim::Faker::Localized.wrapped("<p>", "</p>") do
79
79
  Decidim::Faker::Localized.paragraph(3)
@@ -83,12 +83,24 @@ Decidim.register_feature(:surveys) do |feature|
83
83
  end
84
84
  )
85
85
 
86
- 2.times do
86
+ %w(short_answer long_answer).each do |text_question_type|
87
87
  Decidim::Surveys::SurveyQuestion.create!(
88
88
  survey: survey,
89
89
  body: Decidim::Faker::Localized.paragraph,
90
- question_type: "short_answer"
90
+ question_type: text_question_type
91
91
  )
92
92
  end
93
+
94
+ %w(single_option multiple_option).each do |multiple_choice_question_type|
95
+ question = Decidim::Surveys::SurveyQuestion.create!(
96
+ survey: survey,
97
+ body: Decidim::Faker::Localized.paragraph,
98
+ question_type: multiple_choice_question_type
99
+ )
100
+
101
+ 3.times do
102
+ question.answer_options.create!(body: Decidim::Faker::Localized.sentence)
103
+ end
104
+ end
93
105
  end
94
106
  end