Commit b372312b83c6a2b93cb256eccf98d6a91aff4665

Authored by Pius Uzamere
1 parent 5c4143a7

RAND()

Showing 1 changed file with 2 additions and 2 deletions   Show diff stats
app/models/question.rb
@@ -33,8 +33,8 @@ class Question < ActiveRecord::Base @@ -33,8 +33,8 @@ 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 - @the_choice_ids << choices.active.first(:order => 'RANDOM()', :select => 'id').id  
37 - @the_choice_ids << choices.active.last(:order => 'RANDOM()', :select => 'id').id 36 + @the_choice_ids << choices.active.first(:order => 'RAND()', :select => 'id').id
  37 + @the_choice_ids << choices.active.last(:order => 'RAND()', :select => 'id').id
38 end until @the_choice_ids.size == rank 38 end until @the_choice_ids.size == rank
39 logger.info "set populated and looks like #{@the_choice_ids.inspect}" 39 logger.info "set populated and looks like #{@the_choice_ids.inspect}"
40 return @the_choice_ids.to_a 40 return @the_choice_ids.to_a