Commit 82c86c12695cd4b6e86199a7c02b21c7c1af66ce
1 parent
0a1c2a36
Exists in
master
and in
1 other branch
Removed set from picked_prompt to ensure randomness.
Showing
1 changed file
with
4 additions
and
4 deletions
Show diff stats
app/models/question.rb
... | ... | @@ -37,18 +37,18 @@ class Question < ActiveRecord::Base |
37 | 37 | end until @p.active? |
38 | 38 | return @p |
39 | 39 | end |
40 | - memoize :picked_prompt | |
41 | 40 | |
42 | 41 | def distinct_array_of_choice_ids(rank = 2, only_active = true) |
43 | 42 | @choice_ids = choice_ids |
44 | 43 | @s = @choice_ids.size |
45 | 44 | begin |
46 | - first_one, second_one = rand(@s), rand(@s) | |
47 | - @the_choice_ids = Set.new(@choice_ids.values_at(first_one, second_one)) | |
45 | + index_list = (0...@s).sort_by{rand} | |
46 | + first_one, second_one = index_list.first, index_list.second | |
47 | + @the_choice_ids = @choice_ids.values_at(first_one, second_one) | |
48 | 48 | # @the_choice_ids << choices.active.first(:order => 'RAND()', :select => 'id').id |
49 | 49 | # @the_choice_ids << choices.active.last(:order => 'RAND()', :select => 'id').id |
50 | 50 | end until (@the_choice_ids.size == rank) |
51 | - logger.info "set populated and looks like #{@the_choice_ids.inspect}" | |
51 | + logger.info "List populated and looks like #{@the_choice_ids.inspect}" | |
52 | 52 | return @the_choice_ids.to_a |
53 | 53 | end |
54 | 54 | ... | ... |