Description:
added test_pair model
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r209:491c30075d87 - - 6 files changed: 47 inserted, 1 deleted

@@ -0,0 +1,3
1 + class TestPair < ActiveRecord::Base
2 + belongs_to :problem
3 + end
@@ -0,0 +1,15
1 + class CreateTestPairs < ActiveRecord::Migration
2 + def self.up
3 + create_table :test_pairs do |t|
4 + t.integer :problem_id
5 + t.text :input
6 + t.text :solution
7 +
8 + t.timestamps
9 + end
10 + end
11 +
12 + def self.down
13 + drop_table :test_pairs
14 + end
15 + end
@@ -0,0 +1,11
1 + # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
2 +
3 + one:
4 + problem_id: 1
5 + input: MyText
6 + solution: MyText
7 +
8 + two:
9 + problem_id: 1
10 + input: MyText
11 + solution: MyText
@@ -0,0 +1,8
1 + require 'test_helper'
2 +
3 + class TestPairTest < ActiveSupport::TestCase
4 + # Replace this with your real tests.
5 + test "the truth" do
6 + assert true
7 + end
8 + end
@@ -1,27 +1,28
1 1 class Problem < ActiveRecord::Base
2 2
3 3 belongs_to :description
4 + has_many :test_pairs
4 5
5 6 validates_presence_of :name
6 7 validates_format_of :name, :with => /^\w+$/
7 8 validates_presence_of :full_name
8 9
9 10 DEFAULT_TIME_LIMIT = 1
10 11 DEFAULT_MEMORY_LIMIT = 32
11 12
12 13 def self.find_available_problems
13 14 find(:all, :conditions => {:available => true}, :order => "date_added DESC")
14 15 end
15 16
16 17 def self.new_from_import_form_params(params)
17 18 problem = Problem.new
18 19 import_params = Problem.extract_params_and_check(params, problem)
19 20
20 21 if not problem.valid?
21 22 return problem
22 23 end
23 24
24 25 importer = TestdataImporter.new
25 26
26 27 if not importer.import_from_file(problem.name,
27 28 import_params[:file],
@@ -1,36 +1,36
1 1 # This file is auto-generated from the current state of the database. Instead of editing this file,
2 2 # please use the migrations feature of Active Record to incrementally modify your database, and
3 3 # then regenerate this schema definition.
4 4 #
5 5 # Note that this schema.rb definition is the authoritative source for your database schema. If you need
6 6 # to create the application database on another system, you should be using db:schema:load, not running
7 7 # all the migrations from scratch. The latter is a flawed and unsustainable approach (the more migrations
8 8 # you'll amass, the slower it'll run and the greater likelihood for issues).
9 9 #
10 10 # It's strongly recommended to check this file into your version control system.
11 11
12 - ActiveRecord::Schema.define(:version => 20090815171610) do
12 + ActiveRecord::Schema.define(:version => 20100113094740) do
13 13
14 14 create_table "announcements", :force => true do |t|
15 15 t.string "author"
16 16 t.text "body"
17 17 t.boolean "published"
18 18 t.datetime "created_at"
19 19 t.datetime "updated_at"
20 20 t.boolean "frontpage", :default => false
21 21 t.boolean "contest_only", :default => false
22 22 t.string "title"
23 23 end
24 24
25 25 create_table "configurations", :force => true do |t|
26 26 t.string "key"
27 27 t.string "value_type"
28 28 t.string "value"
29 29 t.datetime "created_at"
30 30 t.datetime "updated_at"
31 31 end
32 32
33 33 create_table "countries", :force => true do |t|
34 34 t.string "name"
35 35 t.datetime "created_at"
36 36 t.datetime "updated_at"
@@ -134,48 +134,56
134 134 t.integer "problem_id"
135 135 t.integer "language_id"
136 136 t.text "source"
137 137 t.binary "binary"
138 138 t.datetime "submitted_at"
139 139 t.datetime "compiled_at"
140 140 t.text "compiler_message"
141 141 t.datetime "graded_at"
142 142 t.integer "points"
143 143 t.text "grader_comment"
144 144 t.integer "number"
145 145 t.string "source_filename"
146 146 end
147 147
148 148 add_index "submissions", ["user_id", "problem_id", "number"], :name => "index_submissions_on_user_id_and_problem_id_and_number", :unique => true
149 149 add_index "submissions", ["user_id", "problem_id"], :name => "index_submissions_on_user_id_and_problem_id"
150 150
151 151 create_table "tasks", :force => true do |t|
152 152 t.integer "submission_id"
153 153 t.datetime "created_at"
154 154 t.integer "status"
155 155 t.datetime "updated_at"
156 156 end
157 157
158 + create_table "test_pairs", :force => true do |t|
159 + t.integer "problem_id"
160 + t.text "input"
161 + t.text "solution"
162 + t.datetime "created_at"
163 + t.datetime "updated_at"
164 + end
165 +
158 166 create_table "test_requests", :force => true do |t|
159 167 t.integer "user_id"
160 168 t.integer "problem_id"
161 169 t.integer "submission_id"
162 170 t.string "input_file_name"
163 171 t.string "output_file_name"
164 172 t.string "running_stat"
165 173 t.integer "status"
166 174 t.datetime "updated_at"
167 175 t.datetime "submitted_at"
168 176 t.datetime "compiled_at"
169 177 t.text "compiler_message"
170 178 t.datetime "graded_at"
171 179 t.string "grader_comment"
172 180 t.datetime "created_at"
173 181 t.float "running_time"
174 182 t.string "exit_status"
175 183 t.integer "memory_usage"
176 184 end
177 185
178 186 add_index "test_requests", ["user_id", "problem_id"], :name => "index_test_requests_on_user_id_and_problem_id"
179 187
180 188 create_table "users", :force => true do |t|
181 189 t.string "login", :limit => 50
You need to be logged in to leave comments. Login now