1 # -*- coding: utf-8 -*-
2 # This file should contain all the record creation needed to seed the database with its default values.
3 # The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
7 # cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }])
8 # Major.create(:name => 'Daley', :city => cities.first)
10 ActiveRecord::Base.transaction do
11 admin = User.create!(:name => "admin",
12 :email => "admin@example.com",
13 :admission_date => Date.today)
14 hashed_password = EmailCredential.create_hashed_password("monkey")
15 e = admin.email_credentials.build(:email => admin.email,
16 :hashed_password => hashed_password,
17 :activation_token => "1"*20,
18 :activated_at => Time.now)
20 admin.has_role!(:admin)
22 user = User.create!(:name => "user",
23 :email => "user@example.com",
24 :admission_date => Date.today)
25 hashed_password = EmailCredential.create_hashed_password("monkey")
26 e = user.email_credentials.build(:email => user.email,
27 :hashed_password => hashed_password,
28 :activation_token => "2"*20,
29 :activated_at => Time.now)
32 teacher = User.create!(:name => "teacher", :email => "teacher@example.com")
33 hashed_password = EmailCredential.create_hashed_password("monkey")
34 e = teacher.email_credentials.build(:email => teacher.email,
35 :hashed_password => hashed_password,
36 :activation_token => "3"*20,
37 :activated_at => Time.now)
39 teacher.has_role!(:teacher)
42 ["ordinary_arithmetic" , "整数の四則演算"],
43 ["decimal_arithmetic" , "小数の四則演算"],
44 ["fractional_arithmetic" , "分数の四則演算"],
45 ["square_root_arithmetic" , "根号を含む数の計算"],
46 ["complex_number_arithmetic" , "複素数の計算"],
47 ["complex_fractional_arithmetic" , "繁分数の計算"],
48 ["expansion" , "式の展開"],
49 ["factorization" , "因数分解"],
50 ["fractional_expression_arithmetic" , "分数式の計算"],
51 ["partial_fraction_expansion" , "部分分数の展開"],
52 ["linear_function_graph" , "一次関数のグラフ"],
53 ].each do |symbol, name|
54 Unit.create!(:symbol => symbol, :name => name)
57 problem_group = ProblemGroup.new(:label => "整数の四則演算",
58 :description => "与えられた式を計算してください。")
59 problem_group.problems.build(:unit => Unit.find_by_symbol("ordinary_arithmetic"), :level => 0,
62 :minus => true, :min => 0, :max => 10,
64 :operators => %w[+ - * div]
66 problem_group.problems.build(:unit => Unit.find_by_symbol("ordinary_arithmetic"), :level => 1,
69 :minus => true, :min => 0, :max => 100,
71 :operators => %w[+ - * div]
73 problem_group.problems.build(:unit => Unit.find_by_symbol("ordinary_arithmetic"), :level => 2,
76 :minus => true, :min => 0, :max => 100,
78 :operators => %w[+ - * div]
82 problem_group = ProblemGroup.new(:label => "小数の四則演算",
83 :description => "与えられた式を計算してください。")
84 problem_group.problems.build(:unit => Unit.find_by_symbol("decimal_arithmetic"), :level => 0,
87 :minus => true, :digits => 2, :min => 0, :max => 10.0,
89 :operators => %w[+ - * div]
91 problem_group.problems.build(:unit => Unit.find_by_symbol("decimal_arithmetic"), :level => 1,
94 :minus => true, :digits => 2, :min => 0, :max => 100.0,
96 :operators => %w[+ - * div]
100 problem_group = ProblemGroup.new(:label => "分数の四則演算",
101 :description => "与えられた式を計算してください。答えは既約にしてください。")
102 problem_group.problems.build(:unit => Unit.find_by_symbol("fractional_arithmetic"), :level => 0,
106 :numerator_min => 1, :numerator_max => 10,
107 :denominator_min => 2, :denominator_max => 10
109 problem_group.problems.build(:unit => Unit.find_by_symbol("fractional_arithmetic"), :level => 1,
113 :numerator_min => 1, :numerator_max => 20,
114 :denominator_min => 2, :denominator_max => 20
118 problem_group = ProblemGroup.new(:label => "根号を含む数の計算",
119 :description => "与えられた式を計算してください。答えは分母を有理化してください。")
120 problem_group.problems.build(:unit => Unit.find_by_symbol("square_root_arithmetic"), :level => 0,
123 :term_number => 2, :operators => %w[+ -],
124 :min => 1, :max => 50,
125 :single_term_min => 1, :single_term_max => 2,
126 :use_coefficient => true, :use_power => true,
130 problem_group = ProblemGroup.new(:label => "複素数の計算",
131 :description => "与えられた式を計算してください。答えは分母を有理化してください。")
132 problem_group.problems.build(:unit => Unit.find_by_symbol("complex_number_arithmetic"), :level => 0,
135 :term_number => 2, :operators => %w[+ - * /],
136 :min => 0, :max => 30,
137 :fractional_mode => false,
141 problem_group = ProblemGroup.new(:label => "繁分数の計算",
142 :description => "与えられた式を簡単にしてください。")
143 problem_group.problems.build(:unit => Unit.find_by_symbol("complex_fractional_arithmetic"), :level => 0,
146 :operators => %w[+ - *],
147 :numerator_term_min => 1, :numerator_term_max => 2,
148 :denominator_term_min => 2, :denominator_term_max => 2,
152 problem_group = ProblemGroup.new(:label => "因数分解",
153 :description => "与えられた式を因数分解してください。")
154 problem_group.problems.build(:unit => Unit.find_by_symbol("factorization"), :level => 0,
157 :order_min => 2, :order_max => 3, :x => %w[x y z],
158 :factor_minus => true, :factor_min => 0, :factor_max => 10
162 problem_group = ProblemGroup.new(:label => "式展開",
163 :description => "与えられた式を展開してください。")
164 problem_group.problems.build(:unit => Unit.find_by_symbol("expansion"), :level => 0,
167 :order_min => 2, :order_max => 3, :x => %w[x y z],
168 :factor_minus => true, :factor_min => 0, :factor_max => 10
172 problem_group = ProblemGroup.new(:label => "一次関数",
173 :description => <<STR)
174 グラフの P1, P2 はそれぞれ以下のとおりである。
175 このグラフを表す一次関数の式を y = ax + b の形で書け。
178 problem_group.problems.build(:unit => Unit.find_by_symbol("linear_function_graph"), :level => 0,
182 :x_minus => true, :x_min => 0, :x_max => 10,
183 :numerator_min => 1, :numerator_max => 10,
184 :denominator_min => 2, :denominator_max => 5