Skip to content

Commit

Permalink
Add new poll sample with all kind of questions
Browse files Browse the repository at this point in the history
  • Loading branch information
Senen committed Aug 3, 2023
1 parent d4f8a66 commit 69cec38
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 275 deletions.
2 changes: 1 addition & 1 deletion db/dev_seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def random_locales_attributes(**attribute_names_with_values)
require_relative "dev_seeds/flags"
require_relative "dev_seeds/hiddings"
require_relative "dev_seeds/banners"
require_relative "dev_seeds/polls"
require_relative "dev_seeds/surveys"
require_relative "dev_seeds/communities"
require_relative "dev_seeds/legislation_processes"
require_relative "dev_seeds/newsletters"
Expand Down
274 changes: 0 additions & 274 deletions db/dev_seeds/polls.rb

This file was deleted.

34 changes: 34 additions & 0 deletions db/dev_seeds/surveys.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
require_dependency "poll/answer"
require_dependency "poll/question/answer"

section "Creating surveys" do
name = "Testing all kind of questions"
poll = Poll.create!(name: name,
slug: name.parameterize,
starts_at: 7.days.ago,
ends_at: 1.year.from_now,
geozone_restricted: false)

author = Administrator.first.user

Poll::Question.create!(title: "Open answer question (Optional)", poll: poll, kind: :open_answer, mandatory_answer: false, author: author)
Poll::Question.create!(title: "Open answer question (Required)", poll: poll, kind: :open_answer, mandatory_answer: true, author: author)

question = Poll::Question.create!(title: "Single choice question (Optional)", poll: poll, kind: :single_choice, mandatory_answer: false, author: author)
%w[A B C].each_with_index do |option, index|
Poll::Question::Answer.create!(title: "Single choice question answer #{option}", question: question, given_order: index + 1)
end
question = Poll::Question.create!(title: "Single choice question (Required)", poll: poll, kind: :single_choice, mandatory_answer: true, author: author)
%w[A B C].each_with_index do |option, index|
Poll::Question::Answer.create!(title: "Single choice question answer #{option}", question: question, given_order: index + 1)
end

question = Poll::Question.create!(title: "Multiple choice question (Optional)", poll: poll, kind: :multiple_choice, mandatory_answer: false, author: author)
%w[X Y W Z].each_with_index do |option, index|
Poll::Question::Answer.create!(title: "Multiple choice question answer #{option}", question: question, given_order: index + 1)
end
question = Poll::Question.create!(title: "Multiple choice question (Required)", poll: poll, kind: :multiple_choice, mandatory_answer: true, author: author)
%w[X Y W Z].each_with_index do |option, index|
Poll::Question::Answer.create!(title: "Multiple choice question answer #{option}", question: question, given_order: index + 1)
end
end

0 comments on commit 69cec38

Please sign in to comment.