From b33fca9dba43af03917a7003da40f5057499fb33 Mon Sep 17 00:00:00 2001 From: Pius Uzamere Date: Sun, 20 Dec 2009 09:33:35 -0500 Subject: [PATCH] avoiding the database randomization function --- app/models/question.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/models/question.rb b/app/models/question.rb index f8cb48a..911b3b6 100644 --- a/app/models/question.rb +++ b/app/models/question.rb @@ -34,10 +34,12 @@ class Question < ActiveRecord::Base memoize :picked_prompt def distinct_array_of_choice_ids(rank = 2, only_active = true) + @choice_ids = choice_ids + @s = @choice_ids.size begin - @the_choice_ids = Set.new - @the_choice_ids << choices.active.first(:order => 'RAND()', :select => 'id').id - @the_choice_ids << choices.active.last(:order => 'RAND()', :select => 'id').id + @the_choice_ids = Set.new(@choice_ids.values_at(rand(@s), rand(@s))) + # @the_choice_ids << choices.active.first(:order => 'RAND()', :select => 'id').id + # @the_choice_ids << choices.active.last(:order => 'RAND()', :select => 'id').id end until @the_choice_ids.size == rank logger.info "set populated and looks like #{@the_choice_ids.inspect}" return @the_choice_ids.to_a -- libgit2 0.21.2