public
Description: BrainBuster - a logic captcha for Rails
Homepage: http://opensource.thinkrelevance.com/wiki/BrainBuster
Clone URL: git://github.com/rsanheim/brain_buster.git
rsanheim (author)
Mon Jun 29 13:54:03 -0700 2009
commit  5854ddbef46e75f2f1ae75746687c4fb997364bf
tree    548a040a3c2a7fcc90338e3da14fb3ad5f2a4e26
parent  e910b2addbbafe0a2b473c2272ecf3ec5412ea4e
100644 40 lines (35 sloc) 1.528 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
class <%= class_name %> < ActiveRecord::Migration
class BrainBuster < ActiveRecord::Base; end;
def self.up
create_table "<%= migration_table_name %>", :force => true do |t|
      t.column :question, :string
      t.column :answer, :string
    end
    
    create "What is two plus two?", "4"
    create "What is the number before twelve?", "11"
    create "Five times two is what?", "10"
    create "Insert the next number in this sequence: 10, 11, 12, 13, 14, ??", "15"
    create "What is five times five?", "25"
    create "Ten divided by two is what?", "5"
    create "What day comes after Monday?", "tuesday"
    create "What is the last month of the year?", "december"
    create "How many minutes are in an hour?", "60"
    create "What is the opposite of down?", "up"
    create "What is the opposite of north?", "south"
    create "What is the opposite of bad?", "good"
    create "Complete the following: 'Jack and Jill went up the ???", "hill"
    create "What is 4 times four?", "16"
    create "What number comes after 20?", "21"
    create "What month comes before July?", "june"
    create "What is fifteen divided by three?", "5"
    create "What is 14 minus 4?", "10"
    create "What comes next? 'Monday Tuesday Wednesday ?????'", "Thursday"
  end
 
  def self.down
    drop_table "<%= migration_table_name %>"
  end
  
  # create a logic captcha - answers should be lower case
  def self.create(question, answer)
    BrainBuster.create(:question => question, :answer => answer.downcase)
  end
  
end