diff options
-rw-r--r-- | app/models/answer.rb | 2 | ||||
-rw-r--r-- | db/schema.rb | 4 | ||||
-rw-r--r-- | db/seeds.rb | 2 | ||||
-rw-r--r-- | features/step_definitions/multiple_choice_question_steps.rb | 2 | ||||
-rw-r--r-- | lib/rich_types/check_list.rb | 10 |
5 files changed, 9 insertions, 11 deletions
diff --git a/app/models/answer.rb b/app/models/answer.rb index f8ab11f..3daa701 100644 --- a/app/models/answer.rb +++ b/app/models/answer.rb @@ -5,7 +5,7 @@ class Answer < ActiveRecord::Base hobo_model # Don't put anything above this fields do - content HoboFields::MarkdownString, :null => false + content HoboFields::MarkdownString, :null => false, :default => '' approved :boolean, :default => false reference :boolean, :default => false feedback HoboFields::EnumString.for('', 'Documentation ok', diff --git a/db/schema.rb b/db/schema.rb index b79b86f..c988035 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -9,10 +9,10 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20100805164943) do +ActiveRecord::Schema.define(:version => 20100809160102) do create_table "answers", :force => true do |t| - t.text "content", :null => false + t.text "content", :default => "", :null => false t.boolean "approved", :default => false t.boolean "reference", :default => false t.datetime "created_at" diff --git a/db/seeds.rb b/db/seeds.rb index afed2eb..4d06bc3 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -103,7 +103,7 @@ end ebuild_q = ['ebuild_q1', 'ebuild_q2', 'ebuild_q3'] mentor_q = ['mentor_q1', 'mentor_q2', 'mentor_q3'] -non_q = ['non_q1', 'non_q', 'non_q3'] +non_q = ['non_q1', 'non_q2'] # non-approved answers ans_hash = {:content => 'Some answer'} diff --git a/features/step_definitions/multiple_choice_question_steps.rb b/features/step_definitions/multiple_choice_question_steps.rb index e44d7f2..5b3fa7a 100644 --- a/features/step_definitions/multiple_choice_question_steps.rb +++ b/features/step_definitions/multiple_choice_question_steps.rb @@ -1,7 +1,7 @@ Given /^a multiple choice content "([^\"]*)"$/ do |content| @content = QuestionContentMultipleChoice.find_by_content(content) if @content.nil? - @content = QuestionContentMultipleChoice.create! :content => content + @content = QuestionContentMultipleChoice.create! :content => content, :question_id => 1 end end diff --git a/lib/rich_types/check_list.rb b/lib/rich_types/check_list.rb index fe8986b..57510a6 100644 --- a/lib/rich_types/check_list.rb +++ b/lib/rich_types/check_list.rb @@ -32,7 +32,7 @@ module RichTypes elsif klass == String # Convert to Array and use = for Arrays - self.options = what.split(',').inject(Array.new){|r, c| r.push c.to_i} + self.options = YAML::load(what) elsif klass == NilClass for i in @opt_list.keys @@ -42,11 +42,9 @@ module RichTypes end def to_s - result = "" - for i in @opt_list.keys - result += i.to_s + "," if @opt_list[i][:checked] - end - result.chop + selected = @opt_list.collect{ |x| x[0] if x[1][:checked] } + selected = selected.flatten.uniq.compact.sort + selected.to_yaml.strip end protected |