Commit 5c4143a7ad4f6a34a3ac0d5b412d2aec3634075b

Authored by Pius Uzamere
2 parents 6eb519b7 06017fb7

merged fix

Showing 1 changed file with 5 additions and 3 deletions   Show diff stats
app/models/question.rb
@@ -21,7 +21,7 @@ class Question < ActiveRecord::Base @@ -21,7 +21,7 @@ class Question < ActiveRecord::Base
21 def item_count 21 def item_count
22 choices_count 22 choices_count
23 end 23 end
24 - 24 +
25 #TODO: generalize for prompts of rank > 2 25 #TODO: generalize for prompts of rank > 2
26 #TODO: add index for rapid finding 26 #TODO: add index for rapid finding
27 def picked_prompt(rank = 2) 27 def picked_prompt(rank = 2)
@@ -33,9 +33,11 @@ class Question < ActiveRecord::Base @@ -33,9 +33,11 @@ class Question < ActiveRecord::Base
33 def distinct_array_of_choice_ids(rank = 2, only_active = true) 33 def distinct_array_of_choice_ids(rank = 2, only_active = true)
34 begin 34 begin
35 @the_choice_ids = Set.new 35 @the_choice_ids = Set.new
36 - rank.times { @the_choice_ids << choices.active.first(:order => 'RANDOM()', :select => 'id').id } 36 + @the_choice_ids << choices.active.first(:order => 'RANDOM()', :select => 'id').id
  37 + @the_choice_ids << choices.active.last(:order => 'RANDOM()', :select => 'id').id
37 end until @the_choice_ids.size == rank 38 end until @the_choice_ids.size == rank
38 - @the_choice_ids.to_a 39 + logger.info "set populated and looks like #{@the_choice_ids.inspect}"
  40 + return @the_choice_ids.to_a
39 end 41 end
40 42
41 def picked_prompt_id 43 def picked_prompt_id