aboutsummaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
authorJoachim Filip Ignacy Bartosik <jbartosik@gmail.com>2010-07-08 13:14:35 +0200
committerJoachim Filip Ignacy Bartosik <jbartosik@gmail.com>2010-07-12 19:17:19 +0200
commit1aa5c8ff43a7435ddfe9c3d1578de45b94cad85a (patch)
treee4a63f85795c2a98efe84adc56f747a131884c89 /db
parentRecruits get feedback on their answers (diff)
downloadrecruiting-webapp-1aa5c8ff43a7435ddfe9c3d1578de45b94cad85a.tar.gz
recruiting-webapp-1aa5c8ff43a7435ddfe9c3d1578de45b94cad85a.tar.bz2
recruiting-webapp-1aa5c8ff43a7435ddfe9c3d1578de45b94cad85a.zip
Add an example multiple choice question to seed
Diffstat (limited to 'db')
-rw-r--r--db/fixtures/questions-multichoice.yml6
-rw-r--r--db/seeds.rb10
2 files changed, 16 insertions, 0 deletions
diff --git a/db/fixtures/questions-multichoice.yml b/db/fixtures/questions-multichoice.yml
new file mode 100644
index 0000000..58fe2b9
--- /dev/null
+++ b/db/fixtures/questions-multichoice.yml
@@ -0,0 +1,6 @@
+multichoice_q1:
+ title: Fake multiple choice
+ documentation: Fake
+ question_category: ebuild
+ content: Some question
+ options: Option 1; Option 2; Option 3
diff --git a/db/seeds.rb b/db/seeds.rb
index cc36215..c15d38b 100644
--- a/db/seeds.rb
+++ b/db/seeds.rb
@@ -61,6 +61,16 @@ seeder.read_yaml('db/fixtures/questions.yml', Question, ['question_category', 'q
objects["#{name}-content"] = QuestionContentText.create! :question => objects[name], :content => hash['content']
end
+# Questions with multiple choice content - load from YAML file
+seeder.read_yaml('db/fixtures/questions-multichoice.yml', Question, ['question_category', 'question_group']) do |name, hash, objects, klass|
+ objects[name] = klass.create!(hash - {'options' => nil, 'content' => nil})
+ objects["#{name}-content"] = QuestionContentMultipleChoice.create! :question => objects[name], :content => hash['content']
+ for opt in hash['options'].split(';')
+ opt.strip!
+ Option.create! :content => opt, :option_owner => objects["#{name}-content"]
+ end
+end
+
# Users - load from YAML file
seeder.read_yaml 'db/fixtures/users.yml', User, 'mentor'