OSDN Git Service

add complex_fractional_arithmetic, complex_number_arithmetic to db/seeds.rb
[mint/mint-server.git] / db / seeds.rb
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).
4 #
5 # Examples:
6 #   
7 #   cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }])
8 #   Major.create(:name => 'Daley', :city => cities.first)
9
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)
19   e.save!
20   admin.has_role!(:admin)
21
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)
30   e.save!
31
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)
38   e.save!
39   teacher.has_role!(:teacher)
40
41   [
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)
55   end
56
57   problem_group = ProblemGroup.new(:label => "整数の四則演算",
58                                    :description => "与えられた式を計算してください。")
59   problem_group.problems.build(:unit => Unit.find_by_symbol("ordinary_arithmetic"), :level => 0,
60                                :amount => 2,
61                                :options => {
62                                  :minus => true, :min => 0, :max => 10,
63                                  :term_number => 2,
64                                  :operators => %w[+ - * div]
65                                }.to_json)
66   problem_group.problems.build(:unit => Unit.find_by_symbol("ordinary_arithmetic"), :level => 1,
67                                :amount => 2,
68                                :options => {
69                                  :minus => true, :min => 0, :max => 100,
70                                  :term_number => 2,
71                                  :operators => %w[+ - * div]
72                                }.to_json)
73   problem_group.problems.build(:unit => Unit.find_by_symbol("ordinary_arithmetic"), :level => 2,
74                                :amount => 2,
75                                :options => {
76                                  :minus => true, :min => 0, :max => 100,
77                                  :term_number => 3,
78                                  :operators => %w[+ - * div]
79                                }.to_json)
80   problem_group.save!
81
82   problem_group = ProblemGroup.new(:label => "小数の四則演算",
83                                    :description => "与えられた式を計算してください。")
84   problem_group.problems.build(:unit => Unit.find_by_symbol("decimal_arithmetic"), :level => 0,
85                                :amount => 2,
86                                :options => {
87                                  :minus => true, :digits => 2, :min => 0, :max => 10.0,
88                                  :term_number => 2,
89                                  :operators => %w[+ - * div]
90                                }.to_json)
91   problem_group.problems.build(:unit => Unit.find_by_symbol("decimal_arithmetic"), :level => 1,
92                                :amount => 2,
93                                :options => {
94                                  :minus => true, :digits => 2, :min => 0, :max => 100.0,
95                                  :term_number => 3,
96                                  :operators => %w[+ - * div]
97                                }.to_json)
98   problem_group.save!
99
100   problem_group = ProblemGroup.new(:label => "分数の四則演算",
101                                    :description => "与えられた式を計算してください。答えは既約にしてください。")
102   problem_group.problems.build(:unit => Unit.find_by_symbol("fractional_arithmetic"), :level => 0,
103                                :amount => 2,
104                                :options => {
105                                  :minus => true,
106                                  :numerator_min => 1, :numerator_max => 10,
107                                  :denominator_min => 2, :denominator_max => 10
108                                }.to_json)
109   problem_group.problems.build(:unit => Unit.find_by_symbol("fractional_arithmetic"), :level => 1,
110                                :amount => 2,
111                                :options => {
112                                  :minus => true,
113                                  :numerator_min => 1, :numerator_max => 20,
114                                  :denominator_min => 2, :denominator_max => 20
115                                }.to_json)
116   problem_group.save!
117
118   problem_group = ProblemGroup.new(:label => "根号を含む数の計算",
119                                    :description => "与えられた式を計算してください。答えは分母を有理化してください。")
120   problem_group.problems.build(:unit => Unit.find_by_symbol("square_root_arithmetic"), :level => 0,
121                                :amount => 2,
122                                :options => {
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,
127                                }.to_json)
128   problem_group.save!
129
130   problem_group = ProblemGroup.new(:label => "複素数の計算",
131                                    :description => "与えられた式を計算してください。答えは分母を有理化してください。")
132   problem_group.problems.build(:unit => Unit.find_by_symbol("complex_number_arithmetic"), :level => 0,
133                                :amount => 2,
134                                :options => {
135                                  :term_number => 2, :operators => %w[+ - * /],
136                                  :min => 0, :max => 30,
137                                  :fractional_mode => false,
138                                }.to_json)
139   problem_group.save!
140
141   problem_group = ProblemGroup.new(:label => "繁分数の計算",
142                                    :description => "与えられた式を簡単にしてください。")
143   problem_group.problems.build(:unit => Unit.find_by_symbol("complex_fractional_arithmetic"), :level => 0,
144                                :amount => 2,
145                                :options => {
146                                  :operators => %w[+ - *],
147                                  :numerator_term_min => 1, :numerator_term_max => 2,
148                                  :denominator_term_min => 2, :denominator_term_max => 2,
149                                }.to_json)
150   problem_group.save!
151
152   problem_group = ProblemGroup.new(:label => "因数分解",
153                                    :description => "与えられた式を因数分解してください。")
154   problem_group.problems.build(:unit => Unit.find_by_symbol("factorization"), :level => 0,
155                                :amount => 2,
156                                :options => {
157                                  :order_min => 2, :order_max => 3, :x => %w[x y z],
158                                  :factor_minus => true, :factor_min => 0, :factor_max => 10
159                                }.to_json)
160   problem_group.save!
161
162   problem_group = ProblemGroup.new(:label => "式展開",
163                                    :description => "与えられた式を展開してください。")
164   problem_group.problems.build(:unit => Unit.find_by_symbol("expansion"), :level => 0,
165                                :amount => 2,
166                                :options =>  {
167                                  :order_min => 2, :order_max => 3, :x => %w[x y z],
168                                  :factor_minus => true, :factor_min => 0, :factor_max => 10
169                                }.to_json)
170   problem_group.save!
171
172   problem_group = ProblemGroup.new(:label => "一次関数",
173                                    :description => <<STR)
174 グラフの P1, P2 はそれぞれ以下のとおりである。
175 このグラフを表す一次関数の式を y = ax + b の形で書け。
176 ただし a, b は有理数である。
177 STR
178   problem_group.problems.build(:unit => Unit.find_by_symbol("linear_function_graph"), :level => 0,
179                                :amount => 1,
180                                :options =>  {
181                                  :minus => true,
182                                  :x_minus => true, :x_min => 0, :x_max => 10,
183                                  :numerator_min => 1, :numerator_max => 10,
184                                  :denominator_min => 2, :denominator_max => 5
185                                }.to_json)
186   problem_group.save!
187 end
188