Description:
saves submitted output, checks time outs; updated submission front-end flows
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r383:31aa87b1b1e9 - - 8 files changed: 116 inserted, 20 deleted
@@ -0,0 +1,5 | |||
|
1 | + class AddOutputToSubmissions < ActiveRecord::Migration | |
|
2 | + def change | |
|
3 | + add_column :submissions, :output, :text | |
|
4 | + end | |
|
5 | + end |
@@ -1,37 +1,77 | |||
|
1 | 1 | var TOIContest = { |
|
2 | 2 | NO_TIMEOUT: -1, |
|
3 | + SUBMISSION_TIMEOUT: 300, | |
|
3 | 4 | |
|
4 | 5 | timeOuts: {}, |
|
6 | + timeStarted: 0, | |
|
5 | 7 | |
|
6 | 8 | problemSelectClick: function() { |
|
7 | 9 | $$(".submission-submit-divs").each(function(item) { |
|
8 | 10 | item.hide(); |
|
9 | 11 | }); |
|
10 | 12 | var problem_id = $('submission_problem_id').value; |
|
11 | 13 | if ( problem_id < 0 ) { |
|
12 | 14 | return; |
|
13 | 15 | } |
|
14 | 16 | $("submission_submit_div_" + problem_id + "_id").show(); |
|
15 | 17 | }, |
|
16 | 18 | |
|
17 | - confirmDownload: function() { | |
|
18 | - return confirm("แน่ใจ?"); | |
|
19 | + confirmDownload: function(pid) { | |
|
20 | + result = confirm("คุณแน่ใจที่จะส่งข้อนี้หรือไม่?\nเมื่อคุณดาวน์โหลดข้อมูลชุดทดสอบแล้ว คุณจะต้องส่งข้อมูลส่งออกและโปรแกรมภายในเวลา 5 นาที"); | |
|
21 | + if ( result ) { | |
|
22 | + if ( TOIContest.timeOuts[ pid ] == TOIContest.NO_TIMEOUT ) { | |
|
23 | + TOIContest.refreshTimeOuts(); | |
|
24 | + | |
|
25 | + TOIContest.timeOuts[ pid ] = TOIContest.SUBMISSION_TIMEOUT; | |
|
26 | + | |
|
27 | + TOIContest.refreshTimeOutMessages(); | |
|
28 | + } | |
|
29 | + } | |
|
30 | + return result; | |
|
19 | 31 | }, |
|
20 | 32 | |
|
21 | 33 | refreshTimeOutMessages: function() { |
|
22 | 34 | for ( var pid in TOIContest.timeOuts ) { |
|
23 | 35 | var timeOut = TOIContest.timeOuts[ pid ]; |
|
24 | 36 | if ( timeOut != TOIContest.NO_TIMEOUT ) { |
|
25 | 37 | if ( timeOut > 0 ) { |
|
26 | 38 | var minLeft = parseInt(timeOut / 60); |
|
27 | 39 | var secLeft = parseInt(timeOut % 60); |
|
28 | 40 | $('submission_time_left_' + pid + '_id').innerHTML = '| <b>เหลือเวลาอีก ' + minLeft + ':' + secLeft + ' นาที</b>'; |
|
41 | + $('submission_form_'+ pid + '_id').show(); | |
|
29 | 42 | } else { |
|
30 | 43 | $('submission_time_left_' + pid + '_id').innerHTML = '| <b>หมดเวลาส่ง</a>'; |
|
31 | 44 | $('submission_form_'+ pid + '_id').hide(); |
|
32 | 45 | } |
|
33 | - } | |
|
46 | + } else { | |
|
47 | + $('submission_form_'+ pid + '_id').hide(); | |
|
34 | 48 | } |
|
35 | 49 | } |
|
50 | + }, | |
|
51 | + | |
|
52 | + refreshTimeOuts: function() { | |
|
53 | + if ( TOIContest.timeStarted == 0 ) { | |
|
54 | + TOIContest.timeStarted = (new Date()).getTime(); | |
|
55 | + } | |
|
56 | + | |
|
57 | + var timeElapsed = ((new Date()).getTime() - TOIContest.timeStarted)/1000; | |
|
58 | + for ( var pid in TOIContest.timeOuts ) { | |
|
59 | + var timeOut = TOIContest.timeOuts[ pid ]; | |
|
60 | + if ( timeOut > timeElapsed ) { | |
|
61 | + TOIContest.timeOuts[ pid ] -= timeElapsed; | |
|
62 | + } else if ( timeOut > 0 ) { | |
|
63 | + TOIContest.timeOuts[ pid ] = 0; | |
|
64 | + } | |
|
65 | + } | |
|
66 | + }, | |
|
67 | + | |
|
68 | + registerRefreshEvent: function() { | |
|
69 | + TOIContest.timeStarted = (new Date()).getTime(); | |
|
70 | + setTimeout(function () { | |
|
71 | + TOIContest.refreshTimeOuts(); | |
|
72 | + TOIContest.refreshTimeOutMessages(); | |
|
73 | + TOIContest.registerRefreshEvent(); | |
|
74 | + }, 1000); | |
|
75 | + }, | |
|
36 | 76 | }; |
|
37 | 77 |
@@ -1,482 +1,512 | |||
|
1 | + # coding: utf-8 | |
|
1 | 2 | class MainController < ApplicationController |
|
2 | 3 | |
|
3 | 4 | before_filter :authenticate, :except => [:index, :login] |
|
4 | 5 | before_filter :check_viewability, :except => [:index, :login] |
|
5 | 6 | |
|
6 | 7 | append_before_filter :confirm_and_update_start_time, |
|
7 | 8 | :except => [:index, |
|
8 | 9 | :login, |
|
9 | 10 | :confirm_contest_start] |
|
10 | 11 | |
|
11 | 12 | # to prevent log in box to be shown when user logged out of the |
|
12 | 13 | # system only in some tab |
|
13 | 14 | prepend_before_filter :reject_announcement_refresh_when_logged_out, |
|
14 | 15 | :only => [:announcements] |
|
15 | 16 | |
|
16 | 17 | # COMMENTED OUT: filter in each action instead |
|
17 | 18 | # before_filter :verify_time_limit, :only => [:submit] |
|
18 | 19 | |
|
19 | 20 | verify :method => :post, :only => [:submit], |
|
20 | 21 | :redirect_to => { :action => :index } |
|
21 | 22 | |
|
22 | 23 | # COMMENT OUT: only need when having high load |
|
23 | 24 | # caches_action :index, :login |
|
24 | 25 | |
|
25 | 26 | # NOTE: This method is not actually needed, 'config/routes.rb' has |
|
26 | 27 | # assigned action login as a default action. |
|
27 | 28 | def index |
|
28 | 29 | redirect_to :action => 'login' |
|
29 | 30 | end |
|
30 | 31 | |
|
31 | 32 | def login |
|
32 | 33 | saved_notice = flash[:notice] |
|
33 | 34 | reset_session |
|
34 | 35 | flash.now[:notice] = saved_notice |
|
35 | 36 | |
|
36 | 37 | # EXPERIMENT: |
|
37 | 38 | # Hide login if in single user mode and the url does not |
|
38 | 39 | # explicitly specify /login |
|
39 | 40 | # |
|
40 | 41 | # logger.info "PATH: #{request.path}" |
|
41 | 42 | # if GraderConfiguration['system.single_user_mode'] and |
|
42 | 43 | # request.path!='/main/login' |
|
43 | 44 | # @hidelogin = true |
|
44 | 45 | # end |
|
45 | 46 | |
|
46 | 47 | @announcements = Announcement.find_for_frontpage |
|
47 | 48 | render :action => 'login', :layout => 'empty' |
|
48 | 49 | end |
|
49 | 50 | |
|
50 | 51 | def list |
|
52 | + if session[:current_problem_id] | |
|
53 | + @current_problem = Problem.find(session[:current_problem_id]) | |
|
54 | + session[:current_problem_id] = nil | |
|
55 | + end | |
|
51 | 56 | prepare_list_information |
|
52 | 57 | end |
|
53 | 58 | |
|
54 | 59 | def help |
|
55 | 60 | @user = User.find(session[:user_id]) |
|
56 | 61 | end |
|
57 | 62 | |
|
58 | 63 | def submit |
|
59 | 64 | user = User.find(session[:user_id]) |
|
60 | 65 | |
|
61 | 66 | @submission = Submission.new |
|
62 |
- @ |
|
|
67 | + @current_problem = Problem.find(params[:submission][:problem_id]) | |
|
68 | + | |
|
69 | + if !@current_problem | |
|
70 | + flash[:notice] = 'Error: คุณยังไม่ได้ระบุข้อที่ต้องการส่ง' | |
|
71 | + redirect_to :action => 'list' | |
|
72 | + end | |
|
73 | + | |
|
74 | + assignment = user.get_test_pair_assignment_for(@current_problem) | |
|
75 | + if !assignment | |
|
76 | + flash[:notice] = 'Error: คุณยังไม่ได้ดาวน์โหลดข้อมูลทดสอบ' | |
|
77 | + prepare_list_information | |
|
78 | + render :action => 'list' and return | |
|
79 | + end | |
|
80 | + if assignment.expired? | |
|
81 | + flash[:notice] = 'Error: หมดเวลาส่งสำหรับข้อนี้' | |
|
82 | + prepare_list_information | |
|
83 | + render :action => 'list' and return | |
|
84 | + end | |
|
85 | + | |
|
86 | + @submission.problem = @current_problem | |
|
63 | 87 | @submission.user = user |
|
64 | 88 | @submission.language_id = 0 |
|
65 | 89 | if (params['file']) and (params['file']!='') |
|
66 | 90 | @submission.source = params['file'].read |
|
67 | 91 | @submission.source_filename = params['file'].original_filename |
|
68 | 92 | end |
|
93 | + if (params['output_file']) and (params['output_file']!='') | |
|
94 | + @submission.output = params['output_file'].read | |
|
95 | + end | |
|
69 | 96 | @submission.submitted_at = Time.new.gmtime |
|
70 | 97 | |
|
71 | 98 | if GraderConfiguration.time_limit_mode? and user.contest_finished? |
|
72 | 99 | @submission.errors.add(:base,"The contest is over.") |
|
73 | 100 | prepare_list_information |
|
74 | 101 | render :action => 'list' and return |
|
75 | 102 | end |
|
76 | 103 | |
|
77 | 104 | if @submission.valid? |
|
78 | 105 | if @submission.save == false |
|
79 | 106 | flash[:notice] = 'Error saving your submission' |
|
80 | 107 | elsif Task.create(:submission_id => @submission.id, |
|
81 | 108 | :status => Task::STATUS_INQUEUE) == false |
|
82 | 109 | flash[:notice] = 'Error adding your submission to task queue' |
|
110 | + else | |
|
111 | + flash[:notice] = 'จัดเก็บคำตอบและโปรแกรมที่คุณส่งเรียบร้อย' | |
|
83 | 112 | end |
|
84 | 113 | else |
|
85 | 114 | prepare_list_information |
|
86 | 115 | render :action => 'list' and return |
|
87 | 116 | end |
|
117 | + | |
|
118 | + if @current_problem | |
|
119 | + session[:current_problem_id] = @current_problem.id | |
|
120 | + end | |
|
88 | 121 | redirect_to :action => 'list' |
|
89 | 122 | end |
|
90 | 123 | |
|
91 | 124 | def source |
|
92 | 125 | submission = Submission.find(params[:id]) |
|
93 | 126 | if ((submission.user_id == session[:user_id]) and |
|
94 | 127 | (submission.problem != nil) and |
|
95 | 128 | (submission.problem.available)) |
|
96 | 129 | send_data(submission.source, |
|
97 | 130 | {:filename => submission.download_filename, |
|
98 | 131 | :type => 'text/plain'}) |
|
99 | 132 | else |
|
100 | 133 | flash[:notice] = 'Error viewing source' |
|
101 | 134 | redirect_to :action => 'list' |
|
102 | 135 | end |
|
103 | 136 | end |
|
104 | 137 | |
|
105 | 138 | def compiler_msg |
|
106 | 139 | @submission = Submission.find(params[:id]) |
|
107 | 140 | if @submission.user_id == session[:user_id] |
|
108 | 141 | render :action => 'compiler_msg', :layout => 'empty' |
|
109 | 142 | else |
|
110 | 143 | flash[:notice] = 'Error viewing source' |
|
111 | 144 | redirect_to :action => 'list' |
|
112 | 145 | end |
|
113 | 146 | end |
|
114 | 147 | |
|
115 | 148 | def submission |
|
116 | 149 | @user = User.find(session[:user_id]) |
|
117 | 150 | @problems = @user.available_problems |
|
118 | 151 | if params[:id]==nil |
|
119 | 152 | @problem = nil |
|
120 | 153 | @submissions = nil |
|
121 | 154 | else |
|
122 | 155 | @problem = Problem.find_by_name(params[:id]) |
|
123 | 156 | if not @problem.available |
|
124 | 157 | redirect_to :action => 'list' |
|
125 | 158 | flash[:notice] = 'Error: submissions for that problem are not viewable.' |
|
126 | 159 | return |
|
127 | 160 | end |
|
128 | 161 | @submissions = Submission.find_all_by_user_problem(@user.id, @problem.id) |
|
129 | 162 | end |
|
130 | 163 | end |
|
131 | 164 | |
|
132 | 165 | def result |
|
133 | 166 | if !GraderConfiguration.show_grading_result |
|
134 | 167 | redirect_to :action => 'list' and return |
|
135 | 168 | end |
|
136 | 169 | @user = User.find(session[:user_id]) |
|
137 | 170 | @submission = Submission.find(params[:id]) |
|
138 | 171 | if @submission.user!=@user |
|
139 | 172 | flash[:notice] = 'You are not allowed to view result of other users.' |
|
140 | 173 | redirect_to :action => 'list' and return |
|
141 | 174 | end |
|
142 | 175 | prepare_grading_result(@submission) |
|
143 | 176 | end |
|
144 | 177 | |
|
145 | 178 | def load_output |
|
146 | 179 | if !GraderConfiguration.show_grading_result or params[:num]==nil |
|
147 | 180 | redirect_to :action => 'list' and return |
|
148 | 181 | end |
|
149 | 182 | @user = User.find(session[:user_id]) |
|
150 | 183 | @submission = Submission.find(params[:id]) |
|
151 | 184 | if @submission.user!=@user |
|
152 | 185 | flash[:notice] = 'You are not allowed to view result of other users.' |
|
153 | 186 | redirect_to :action => 'list' and return |
|
154 | 187 | end |
|
155 | 188 | case_num = params[:num].to_i |
|
156 | 189 | out_filename = output_filename(@user.login, |
|
157 | 190 | @submission.problem.name, |
|
158 | 191 | @submission.id, |
|
159 | 192 | case_num) |
|
160 | 193 | if !FileTest.exists?(out_filename) |
|
161 | 194 | flash[:notice] = 'Output not found.' |
|
162 | 195 | redirect_to :action => 'list' and return |
|
163 | 196 | end |
|
164 | 197 | |
|
165 | 198 | if defined?(USE_APACHE_XSENDFILE) and USE_APACHE_XSENDFILE |
|
166 | 199 | response.headers['Content-Type'] = "application/force-download" |
|
167 | 200 | response.headers['Content-Disposition'] = "attachment; filename=\"output-#{case_num}.txt\"" |
|
168 | 201 | response.headers["X-Sendfile"] = out_filename |
|
169 | 202 | response.headers['Content-length'] = File.size(out_filename) |
|
170 | 203 | render :nothing => true |
|
171 | 204 | else |
|
172 | 205 | send_file out_filename, :stream => false, :filename => "output-#{case_num}.txt", :type => "text/plain" |
|
173 | 206 | end |
|
174 | 207 | end |
|
175 | 208 | |
|
176 | 209 | def error |
|
177 | 210 | @user = User.find(session[:user_id]) |
|
178 | 211 | end |
|
179 | 212 | |
|
180 | 213 | # announcement refreshing and hiding methods |
|
181 | 214 | |
|
182 | 215 | def announcements |
|
183 | 216 | if params.has_key? 'recent' |
|
184 | 217 | prepare_announcements(params[:recent]) |
|
185 | 218 | else |
|
186 | 219 | prepare_announcements |
|
187 | 220 | end |
|
188 | 221 | render(:partial => 'announcement', |
|
189 | 222 | :collection => @announcements, |
|
190 | 223 | :locals => {:announcement_effect => true}) |
|
191 | 224 | end |
|
192 | 225 | |
|
193 | 226 | def confirm_contest_start |
|
194 | 227 | user = User.find(session[:user_id]) |
|
195 | 228 | if request.method == 'POST' |
|
196 | 229 | user.update_start_time |
|
197 | 230 | redirect_to :action => 'list' |
|
198 | 231 | else |
|
199 | 232 | @contests = user.contests |
|
200 | 233 | @user = user |
|
201 | 234 | end |
|
202 | 235 | end |
|
203 | 236 | |
|
204 | 237 | # thailandoi contests |
|
205 | 238 | |
|
206 | 239 | def verifying_testcase |
|
207 | 240 | problem = Problem.find(params[:id]) |
|
208 | 241 | if !problem.available |
|
209 | 242 | flash[:notice] = 'Error: problem is not available' |
|
210 | 243 | redirect_to :action => 'list' |
|
211 | 244 | else |
|
212 | 245 | test_pair = TestPair.get_for(problem, false) |
|
213 | 246 | send_data(test_pair.input, |
|
214 | 247 | {:filename => problem.name + '-verifying-input.txt', |
|
215 | 248 | :type => 'text/plain'}) |
|
216 | 249 | end |
|
217 | 250 | end |
|
218 | 251 | |
|
219 | 252 | def testcase |
|
220 | 253 | problem = Problem.find(params[:id]) |
|
221 | 254 | if !problem.available |
|
222 | 255 | flash[:notice] = 'Error: problem is not available' |
|
223 | 256 | redirect_to :action => 'list' |
|
224 | 257 | else |
|
225 | 258 | test_pair = TestPair.get_for(problem, true) |
|
226 | 259 | |
|
227 | 260 | user = User.find(session[:user_id]) |
|
228 | - assignent = user.get_test_pair_assignment_for(problem) | |
|
261 | + assignment = user.get_test_pair_assignment_for(problem) | |
|
229 | 262 | |
|
230 | - if !assignent | |
|
231 |
- assignent = TestPairAssignment. |
|
|
232 |
- assignent. |
|
|
233 | - assignent.problem = problem | |
|
234 | - assignent.test_pair = test_pair | |
|
235 | - assignent.submitted = false | |
|
236 | - assignent.save | |
|
263 | + if !assignment | |
|
264 | + assignment = TestPairAssignment.create_for(user, problem, test_pair) | |
|
265 | + assignment.save | |
|
237 | 266 | end |
|
238 | 267 | |
|
239 | 268 | send_data(test_pair.input, |
|
240 | 269 | {:filename => problem.name + '-input.txt', |
|
241 | 270 | :type => 'text/plain'}) |
|
242 | 271 | end |
|
243 | 272 | end |
|
244 | 273 | |
|
245 | 274 | def verifying_submit |
|
246 | 275 | user = User.find(session[:user_id]) |
|
247 | 276 | problem_id = params[:id] |
|
248 | 277 | problem = Problem.find(problem_id) |
|
249 | 278 | |
|
250 | 279 | if !problem or !problem.available |
|
251 | 280 | flash[:notice] = 'Error: problem is not available' |
|
252 | 281 | redirect_to :action => 'list' and return |
|
253 | 282 | end |
|
254 | 283 | |
|
284 | + @current_problem = problem | |
|
255 | 285 | test_pair = TestPair.get_for(problem, false) |
|
256 | 286 | if (params['output_file']) and (params['output_file']!='') |
|
257 | 287 | output = params['output_file'].read |
|
258 | 288 | |
|
259 | - @current_problem = problem | |
|
260 | 289 | @grading_result = grade(output, test_pair.solution) |
|
261 | 290 | prepare_list_information |
|
262 | 291 | render :action => 'list' and return |
|
263 | 292 | else |
|
264 | 293 | flash[:notice] = 'Error: output file errors' |
|
265 | - redirect_to :action => 'list' | |
|
294 | + prepare_list_information | |
|
295 | + render :action => 'list' and return | |
|
266 | 296 | end |
|
267 | 297 | end |
|
268 | 298 | |
|
269 | 299 | protected |
|
270 | 300 | |
|
271 | 301 | def grade(output, solution) |
|
272 | 302 | out_items = output.split |
|
273 | 303 | sol_items = solution.split |
|
274 | 304 | res = '' |
|
275 | 305 | f = 0 |
|
276 | 306 | s = 0 |
|
277 | 307 | sol_items.length.times do |i| |
|
278 | 308 | f += 1 |
|
279 | 309 | if out_items[i] == sol_items[i] |
|
280 | 310 | res = res + 'P' |
|
281 | 311 | s += 1 |
|
282 | 312 | else |
|
283 | 313 | res = res + '-' |
|
284 | 314 | end |
|
285 | 315 | end |
|
286 | 316 | return { :score => s, :full_score => f, :msg => res } |
|
287 | 317 | end |
|
288 | 318 | |
|
289 | 319 | def prepare_announcements(recent=nil) |
|
290 | 320 | if GraderConfiguration.show_tasks_to?(@user) |
|
291 | 321 | @announcements = Announcement.find_published(true) |
|
292 | 322 | else |
|
293 | 323 | @announcements = Announcement.find_published |
|
294 | 324 | end |
|
295 | 325 | if recent!=nil |
|
296 | 326 | recent_id = recent.to_i |
|
297 | 327 | @announcements = @announcements.find_all { |a| a.id > recent_id } |
|
298 | 328 | end |
|
299 | 329 | end |
|
300 | 330 | |
|
301 | 331 | def prepare_timeout_information(problems) |
|
302 | 332 | @submission_timeouts = {} |
|
303 | 333 | problems.each do |problem| |
|
304 | 334 | assignment = @user.get_test_pair_assignment_for(problem) |
|
305 | 335 | if assignment == nil |
|
306 | 336 | timeout = nil |
|
307 | 337 | else |
|
308 | 338 | if (assignment.expired?) or (assignment.submitted) |
|
309 | 339 | timeout = 0 |
|
310 | 340 | else |
|
311 | 341 | timeout = assignment.created_at + TEST_ASSIGNMENT_EXPIRATION_DURATION - Time.new.gmtime |
|
312 | 342 | end |
|
313 | 343 | end |
|
314 | 344 | @submission_timeouts[problem.id] = timeout |
|
315 | 345 | end |
|
316 | 346 | end |
|
317 | 347 | |
|
318 | 348 | def prepare_list_information |
|
319 | 349 | @user = User.find(session[:user_id]) |
|
320 | 350 | if not GraderConfiguration.multicontests? |
|
321 | 351 | @problems = @user.available_problems |
|
322 | 352 | else |
|
323 | 353 | @contest_problems = @user.available_problems_group_by_contests |
|
324 | 354 | @problems = @user.available_problems |
|
325 | 355 | end |
|
326 | 356 | @prob_submissions = {} |
|
327 | 357 | @problems.each do |p| |
|
328 | 358 | sub = Submission.find_last_by_user_and_problem(@user.id,p.id) |
|
329 | 359 | if sub!=nil |
|
330 | 360 | @prob_submissions[p.id] = { :count => sub.number, :submission => sub } |
|
331 | 361 | else |
|
332 | 362 | @prob_submissions[p.id] = { :count => 0, :submission => nil } |
|
333 | 363 | end |
|
334 | 364 | end |
|
335 | 365 | prepare_announcements |
|
336 | 366 | prepare_timeout_information(@problems) |
|
337 | 367 | end |
|
338 | 368 | |
|
339 | 369 | def check_viewability |
|
340 | 370 | @user = User.find(session[:user_id]) |
|
341 | 371 | if (!GraderConfiguration.show_tasks_to?(@user)) and |
|
342 | 372 | ((action_name=='submission') or (action_name=='submit')) |
|
343 | 373 | redirect_to :action => 'list' and return |
|
344 | 374 | end |
|
345 | 375 | end |
|
346 | 376 | |
|
347 | 377 | def prepare_grading_result(submission) |
|
348 | 378 | if GraderConfiguration.task_grading_info.has_key? submission.problem.name |
|
349 | 379 | grading_info = GraderConfiguration.task_grading_info[submission.problem.name] |
|
350 | 380 | else |
|
351 | 381 | # guess task info from problem.full_score |
|
352 | 382 | cases = submission.problem.full_score / 10 |
|
353 | 383 | grading_info = { |
|
354 | 384 | 'testruns' => cases, |
|
355 | 385 | 'testcases' => cases |
|
356 | 386 | } |
|
357 | 387 | end |
|
358 | 388 | @test_runs = [] |
|
359 | 389 | if grading_info['testruns'].is_a? Integer |
|
360 | 390 | trun_count = grading_info['testruns'] |
|
361 | 391 | trun_count.times do |i| |
|
362 | 392 | @test_runs << [ read_grading_result(@user.login, |
|
363 | 393 | submission.problem.name, |
|
364 | 394 | submission.id, |
|
365 | 395 | i+1) ] |
|
366 | 396 | end |
|
367 | 397 | else |
|
368 | 398 | grading_info['testruns'].keys.sort.each do |num| |
|
369 | 399 | run = [] |
|
370 | 400 | testrun = grading_info['testruns'][num] |
|
371 | 401 | testrun.each do |c| |
|
372 | 402 | run << read_grading_result(@user.login, |
|
373 | 403 | submission.problem.name, |
|
374 | 404 | submission.id, |
|
375 | 405 | c) |
|
376 | 406 | end |
|
377 | 407 | @test_runs << run |
|
378 | 408 | end |
|
379 | 409 | end |
|
380 | 410 | end |
|
381 | 411 | |
|
382 | 412 | def grading_result_dir(user_name, problem_name, submission_id, case_num) |
|
383 | 413 | return "#{GRADING_RESULT_DIR}/#{user_name}/#{problem_name}/#{submission_id}/test-result/#{case_num}" |
|
384 | 414 | end |
|
385 | 415 | |
|
386 | 416 | def output_filename(user_name, problem_name, submission_id, case_num) |
|
387 | 417 | dir = grading_result_dir(user_name,problem_name, submission_id, case_num) |
|
388 | 418 | return "#{dir}/output.txt" |
|
389 | 419 | end |
|
390 | 420 | |
|
391 | 421 | def read_grading_result(user_name, problem_name, submission_id, case_num) |
|
392 | 422 | dir = grading_result_dir(user_name,problem_name, submission_id, case_num) |
|
393 | 423 | result_file_name = "#{dir}/result" |
|
394 | 424 | if !FileTest.exists?(result_file_name) |
|
395 | 425 | return {:num => case_num, :msg => 'program did not run'} |
|
396 | 426 | else |
|
397 | 427 | results = File.open(result_file_name).readlines |
|
398 | 428 | run_stat = extract_running_stat(results) |
|
399 | 429 | output_filename = "#{dir}/output.txt" |
|
400 | 430 | if FileTest.exists?(output_filename) |
|
401 | 431 | output_file = true |
|
402 | 432 | output_size = File.size(output_filename) |
|
403 | 433 | else |
|
404 | 434 | output_file = false |
|
405 | 435 | output_size = 0 |
|
406 | 436 | end |
|
407 | 437 | |
|
408 | 438 | return { |
|
409 | 439 | :num => case_num, |
|
410 | 440 | :msg => results[0], |
|
411 | 441 | :run_stat => run_stat, |
|
412 | 442 | :output => output_file, |
|
413 | 443 | :output_size => output_size |
|
414 | 444 | } |
|
415 | 445 | end |
|
416 | 446 | end |
|
417 | 447 | |
|
418 | 448 | # copied from grader/script/lib/test_request_helper.rb |
|
419 | 449 | def extract_running_stat(results) |
|
420 | 450 | running_stat_line = results[-1] |
|
421 | 451 | |
|
422 | 452 | # extract exit status line |
|
423 | 453 | run_stat = "" |
|
424 | 454 | if !(/[Cc]orrect/.match(results[0])) |
|
425 | 455 | run_stat = results[0].chomp |
|
426 | 456 | else |
|
427 | 457 | run_stat = 'Program exited normally' |
|
428 | 458 | end |
|
429 | 459 | |
|
430 | 460 | logger.info "Stat line: #{running_stat_line}" |
|
431 | 461 | |
|
432 | 462 | # extract running time |
|
433 | 463 | if res = /r(.*)u(.*)s/.match(running_stat_line) |
|
434 | 464 | seconds = (res[1].to_f + res[2].to_f) |
|
435 | 465 | time_stat = "Time used: #{seconds} sec." |
|
436 | 466 | else |
|
437 | 467 | seconds = nil |
|
438 | 468 | time_stat = "Time used: n/a sec." |
|
439 | 469 | end |
|
440 | 470 | |
|
441 | 471 | # extract memory usage |
|
442 | 472 | if res = /s(.*)m/.match(running_stat_line) |
|
443 | 473 | memory_used = res[1].to_i |
|
444 | 474 | else |
|
445 | 475 | memory_used = -1 |
|
446 | 476 | end |
|
447 | 477 | |
|
448 | 478 | return { |
|
449 | 479 | :msg => "#{run_stat}\n#{time_stat}", |
|
450 | 480 | :running_time => seconds, |
|
451 | 481 | :exit_status => run_stat, |
|
452 | 482 | :memory_usage => memory_used |
|
453 | 483 | } |
|
454 | 484 | end |
|
455 | 485 | |
|
456 | 486 | def confirm_and_update_start_time |
|
457 | 487 | user = User.find(session[:user_id]) |
|
458 | 488 | if (GraderConfiguration.indv_contest_mode? and |
|
459 | 489 | GraderConfiguration['contest.confirm_indv_contest_start'] and |
|
460 | 490 | !user.contest_started?) |
|
461 | 491 | redirect_to :action => 'confirm_contest_start' and return |
|
462 | 492 | end |
|
463 | 493 | if not GraderConfiguration.analysis_mode? |
|
464 | 494 | user.update_start_time |
|
465 | 495 | end |
|
466 | 496 | end |
|
467 | 497 | |
|
468 | 498 | def reject_announcement_refresh_when_logged_out |
|
469 | 499 | if not session[:user_id] |
|
470 | 500 | render :text => 'Access forbidden', :status => 403 |
|
471 | 501 | end |
|
472 | 502 | |
|
473 | 503 | if GraderConfiguration.multicontests? |
|
474 | 504 | user = User.find(session[:user_id]) |
|
475 | 505 | if user.contest_stat.forced_logout |
|
476 | 506 | render :text => 'Access forbidden', :status => 403 |
|
477 | 507 | end |
|
478 | 508 | end |
|
479 | 509 | end |
|
480 | 510 | |
|
481 | 511 | end |
|
482 | 512 |
@@ -1,173 +1,178 | |||
|
1 | 1 | class Submission < ActiveRecord::Base |
|
2 | 2 | |
|
3 | 3 | belongs_to :language |
|
4 | 4 | belongs_to :problem |
|
5 | 5 | belongs_to :user |
|
6 | 6 | |
|
7 | 7 | before_validation :assign_problem |
|
8 | 8 | before_validation :assign_language |
|
9 | 9 | |
|
10 | 10 | validates_presence_of :source |
|
11 | 11 | validates_length_of :source, :maximum => 100_000, :allow_blank => true, :message => 'too long' |
|
12 | 12 | validates_length_of :source, :minimum => 1, :allow_blank => true, :message => 'too short' |
|
13 | + | |
|
14 | + validates_presence_of :output | |
|
15 | + validates_length_of :output, :maximum => 100_000, :allow_blank => true, :message => 'too long' | |
|
16 | + validates_length_of :output, :minimum => 1, :allow_blank => true, :message => 'too short' | |
|
17 | + | |
|
13 | 18 | validate :must_have_valid_problem |
|
14 | 19 | validate :must_specify_language |
|
15 | 20 | |
|
16 | 21 | before_save :assign_latest_number_if_new_recond |
|
17 | 22 | |
|
18 | 23 | def self.find_last_by_user_and_problem(user_id, problem_id) |
|
19 | 24 | last_sub = find(:first, |
|
20 | 25 | :conditions => {:user_id => user_id, |
|
21 | 26 | :problem_id => problem_id}, |
|
22 | 27 | :order => 'number DESC') |
|
23 | 28 | return last_sub |
|
24 | 29 | end |
|
25 | 30 | |
|
26 | 31 | def self.find_all_last_by_problem(problem_id) |
|
27 | 32 | # need to put in SQL command, maybe there's a better way |
|
28 | 33 | Submission.find_by_sql("SELECT * FROM submissions " + |
|
29 | 34 | "WHERE id = " + |
|
30 | 35 | "(SELECT MAX(id) FROM submissions AS subs " + |
|
31 | 36 | "WHERE subs.user_id = submissions.user_id AND " + |
|
32 | 37 | "problem_id = " + problem_id.to_s + " " + |
|
33 | 38 | "GROUP BY user_id) " + |
|
34 | 39 | "ORDER BY user_id") |
|
35 | 40 | end |
|
36 | 41 | |
|
37 | 42 | def self.find_in_range_by_user_and_problem(user_id, problem_id,since_id,until_id) |
|
38 | 43 | records = Submission.where(problem_id: problem_id,user_id: user_id) |
|
39 | 44 | records = records.where('id >= ?',since_id) if since_id > 0 |
|
40 | 45 | records = records.where('id <= ?',until_id) if until_id > 0 |
|
41 | 46 | records.all |
|
42 | 47 | end |
|
43 | 48 | |
|
44 | 49 | def self.find_last_for_all_available_problems(user_id) |
|
45 | 50 | submissions = Array.new |
|
46 | 51 | problems = Problem.find_available_problems |
|
47 | 52 | problems.each do |problem| |
|
48 | 53 | sub = Submission.find_last_by_user_and_problem(user_id, problem.id) |
|
49 | 54 | submissions << sub if sub!=nil |
|
50 | 55 | end |
|
51 | 56 | submissions |
|
52 | 57 | end |
|
53 | 58 | |
|
54 | 59 | def self.find_by_user_problem_number(user_id, problem_id, number) |
|
55 | 60 | Submission.find(:first, |
|
56 | 61 | :conditions => { |
|
57 | 62 | :user_id => user_id, |
|
58 | 63 | :problem_id => problem_id, |
|
59 | 64 | :number => number |
|
60 | 65 | }) |
|
61 | 66 | end |
|
62 | 67 | |
|
63 | 68 | def self.find_all_by_user_problem(user_id, problem_id) |
|
64 | 69 | Submission.find(:all, |
|
65 | 70 | :conditions => { |
|
66 | 71 | :user_id => user_id, |
|
67 | 72 | :problem_id => problem_id, |
|
68 | 73 | }) |
|
69 | 74 | end |
|
70 | 75 | |
|
71 | 76 | def download_filename |
|
72 | 77 | if self.problem.output_only |
|
73 | 78 | return self.source_filename |
|
74 | 79 | else |
|
75 | 80 | timestamp = self.submitted_at.localtime.strftime("%H%M%S") |
|
76 | 81 | return "#{self.problem.name}-#{timestamp}.#{self.language.ext}" |
|
77 | 82 | end |
|
78 | 83 | end |
|
79 | 84 | |
|
80 | 85 | protected |
|
81 | 86 | |
|
82 | 87 | def self.find_option_in_source(option, source) |
|
83 | 88 | if source==nil |
|
84 | 89 | return nil |
|
85 | 90 | end |
|
86 | 91 | i = 0 |
|
87 | 92 | source.each_line do |s| |
|
88 | 93 | if s =~ option |
|
89 | 94 | words = s.split |
|
90 | 95 | return words[1] |
|
91 | 96 | end |
|
92 | 97 | i = i + 1 |
|
93 | 98 | if i==10 |
|
94 | 99 | return nil |
|
95 | 100 | end |
|
96 | 101 | end |
|
97 | 102 | return nil |
|
98 | 103 | end |
|
99 | 104 | |
|
100 | 105 | def self.find_language_in_source(source, source_filename="") |
|
101 | 106 | langopt = find_option_in_source(/^LANG:/,source) |
|
102 | 107 | if langopt |
|
103 | 108 | return (Language.find_by_name(langopt) || |
|
104 | 109 | Language.find_by_pretty_name(langopt)) |
|
105 | 110 | else |
|
106 | 111 | if source_filename |
|
107 | 112 | return Language.find_by_extension(source_filename.split('.').last) |
|
108 | 113 | else |
|
109 | 114 | return nil |
|
110 | 115 | end |
|
111 | 116 | end |
|
112 | 117 | end |
|
113 | 118 | |
|
114 | 119 | def self.find_problem_in_source(source, source_filename="") |
|
115 | 120 | prob_opt = find_option_in_source(/^TASK:/,source) |
|
116 | 121 | if problem = Problem.find_by_name(prob_opt) |
|
117 | 122 | return problem |
|
118 | 123 | else |
|
119 | 124 | if source_filename |
|
120 | 125 | return Problem.find_by_name(source_filename.split('.').first) |
|
121 | 126 | else |
|
122 | 127 | return nil |
|
123 | 128 | end |
|
124 | 129 | end |
|
125 | 130 | end |
|
126 | 131 | |
|
127 | 132 | def assign_problem |
|
128 | 133 | if self.problem_id!=-1 |
|
129 | 134 | begin |
|
130 | 135 | self.problem = Problem.find(self.problem_id) |
|
131 | 136 | rescue ActiveRecord::RecordNotFound |
|
132 | 137 | self.problem = nil |
|
133 | 138 | end |
|
134 | 139 | else |
|
135 | 140 | self.problem = Submission.find_problem_in_source(self.source, |
|
136 | 141 | self.source_filename) |
|
137 | 142 | end |
|
138 | 143 | end |
|
139 | 144 | |
|
140 | 145 | def assign_language |
|
141 | 146 | self.language = Submission.find_language_in_source(self.source, |
|
142 | 147 | self.source_filename) |
|
143 | 148 | end |
|
144 | 149 | |
|
145 | 150 | # validation codes |
|
146 | 151 | def must_specify_language |
|
147 | 152 | return if self.source==nil |
|
148 | 153 | |
|
149 | 154 | # for output_only tasks |
|
150 | 155 | return if self.problem!=nil and self.problem.output_only |
|
151 | 156 | |
|
152 | 157 | if self.language==nil |
|
153 | 158 | errors.add('source',"must specify programming language") unless self.language!=nil |
|
154 | 159 | end |
|
155 | 160 | end |
|
156 | 161 | |
|
157 | 162 | def must_have_valid_problem |
|
158 | 163 | return if self.source==nil |
|
159 | 164 | if self.problem==nil |
|
160 | 165 | errors.add('problem',"must be specified.") |
|
161 | 166 | elsif (!self.problem.available) and (self.new_record?) |
|
162 | 167 | errors.add('problem',"must be valid.") |
|
163 | 168 | end |
|
164 | 169 | end |
|
165 | 170 | |
|
166 | 171 | # callbacks |
|
167 | 172 | def assign_latest_number_if_new_recond |
|
168 | 173 | return if !self.new_record? |
|
169 | 174 | latest = Submission.find_last_by_user_and_problem(self.user_id, self.problem_id) |
|
170 | 175 | self.number = (latest==nil) ? 1 : latest.number + 1; |
|
171 | 176 | end |
|
172 | 177 | |
|
173 | 178 | end |
@@ -1,9 +1,19 | |||
|
1 | 1 | class TestPairAssignment < ActiveRecord::Base |
|
2 | 2 | belongs_to :problem |
|
3 | 3 | belongs_to :test_pair |
|
4 | 4 | belongs_to :user |
|
5 | 5 | |
|
6 | 6 | def expired? |
|
7 | 7 | return created_at + TEST_ASSIGNMENT_EXPIRATION_DURATION < Time.new.gmtime |
|
8 | 8 | end |
|
9 | + | |
|
10 | + def self.create_for(user, problem, test_pair) | |
|
11 | + assignment = TestPairAssignment.new | |
|
12 | + assignment.user = user | |
|
13 | + assignment.problem = problem | |
|
14 | + assignment.test_pair = test_pair | |
|
15 | + assignment.submitted = false | |
|
16 | + assignment.save | |
|
17 | + return assignment | |
|
9 | 18 | end |
|
19 | + end |
@@ -1,36 +1,38 | |||
|
1 | + <% selected_problem_id = @current_problem ? @current_problem.id : -1 %> | |
|
1 | 2 | <div class="submitbox"> |
|
2 | 3 | <b>Problem:</b> <%= select 'submission', 'problem_id', |
|
3 | 4 | [['กรุณาเลือกข้อที่ต้องการส่งหรือทดสอบ','-1']] + |
|
4 | 5 | @problems.collect {|p| [p.full_name, p.id]}, |
|
5 |
- { :selected => |
|
|
6 | + { :selected => selected_problem_id }, | |
|
6 | 7 | { :onchange => 'TOIContest.problemSelectClick()' } %> |
|
7 | 8 | </div> |
|
8 | 9 | |
|
9 | 10 | <% @problems.each do |problem| %> |
|
10 |
- <div class="submission-submit-divs" id="submission_submit_div_<%= problem.id %>_id" style="displa |
|
|
11 | + <div class="submission-submit-divs" id="submission_submit_div_<%= problem.id %>_id" style="display: none;"> | |
|
11 | 12 | <div style="border: 1px solid #c0c0c0; padding: 5px; margin: 5px 0 5px 0;"> |
|
12 | 13 | <b><%= problem.full_name %>: ข้อมูลสำหรับตรวจสอบ</b> (สามารถดาวน์โหลดและส่งกี่ครั้งก็ได้,ไม่มีคะแนน): |
|
13 | 14 | <%= link_to 'ดาวน์โหลด input', :action => 'verifying_testcase', :id => problem.id %> |
|
14 | 15 | <% if @current_problem and @current_problem.id == problem.id %> |
|
15 | 16 | <% if @grading_result %> |
|
16 | 17 | | <b>ผลการตรวจ:</b> <%= "#{@grading_result[:score]}/#{@grading_result[:full_score]} [#{@grading_result[:msg]}]" %> |
|
17 | 18 | <% end %> |
|
18 | 19 | <% end %> |
|
19 | 20 | <%= form_tag({:controller => 'main', :action => 'verifying_submit', :id => problem.id}, {:method => 'post', :multipart => true }) do %> |
|
20 | 21 | ส่งคำตอบของข้อมูลสำหรับตรวจสอบ: |
|
21 | 22 | <%= file_field_tag 'output_file' %> |
|
22 | 23 | <%= submit_tag 'Submit' %> |
|
23 | 24 | <% end %> |
|
24 | 25 | </div> |
|
25 | 26 | <div style="border: 1px solid #c0c0c0; padding: 5px; margin: 5px 0 5px 0;"> |
|
26 | 27 | <b><%= problem.full_name %>: ข้อมูลทดสอบจริง</b> (ส่งกี่ครั้งก็ได้ภายในเวลา 5 นาทีหลังดาวน์โหลด): |
|
27 |
- <%= link_to 'ดาวน์โหลด input และเริ่มจับเวลา', { :action => 'testcase', :id => problem.id}, { :onclick => |
|
|
28 | + <%= link_to 'ดาวน์โหลด input และเริ่มจับเวลา', { :action => 'testcase', :id => problem.id}, { :onclick => "return TOIContest.confirmDownload(#{problem.id})" } %> | |
|
28 | 29 | <span id="submission_time_left_<%= problem.id %>_id"></span> |
|
29 |
- <%= form_tag({:controller => 'main', :action => 'submit' |
|
|
30 | + <%= form_tag({:controller => 'main', :action => 'submit'}, {:method => 'post', :multipart => true, :id => "submission_form_#{problem.id}_id" }) do %> | |
|
31 | + <%= hidden_field_tag 'submission[problem_id]', problem.id %> | |
|
30 | 32 | ข้อมูลส่งออก: <%= file_field_tag 'output_file' %> |
|
31 |
- โปรแกรมคำตอบ: <%= file_field_tag ' |
|
|
33 | + โปรแกรมคำตอบ: <%= file_field_tag 'file' %> | |
|
32 | 34 | <%= submit_tag 'Submit' %> |
|
33 | 35 | <% end %> |
|
34 | 36 | </div> |
|
35 | 37 | </div> |
|
36 | 38 | <% end %> |
@@ -1,59 +1,62 | |||
|
1 | 1 | - content_for :head do |
|
2 | 2 | = javascript_include_tag "announcement_refresh" |
|
3 | 3 | = javascript_include_tag "toicontest" |
|
4 | 4 | |
|
5 | 5 | = user_title_bar(@user) |
|
6 | 6 | |
|
7 | 7 | .announcementbox{:style => (@announcements.length==0 ? "display:none" : "")} |
|
8 | 8 | %span{:class => 'title'} |
|
9 | 9 | Announcements |
|
10 | 10 | #announcementbox-body |
|
11 | 11 | = render :partial => 'announcement', :collection => @announcements |
|
12 | 12 | |
|
13 | 13 | - if GraderConfiguration.show_submitbox_to?(@user) |
|
14 | 14 | = error_messages_for 'submission' |
|
15 | 15 | = render :partial => 'submission_box' |
|
16 | 16 | |
|
17 | 17 | |
|
18 | 18 | %hr/ |
|
19 | 19 | |
|
20 | 20 | - if (GraderConfiguration.contest_mode?) and (@user.site!=nil) and (@user.site.started!=true) |
|
21 | 21 | %p=t 'main.start_soon' |
|
22 | 22 | |
|
23 | 23 | - if GraderConfiguration.show_tasks_to?(@user) |
|
24 | 24 | - if not GraderConfiguration.multicontests? |
|
25 | 25 | %table.info |
|
26 | 26 | %tr.info-head |
|
27 | 27 | %th |
|
28 | 28 | %th Tasks |
|
29 | 29 | %th # of sub(s) |
|
30 | 30 | %th Results |
|
31 | 31 | = render :partial => 'problem', :collection => @problems |
|
32 | 32 | - else |
|
33 | 33 | - @contest_problems.each do |cp| |
|
34 | 34 | - if cp[:problems].length > 0 |
|
35 | 35 | %h2{:class =>'contest-title'} |
|
36 | 36 | = "#{cp[:contest] ? cp[:contest].title : 'Public problems'}" |
|
37 | 37 | %table.info |
|
38 | 38 | %tr.info-head |
|
39 | 39 | %th |
|
40 | 40 | %th Tasks |
|
41 | 41 | %th # of sub(s) |
|
42 | 42 | %th Results |
|
43 | 43 | = render :partial => 'problem', :collection => cp[:problems] |
|
44 | 44 | |
|
45 | 45 | |
|
46 | 46 | %hr/ |
|
47 | 47 | |
|
48 | 48 | %script{:type => 'text/javascript'} |
|
49 | 49 | = "Announcement.refreshUrl = '#{url_for :controller => 'main', :action => 'announcements'}';" |
|
50 | 50 | Announcement.registerRefreshEventTimer(); |
|
51 | 51 | |
|
52 | + TOIContest.problemSelectClick() | |
|
53 | + | |
|
52 | 54 | TOIContest.timeOuts = {}; |
|
53 | 55 | - @problems.each do |p| |
|
54 | 56 | - if (@submission_timeouts.has_key? p.id) and (@submission_timeouts[p.id] != nil) |
|
55 | 57 | = "TOIContest.timeOuts[#{p.id}] = #{@submission_timeouts[p.id]};" |
|
56 | 58 | - else |
|
57 | 59 | = "TOIContest.timeOuts[#{p.id}] = TOIContest.NO_TIMEOUT;" |
|
58 | 60 | |
|
59 | 61 | TOIContest.refreshTimeOutMessages(); |
|
62 | + TOIContest.registerRefreshEvent(); |
@@ -1,246 +1,247 | |||
|
1 | 1 | # encoding: UTF-8 |
|
2 | 2 | # This file is auto-generated from the current state of the database. Instead |
|
3 | 3 | # of editing this file, please use the migrations feature of Active Record to |
|
4 | 4 | # incrementally modify your database, and then regenerate this schema definition. |
|
5 | 5 | # |
|
6 | 6 | # Note that this schema.rb definition is the authoritative source for your |
|
7 | 7 | # database schema. If you need to create the application database on another |
|
8 | 8 | # system, you should be using db:schema:load, not running all the migrations |
|
9 | 9 | # from scratch. The latter is a flawed and unsustainable approach (the more migrations |
|
10 | 10 | # you'll amass, the slower it'll run and the greater likelihood for issues). |
|
11 | 11 | # |
|
12 | 12 | # It's strongly recommended to check this file into your version control system. |
|
13 | 13 | |
|
14 |
- ActiveRecord::Schema.define(:version => 2015012 |
|
|
14 | + ActiveRecord::Schema.define(:version => 20150129021221) do | |
|
15 | 15 | |
|
16 | 16 | create_table "announcements", :force => true do |t| |
|
17 | 17 | t.string "author" |
|
18 | 18 | t.text "body" |
|
19 | 19 | t.boolean "published" |
|
20 | 20 | t.datetime "created_at", :null => false |
|
21 | 21 | t.datetime "updated_at", :null => false |
|
22 | 22 | t.boolean "frontpage", :default => false |
|
23 | 23 | t.boolean "contest_only", :default => false |
|
24 | 24 | t.string "title" |
|
25 | 25 | t.string "notes" |
|
26 | 26 | end |
|
27 | 27 | |
|
28 | 28 | create_table "contests", :force => true do |t| |
|
29 | 29 | t.string "title" |
|
30 | 30 | t.boolean "enabled" |
|
31 | 31 | t.datetime "created_at", :null => false |
|
32 | 32 | t.datetime "updated_at", :null => false |
|
33 | 33 | t.string "name" |
|
34 | 34 | end |
|
35 | 35 | |
|
36 | 36 | create_table "contests_problems", :id => false, :force => true do |t| |
|
37 | 37 | t.integer "contest_id" |
|
38 | 38 | t.integer "problem_id" |
|
39 | 39 | end |
|
40 | 40 | |
|
41 | 41 | create_table "contests_users", :id => false, :force => true do |t| |
|
42 | 42 | t.integer "contest_id" |
|
43 | 43 | t.integer "user_id" |
|
44 | 44 | end |
|
45 | 45 | |
|
46 | 46 | create_table "countries", :force => true do |t| |
|
47 | 47 | t.string "name" |
|
48 | 48 | t.datetime "created_at", :null => false |
|
49 | 49 | t.datetime "updated_at", :null => false |
|
50 | 50 | end |
|
51 | 51 | |
|
52 | 52 | create_table "descriptions", :force => true do |t| |
|
53 | 53 | t.text "body" |
|
54 | 54 | t.boolean "markdowned" |
|
55 | 55 | t.datetime "created_at", :null => false |
|
56 | 56 | t.datetime "updated_at", :null => false |
|
57 | 57 | end |
|
58 | 58 | |
|
59 | 59 | create_table "grader_configurations", :force => true do |t| |
|
60 | 60 | t.string "key" |
|
61 | 61 | t.string "value_type" |
|
62 | 62 | t.string "value" |
|
63 | 63 | t.datetime "created_at", :null => false |
|
64 | 64 | t.datetime "updated_at", :null => false |
|
65 | 65 | t.text "description" |
|
66 | 66 | end |
|
67 | 67 | |
|
68 | 68 | create_table "grader_processes", :force => true do |t| |
|
69 | 69 | t.string "host", :limit => 20 |
|
70 | 70 | t.integer "pid" |
|
71 | 71 | t.string "mode" |
|
72 | 72 | t.boolean "active" |
|
73 | 73 | t.datetime "created_at", :null => false |
|
74 | 74 | t.datetime "updated_at", :null => false |
|
75 | 75 | t.integer "task_id" |
|
76 | 76 | t.string "task_type" |
|
77 | 77 | t.boolean "terminated" |
|
78 | 78 | end |
|
79 | 79 | |
|
80 | 80 | add_index "grader_processes", ["host", "pid"], :name => "index_grader_processes_on_ip_and_pid" |
|
81 | 81 | |
|
82 | 82 | create_table "languages", :force => true do |t| |
|
83 | 83 | t.string "name", :limit => 10 |
|
84 | 84 | t.string "pretty_name" |
|
85 | 85 | t.string "ext", :limit => 10 |
|
86 | 86 | t.string "common_ext" |
|
87 | 87 | end |
|
88 | 88 | |
|
89 | 89 | create_table "messages", :force => true do |t| |
|
90 | 90 | t.integer "sender_id" |
|
91 | 91 | t.integer "receiver_id" |
|
92 | 92 | t.integer "replying_message_id" |
|
93 | 93 | t.text "body" |
|
94 | 94 | t.boolean "replied" |
|
95 | 95 | t.datetime "created_at", :null => false |
|
96 | 96 | t.datetime "updated_at", :null => false |
|
97 | 97 | end |
|
98 | 98 | |
|
99 | 99 | create_table "problems", :force => true do |t| |
|
100 | 100 | t.string "name", :limit => 30 |
|
101 | 101 | t.string "full_name" |
|
102 | 102 | t.integer "full_score" |
|
103 | 103 | t.date "date_added" |
|
104 | 104 | t.boolean "available" |
|
105 | 105 | t.string "url" |
|
106 | 106 | t.integer "description_id" |
|
107 | 107 | t.boolean "test_allowed" |
|
108 | 108 | t.boolean "output_only" |
|
109 | 109 | t.string "description_filename" |
|
110 | 110 | end |
|
111 | 111 | |
|
112 | 112 | create_table "rights", :force => true do |t| |
|
113 | 113 | t.string "name" |
|
114 | 114 | t.string "controller" |
|
115 | 115 | t.string "action" |
|
116 | 116 | end |
|
117 | 117 | |
|
118 | 118 | create_table "rights_roles", :id => false, :force => true do |t| |
|
119 | 119 | t.integer "right_id" |
|
120 | 120 | t.integer "role_id" |
|
121 | 121 | end |
|
122 | 122 | |
|
123 | 123 | add_index "rights_roles", ["role_id"], :name => "index_rights_roles_on_role_id" |
|
124 | 124 | |
|
125 | 125 | create_table "roles", :force => true do |t| |
|
126 | 126 | t.string "name" |
|
127 | 127 | end |
|
128 | 128 | |
|
129 | 129 | create_table "roles_users", :id => false, :force => true do |t| |
|
130 | 130 | t.integer "role_id" |
|
131 | 131 | t.integer "user_id" |
|
132 | 132 | end |
|
133 | 133 | |
|
134 | 134 | add_index "roles_users", ["user_id"], :name => "index_roles_users_on_user_id" |
|
135 | 135 | |
|
136 | 136 | create_table "sessions", :force => true do |t| |
|
137 | 137 | t.string "session_id" |
|
138 | 138 | t.text "data" |
|
139 | 139 | t.datetime "updated_at" |
|
140 | 140 | end |
|
141 | 141 | |
|
142 | 142 | add_index "sessions", ["session_id"], :name => "index_sessions_on_session_id" |
|
143 | 143 | add_index "sessions", ["updated_at"], :name => "index_sessions_on_updated_at" |
|
144 | 144 | |
|
145 | 145 | create_table "sites", :force => true do |t| |
|
146 | 146 | t.string "name" |
|
147 | 147 | t.boolean "started" |
|
148 | 148 | t.datetime "start_time" |
|
149 | 149 | t.datetime "created_at", :null => false |
|
150 | 150 | t.datetime "updated_at", :null => false |
|
151 | 151 | t.integer "country_id" |
|
152 | 152 | t.string "password" |
|
153 | 153 | end |
|
154 | 154 | |
|
155 | 155 | create_table "submissions", :force => true do |t| |
|
156 | 156 | t.integer "user_id" |
|
157 | 157 | t.integer "problem_id" |
|
158 | 158 | t.integer "language_id" |
|
159 | 159 | t.text "source" |
|
160 | 160 | t.binary "binary" |
|
161 | 161 | t.datetime "submitted_at" |
|
162 | 162 | t.datetime "compiled_at" |
|
163 | 163 | t.text "compiler_message" |
|
164 | 164 | t.datetime "graded_at" |
|
165 | 165 | t.integer "points" |
|
166 | 166 | t.text "grader_comment" |
|
167 | 167 | t.integer "number" |
|
168 | 168 | t.string "source_filename" |
|
169 | + t.text "output" | |
|
169 | 170 | end |
|
170 | 171 | |
|
171 | 172 | add_index "submissions", ["user_id", "problem_id", "number"], :name => "index_submissions_on_user_id_and_problem_id_and_number", :unique => true |
|
172 | 173 | add_index "submissions", ["user_id", "problem_id"], :name => "index_submissions_on_user_id_and_problem_id" |
|
173 | 174 | |
|
174 | 175 | create_table "tasks", :force => true do |t| |
|
175 | 176 | t.integer "submission_id" |
|
176 | 177 | t.datetime "created_at" |
|
177 | 178 | t.integer "status" |
|
178 | 179 | t.datetime "updated_at" |
|
179 | 180 | end |
|
180 | 181 | |
|
181 | 182 | create_table "test_pair_assignments", :force => true do |t| |
|
182 | 183 | t.integer "user_id" |
|
183 | 184 | t.integer "problem_id" |
|
184 | 185 | t.integer "test_pair_id" |
|
185 | 186 | t.integer "request_number" |
|
186 | 187 | t.boolean "submitted" |
|
187 | 188 | t.datetime "created_at", :null => false |
|
188 | 189 | t.datetime "updated_at", :null => false |
|
189 | 190 | end |
|
190 | 191 | |
|
191 | 192 | create_table "test_pairs", :force => true do |t| |
|
192 | 193 | t.integer "problem_id" |
|
193 | 194 | t.text "input", :limit => 16777215 |
|
194 | 195 | t.text "solution", :limit => 16777215 |
|
195 | 196 | t.datetime "created_at", :null => false |
|
196 | 197 | t.datetime "updated_at", :null => false |
|
197 | 198 | t.boolean "is_private" |
|
198 | 199 | end |
|
199 | 200 | |
|
200 | 201 | create_table "test_requests", :force => true do |t| |
|
201 | 202 | t.integer "user_id" |
|
202 | 203 | t.integer "problem_id" |
|
203 | 204 | t.integer "submission_id" |
|
204 | 205 | t.string "input_file_name" |
|
205 | 206 | t.string "output_file_name" |
|
206 | 207 | t.string "running_stat" |
|
207 | 208 | t.integer "status" |
|
208 | 209 | t.datetime "updated_at", :null => false |
|
209 | 210 | t.datetime "submitted_at" |
|
210 | 211 | t.datetime "compiled_at" |
|
211 | 212 | t.text "compiler_message" |
|
212 | 213 | t.datetime "graded_at" |
|
213 | 214 | t.string "grader_comment" |
|
214 | 215 | t.datetime "created_at", :null => false |
|
215 | 216 | t.float "running_time" |
|
216 | 217 | t.string "exit_status" |
|
217 | 218 | t.integer "memory_usage" |
|
218 | 219 | end |
|
219 | 220 | |
|
220 | 221 | add_index "test_requests", ["user_id", "problem_id"], :name => "index_test_requests_on_user_id_and_problem_id" |
|
221 | 222 | |
|
222 | 223 | create_table "user_contest_stats", :force => true do |t| |
|
223 | 224 | t.integer "user_id" |
|
224 | 225 | t.datetime "started_at" |
|
225 | 226 | t.datetime "created_at", :null => false |
|
226 | 227 | t.datetime "updated_at", :null => false |
|
227 | 228 | t.boolean "forced_logout" |
|
228 | 229 | end |
|
229 | 230 | |
|
230 | 231 | create_table "users", :force => true do |t| |
|
231 | 232 | t.string "login", :limit => 50 |
|
232 | 233 | t.string "full_name" |
|
233 | 234 | t.string "hashed_password" |
|
234 | 235 | t.string "salt", :limit => 5 |
|
235 | 236 | t.string "alias" |
|
236 | 237 | t.string "email" |
|
237 | 238 | t.integer "site_id" |
|
238 | 239 | t.integer "country_id" |
|
239 | 240 | t.boolean "activated", :default => false |
|
240 | 241 | t.datetime "created_at" |
|
241 | 242 | t.datetime "updated_at" |
|
242 | 243 | end |
|
243 | 244 | |
|
244 | 245 | add_index "users", ["login"], :name => "index_users_on_login", :unique => true |
|
245 | 246 | |
|
246 | 247 | end |
You need to be logged in to leave comments.
Login now