| Module | Algorithms::Prompt |
| In: |
lib/algorithms/prompt.rb
|
# File lib/algorithms/prompt.rb, line 39
39: def conditions(question_id)
40: {
41: :joins => "INNER JOIN items_questions ON (items_questions.question_id=#{question_id} AND items_questions.item_id=items.id)",
42: :conditions => { :active => true },
43: }
44: end
Generate count number of prompts based on question and voter. Choose generation algorithm based on prime.
An array of prompts
| question_id<int>: | Prompts for this question ID. |
| voter_id<int>: | Prompts for this voter ID. |
| count<int>: | This number of prompts. |
| prompt<bool>: | If true primed prompts are generated, otherwise random |
prompts are generated.
# File lib/algorithms/prompt.rb, line 12
12: def create_prompts(question_id, voter_id, count, algo)
13: srand if PRODUCTION
14: case algo
15: when 2
16: prompts = Algorithms::Prompt::Popular.prompts(question_id, voter_id, count)
17: when 3
18: prompts = Algorithms::Prompt::Extremes.prompts(question_id, voter_id, count)
19: end
20: prompts || Algorithms::Prompt::Random.prompts(question_id, voter_id, count)
21: end