Description:
MERGED changeset 404:406 from ytopc branch
git-svn-id: http://theory.cpe.ku.ac.th/grader/web/trunk@425 6386c4cd-e34a-4fa8-8920-d93eb39b512e
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r197:7e5cbcab36dd - - 3 files changed: 20 inserted, 4 deleted
new file 100644 | |||||
binary diff hidden |
@@ -1,317 +1,326 | |||||
|
1 | class MainController < ApplicationController |
|
1 | class MainController < ApplicationController |
|
2 |
|
2 | ||
|
3 | SYSTEM_MODE_CONF_KEY = 'system.mode' |
|
3 | SYSTEM_MODE_CONF_KEY = 'system.mode' |
|
4 |
|
4 | ||
|
5 | before_filter :authenticate, :except => [:index, :login] |
|
5 | before_filter :authenticate, :except => [:index, :login] |
|
6 | before_filter :check_viewability, :except => [:index, :login] |
|
6 | before_filter :check_viewability, :except => [:index, :login] |
|
7 |
|
7 | ||
|
8 | # COMMENTED OUT: filter in each action instead |
|
8 | # COMMENTED OUT: filter in each action instead |
|
9 | # before_filter :verify_time_limit, :only => [:submit] |
|
9 | # before_filter :verify_time_limit, :only => [:submit] |
|
10 |
|
10 | ||
|
11 | verify :method => :post, :only => [:submit], |
|
11 | verify :method => :post, :only => [:submit], |
|
12 | :redirect_to => { :action => :index } |
|
12 | :redirect_to => { :action => :index } |
|
13 |
|
13 | ||
|
14 | # COMMENT OUT: only need when having high load |
|
14 | # COMMENT OUT: only need when having high load |
|
15 | # caches_action :index, :login |
|
15 | # caches_action :index, :login |
|
16 |
|
16 | ||
|
17 | # NOTE: This method is not actually needed, 'config/routes.rb' has |
|
17 | # NOTE: This method is not actually needed, 'config/routes.rb' has |
|
18 | # assigned action login as a default action. |
|
18 | # assigned action login as a default action. |
|
19 | def index |
|
19 | def index |
|
20 | redirect_to :action => 'login' |
|
20 | redirect_to :action => 'login' |
|
21 | end |
|
21 | end |
|
22 |
|
22 | ||
|
23 | def login |
|
23 | def login |
|
24 | saved_notice = flash[:notice] |
|
24 | saved_notice = flash[:notice] |
|
25 | reset_session |
|
25 | reset_session |
|
26 | flash[:notice] = saved_notice |
|
26 | flash[:notice] = saved_notice |
|
27 |
|
27 | ||
|
28 | # EXPERIMENT: |
|
28 | # EXPERIMENT: |
|
29 | # Hide login if in single user mode and the url does not |
|
29 | # Hide login if in single user mode and the url does not |
|
30 | # explicitly specify /login |
|
30 | # explicitly specify /login |
|
31 | # |
|
31 | # |
|
32 | # logger.info "PATH: #{request.path}" |
|
32 | # logger.info "PATH: #{request.path}" |
|
33 | # if Configuration['system.single_user_mode'] and |
|
33 | # if Configuration['system.single_user_mode'] and |
|
34 | # request.path!='/main/login' |
|
34 | # request.path!='/main/login' |
|
35 | # @hidelogin = true |
|
35 | # @hidelogin = true |
|
36 | # end |
|
36 | # end |
|
37 |
|
37 | ||
|
38 | @announcements = Announcement.find_for_frontpage |
|
38 | @announcements = Announcement.find_for_frontpage |
|
39 | render :action => 'login', :layout => 'empty' |
|
39 | render :action => 'login', :layout => 'empty' |
|
40 | end |
|
40 | end |
|
41 |
|
41 | ||
|
42 | def list |
|
42 | def list |
|
43 | prepare_list_information |
|
43 | prepare_list_information |
|
44 | end |
|
44 | end |
|
45 |
|
45 | ||
|
46 | def help |
|
46 | def help |
|
47 | @user = User.find(session[:user_id]) |
|
47 | @user = User.find(session[:user_id]) |
|
48 | end |
|
48 | end |
|
49 |
|
49 | ||
|
50 | def submit |
|
50 | def submit |
|
51 | user = User.find(session[:user_id]) |
|
51 | user = User.find(session[:user_id]) |
|
52 |
|
52 | ||
|
53 | @submission = Submission.new(params[:submission]) |
|
53 | @submission = Submission.new(params[:submission]) |
|
54 | @submission.user = user |
|
54 | @submission.user = user |
|
55 | @submission.language_id = 0 |
|
55 | @submission.language_id = 0 |
|
56 | if (params['file']) and (params['file']!='') |
|
56 | if (params['file']) and (params['file']!='') |
|
57 | @submission.source = params['file'].read |
|
57 | @submission.source = params['file'].read |
|
58 | @submission.source_filename = params['file'].original_filename |
|
58 | @submission.source_filename = params['file'].original_filename |
|
59 | end |
|
59 | end |
|
60 | @submission.submitted_at = Time.new.gmtime |
|
60 | @submission.submitted_at = Time.new.gmtime |
|
61 |
|
61 | ||
|
62 | if Configuration[SYSTEM_MODE_CONF_KEY]=='contest' and |
|
62 | if Configuration[SYSTEM_MODE_CONF_KEY]=='contest' and |
|
63 | user.site!=nil and user.site.finished? |
|
63 | user.site!=nil and user.site.finished? |
|
64 | @submission.errors.add_to_base "The contest is over." |
|
64 | @submission.errors.add_to_base "The contest is over." |
|
65 | prepare_list_information |
|
65 | prepare_list_information |
|
66 | render :action => 'list' and return |
|
66 | render :action => 'list' and return |
|
67 | end |
|
67 | end |
|
68 |
|
68 | ||
|
69 | if @submission.valid? |
|
69 | if @submission.valid? |
|
70 | if @submission.save == false |
|
70 | if @submission.save == false |
|
71 | flash[:notice] = 'Error saving your submission' |
|
71 | flash[:notice] = 'Error saving your submission' |
|
72 | elsif Task.create(:submission_id => @submission.id, |
|
72 | elsif Task.create(:submission_id => @submission.id, |
|
73 | :status => Task::STATUS_INQUEUE) == false |
|
73 | :status => Task::STATUS_INQUEUE) == false |
|
74 | flash[:notice] = 'Error adding your submission to task queue' |
|
74 | flash[:notice] = 'Error adding your submission to task queue' |
|
75 | end |
|
75 | end |
|
76 | else |
|
76 | else |
|
77 | prepare_list_information |
|
77 | prepare_list_information |
|
78 | render :action => 'list' and return |
|
78 | render :action => 'list' and return |
|
79 | end |
|
79 | end |
|
80 | redirect_to :action => 'list' |
|
80 | redirect_to :action => 'list' |
|
81 | end |
|
81 | end |
|
82 |
|
82 | ||
|
83 | def source |
|
83 | def source |
|
84 | submission = Submission.find(params[:id]) |
|
84 | submission = Submission.find(params[:id]) |
|
85 | if submission.user_id == session[:user_id] |
|
85 | if submission.user_id == session[:user_id] |
|
86 | send_data(submission.source, |
|
86 | send_data(submission.source, |
|
87 | {:filename => submission.download_filename, |
|
87 | {:filename => submission.download_filename, |
|
88 | :type => 'text/plain'}) |
|
88 | :type => 'text/plain'}) |
|
89 | else |
|
89 | else |
|
90 | flash[:notice] = 'Error viewing source' |
|
90 | flash[:notice] = 'Error viewing source' |
|
91 | redirect_to :action => 'list' |
|
91 | redirect_to :action => 'list' |
|
92 | end |
|
92 | end |
|
93 | end |
|
93 | end |
|
94 |
|
94 | ||
|
95 | def compiler_msg |
|
95 | def compiler_msg |
|
96 | @submission = Submission.find(params[:id]) |
|
96 | @submission = Submission.find(params[:id]) |
|
97 | if @submission.user_id == session[:user_id] |
|
97 | if @submission.user_id == session[:user_id] |
|
98 | render :action => 'compiler_msg', :layout => 'empty' |
|
98 | render :action => 'compiler_msg', :layout => 'empty' |
|
99 | else |
|
99 | else |
|
100 | flash[:notice] = 'Error viewing source' |
|
100 | flash[:notice] = 'Error viewing source' |
|
101 | redirect_to :action => 'list' |
|
101 | redirect_to :action => 'list' |
|
102 | end |
|
102 | end |
|
103 | end |
|
103 | end |
|
104 |
|
104 | ||
|
105 | def submission |
|
105 | def submission |
|
106 | @user = User.find(session[:user_id]) |
|
106 | @user = User.find(session[:user_id]) |
|
107 | @problems = Problem.find_available_problems |
|
107 | @problems = Problem.find_available_problems |
|
108 | if params[:id]==nil |
|
108 | if params[:id]==nil |
|
109 | @problem = nil |
|
109 | @problem = nil |
|
110 | @submissions = nil |
|
110 | @submissions = nil |
|
111 | else |
|
111 | else |
|
112 | @problem = Problem.find_by_name(params[:id]) |
|
112 | @problem = Problem.find_by_name(params[:id]) |
|
113 | if not @problem.available |
|
113 | if not @problem.available |
|
114 | redirect_to :action => 'list' |
|
114 | redirect_to :action => 'list' |
|
115 | flash[:notice] = 'Error: submissions for that problem are not viewable.' |
|
115 | flash[:notice] = 'Error: submissions for that problem are not viewable.' |
|
116 | return |
|
116 | return |
|
117 | end |
|
117 | end |
|
118 | @submissions = Submission.find_all_by_user_problem(@user.id, @problem.id) |
|
118 | @submissions = Submission.find_all_by_user_problem(@user.id, @problem.id) |
|
119 | end |
|
119 | end |
|
120 | end |
|
120 | end |
|
121 |
|
121 | ||
|
122 | def result |
|
122 | def result |
|
123 | if !Configuration.show_grading_result |
|
123 | if !Configuration.show_grading_result |
|
124 | redirect_to :action => 'list' and return |
|
124 | redirect_to :action => 'list' and return |
|
125 | end |
|
125 | end |
|
126 | @user = User.find(session[:user_id]) |
|
126 | @user = User.find(session[:user_id]) |
|
127 | @submission = Submission.find(params[:id]) |
|
127 | @submission = Submission.find(params[:id]) |
|
128 | if @submission.user!=@user |
|
128 | if @submission.user!=@user |
|
129 | flash[:notice] = 'You are not allowed to view result of other users.' |
|
129 | flash[:notice] = 'You are not allowed to view result of other users.' |
|
130 | redirect_to :action => 'list' and return |
|
130 | redirect_to :action => 'list' and return |
|
131 | end |
|
131 | end |
|
132 | prepare_grading_result(@submission) |
|
132 | prepare_grading_result(@submission) |
|
133 | end |
|
133 | end |
|
134 |
|
134 | ||
|
135 | def load_output |
|
135 | def load_output |
|
136 | if !Configuration.show_grading_result or params[:num]==nil |
|
136 | if !Configuration.show_grading_result or params[:num]==nil |
|
137 | redirect_to :action => 'list' and return |
|
137 | redirect_to :action => 'list' and return |
|
138 | end |
|
138 | end |
|
139 | @user = User.find(session[:user_id]) |
|
139 | @user = User.find(session[:user_id]) |
|
140 | @submission = Submission.find(params[:id]) |
|
140 | @submission = Submission.find(params[:id]) |
|
141 | if @submission.user!=@user |
|
141 | if @submission.user!=@user |
|
142 | flash[:notice] = 'You are not allowed to view result of other users.' |
|
142 | flash[:notice] = 'You are not allowed to view result of other users.' |
|
143 | redirect_to :action => 'list' and return |
|
143 | redirect_to :action => 'list' and return |
|
144 | end |
|
144 | end |
|
145 | case_num = params[:num].to_i |
|
145 | case_num = params[:num].to_i |
|
146 | out_filename = output_filename(@user.login, |
|
146 | out_filename = output_filename(@user.login, |
|
147 | @submission.problem.name, |
|
147 | @submission.problem.name, |
|
148 | @submission.id, |
|
148 | @submission.id, |
|
149 | case_num) |
|
149 | case_num) |
|
150 | if !FileTest.exists?(out_filename) |
|
150 | if !FileTest.exists?(out_filename) |
|
151 | flash[:notice] = 'Output not found.' |
|
151 | flash[:notice] = 'Output not found.' |
|
152 | redirect_to :action => 'list' and return |
|
152 | redirect_to :action => 'list' and return |
|
153 | end |
|
153 | end |
|
154 |
|
154 | ||
|
155 | response.headers['Content-Type'] = "application/force-download" |
|
155 | response.headers['Content-Type'] = "application/force-download" |
|
156 | response.headers['Content-Disposition'] = "attachment; filename=\"output-#{case_num}.txt\"" |
|
156 | response.headers['Content-Disposition'] = "attachment; filename=\"output-#{case_num}.txt\"" |
|
157 | response.headers["X-Sendfile"] = out_filename |
|
157 | response.headers["X-Sendfile"] = out_filename |
|
158 | response.headers['Content-length'] = File.size(out_filename) |
|
158 | response.headers['Content-length'] = File.size(out_filename) |
|
159 | render :nothing => true |
|
159 | render :nothing => true |
|
160 | end |
|
160 | end |
|
161 |
|
161 | ||
|
162 | def error |
|
162 | def error |
|
163 | @user = User.find(session[:user_id]) |
|
163 | @user = User.find(session[:user_id]) |
|
164 | end |
|
164 | end |
|
165 |
|
165 | ||
|
166 | # announcement refreshing and hiding methods |
|
166 | # announcement refreshing and hiding methods |
|
167 |
|
167 | ||
|
168 | def announcements |
|
168 | def announcements |
|
169 | if params.has_key? 'recent' |
|
169 | if params.has_key? 'recent' |
|
170 | prepare_announcements(params[:recent]) |
|
170 | prepare_announcements(params[:recent]) |
|
171 | else |
|
171 | else |
|
172 | prepare_announcements |
|
172 | prepare_announcements |
|
173 | end |
|
173 | end |
|
174 | render(:partial => 'announcement', |
|
174 | render(:partial => 'announcement', |
|
175 | :collection => @announcements, |
|
175 | :collection => @announcements, |
|
176 | :locals => {:announcement_effect => true}) |
|
176 | :locals => {:announcement_effect => true}) |
|
177 | end |
|
177 | end |
|
178 |
|
178 | ||
|
179 | protected |
|
179 | protected |
|
180 |
|
180 | ||
|
181 | def prepare_announcements(recent=nil) |
|
181 | def prepare_announcements(recent=nil) |
|
182 | if Configuration.show_tasks_to?(@user) |
|
182 | if Configuration.show_tasks_to?(@user) |
|
183 | @announcements = Announcement.find_published(true) |
|
183 | @announcements = Announcement.find_published(true) |
|
184 | else |
|
184 | else |
|
185 | @announcements = Announcement.find_published |
|
185 | @announcements = Announcement.find_published |
|
186 | end |
|
186 | end |
|
187 | if recent!=nil |
|
187 | if recent!=nil |
|
188 | recent_id = recent.to_i |
|
188 | recent_id = recent.to_i |
|
189 | @announcements = @announcements.find_all { |a| a.id > recent_id } |
|
189 | @announcements = @announcements.find_all { |a| a.id > recent_id } |
|
190 | end |
|
190 | end |
|
191 | end |
|
191 | end |
|
192 |
|
192 | ||
|
193 | def prepare_list_information |
|
193 | def prepare_list_information |
|
194 | @problems = Problem.find_available_problems |
|
194 | @problems = Problem.find_available_problems |
|
195 | @prob_submissions = Array.new |
|
195 | @prob_submissions = Array.new |
|
196 | @user = User.find(session[:user_id]) |
|
196 | @user = User.find(session[:user_id]) |
|
197 | @problems.each do |p| |
|
197 | @problems.each do |p| |
|
198 | sub = Submission.find_last_by_user_and_problem(@user.id,p.id) |
|
198 | sub = Submission.find_last_by_user_and_problem(@user.id,p.id) |
|
199 | if sub!=nil |
|
199 | if sub!=nil |
|
200 | @prob_submissions << { :count => sub.number, :submission => sub } |
|
200 | @prob_submissions << { :count => sub.number, :submission => sub } |
|
201 | else |
|
201 | else |
|
202 | @prob_submissions << { :count => 0, :submission => nil } |
|
202 | @prob_submissions << { :count => 0, :submission => nil } |
|
203 | end |
|
203 | end |
|
204 | end |
|
204 | end |
|
205 | prepare_announcements |
|
205 | prepare_announcements |
|
206 | end |
|
206 | end |
|
207 |
|
207 | ||
|
208 | def check_viewability |
|
208 | def check_viewability |
|
209 | @user = User.find(session[:user_id]) |
|
209 | @user = User.find(session[:user_id]) |
|
210 | if (!Configuration.show_tasks_to?(@user)) and |
|
210 | if (!Configuration.show_tasks_to?(@user)) and |
|
211 | ((action_name=='submission') or (action_name=='submit')) |
|
211 | ((action_name=='submission') or (action_name=='submit')) |
|
212 | redirect_to :action => 'list' and return |
|
212 | redirect_to :action => 'list' and return |
|
213 | end |
|
213 | end |
|
214 | end |
|
214 | end |
|
215 |
|
215 | ||
|
216 | def prepare_grading_result(submission) |
|
216 | def prepare_grading_result(submission) |
|
217 |
- |
|
217 | + if Configuration.task_grading_info.has_key? submission.problem.name |
|
|
218 | + grading_info = Configuration.task_grading_info[submission.problem.name] | ||
|
|
219 | + else | ||
|
|
220 | + # guess task info from problem.full_score | ||
|
|
221 | + cases = submission.problem.full_score / 10 | ||
|
|
222 | + grading_info = { | ||
|
|
223 | + 'testruns' => cases, | ||
|
|
224 | + 'testcases' => cases | ||
|
|
225 | + } | ||
|
|
226 | + end | ||
|
218 | @test_runs = [] |
|
227 | @test_runs = [] |
|
219 | if grading_info['testruns'].is_a? Integer |
|
228 | if grading_info['testruns'].is_a? Integer |
|
220 | trun_count = grading_info['testruns'] |
|
229 | trun_count = grading_info['testruns'] |
|
221 | trun_count.times do |i| |
|
230 | trun_count.times do |i| |
|
222 | @test_runs << [ read_grading_result(@user.login, |
|
231 | @test_runs << [ read_grading_result(@user.login, |
|
223 | submission.problem.name, |
|
232 | submission.problem.name, |
|
224 | submission.id, |
|
233 | submission.id, |
|
225 | i+1) ] |
|
234 | i+1) ] |
|
226 | end |
|
235 | end |
|
227 | else |
|
236 | else |
|
228 | grading_info['testruns'].keys.sort.each do |num| |
|
237 | grading_info['testruns'].keys.sort.each do |num| |
|
229 | run = [] |
|
238 | run = [] |
|
230 | testrun = grading_info['testruns'][num] |
|
239 | testrun = grading_info['testruns'][num] |
|
231 | testrun.each do |c| |
|
240 | testrun.each do |c| |
|
232 | run << read_grading_result(@user.login, |
|
241 | run << read_grading_result(@user.login, |
|
233 | submission.problem.name, |
|
242 | submission.problem.name, |
|
234 | submission.id, |
|
243 | submission.id, |
|
235 | c) |
|
244 | c) |
|
236 | end |
|
245 | end |
|
237 | @test_runs << run |
|
246 | @test_runs << run |
|
238 | end |
|
247 | end |
|
239 | end |
|
248 | end |
|
240 | end |
|
249 | end |
|
241 |
|
250 | ||
|
242 | def grading_result_dir(user_name, problem_name, submission_id, case_num) |
|
251 | def grading_result_dir(user_name, problem_name, submission_id, case_num) |
|
243 | return "#{GRADING_RESULT_DIR}/#{user_name}/#{problem_name}/#{submission_id}/test-result/#{case_num}" |
|
252 | return "#{GRADING_RESULT_DIR}/#{user_name}/#{problem_name}/#{submission_id}/test-result/#{case_num}" |
|
244 | end |
|
253 | end |
|
245 |
|
254 | ||
|
246 | def output_filename(user_name, problem_name, submission_id, case_num) |
|
255 | def output_filename(user_name, problem_name, submission_id, case_num) |
|
247 | dir = grading_result_dir(user_name,problem_name, submission_id, case_num) |
|
256 | dir = grading_result_dir(user_name,problem_name, submission_id, case_num) |
|
248 | return "#{dir}/output.txt" |
|
257 | return "#{dir}/output.txt" |
|
249 | end |
|
258 | end |
|
250 |
|
259 | ||
|
251 | def read_grading_result(user_name, problem_name, submission_id, case_num) |
|
260 | def read_grading_result(user_name, problem_name, submission_id, case_num) |
|
252 | dir = grading_result_dir(user_name,problem_name, submission_id, case_num) |
|
261 | dir = grading_result_dir(user_name,problem_name, submission_id, case_num) |
|
253 | result_file_name = "#{dir}/result" |
|
262 | result_file_name = "#{dir}/result" |
|
254 | if !FileTest.exists?(result_file_name) |
|
263 | if !FileTest.exists?(result_file_name) |
|
255 | return {:num => case_num, :msg => 'program did not run'} |
|
264 | return {:num => case_num, :msg => 'program did not run'} |
|
256 | else |
|
265 | else |
|
257 | results = File.open(result_file_name).readlines |
|
266 | results = File.open(result_file_name).readlines |
|
258 | run_stat = extract_running_stat(results) |
|
267 | run_stat = extract_running_stat(results) |
|
259 | output_filename = "#{dir}/output.txt" |
|
268 | output_filename = "#{dir}/output.txt" |
|
260 | if FileTest.exists?(output_filename) |
|
269 | if FileTest.exists?(output_filename) |
|
261 | output_file = true |
|
270 | output_file = true |
|
262 | output_size = File.size(output_filename) |
|
271 | output_size = File.size(output_filename) |
|
263 | else |
|
272 | else |
|
264 | output_file = false |
|
273 | output_file = false |
|
265 | output_size = 0 |
|
274 | output_size = 0 |
|
266 | end |
|
275 | end |
|
267 |
|
276 | ||
|
268 | return { |
|
277 | return { |
|
269 | :num => case_num, |
|
278 | :num => case_num, |
|
270 | :msg => results[0], |
|
279 | :msg => results[0], |
|
271 | :run_stat => run_stat, |
|
280 | :run_stat => run_stat, |
|
272 | :output => output_file, |
|
281 | :output => output_file, |
|
273 | :output_size => output_size |
|
282 | :output_size => output_size |
|
274 | } |
|
283 | } |
|
275 | end |
|
284 | end |
|
276 | end |
|
285 | end |
|
277 |
|
286 | ||
|
278 | # copied from grader/script/lib/test_request_helper.rb |
|
287 | # copied from grader/script/lib/test_request_helper.rb |
|
279 | def extract_running_stat(results) |
|
288 | def extract_running_stat(results) |
|
280 | running_stat_line = results[-1] |
|
289 | running_stat_line = results[-1] |
|
281 |
|
290 | ||
|
282 | # extract exit status line |
|
291 | # extract exit status line |
|
283 | run_stat = "" |
|
292 | run_stat = "" |
|
284 | if !(/[Cc]orrect/.match(results[0])) |
|
293 | if !(/[Cc]orrect/.match(results[0])) |
|
285 | run_stat = results[0].chomp |
|
294 | run_stat = results[0].chomp |
|
286 | else |
|
295 | else |
|
287 | run_stat = 'Program exited normally' |
|
296 | run_stat = 'Program exited normally' |
|
288 | end |
|
297 | end |
|
289 |
|
298 | ||
|
290 | logger.info "Stat line: #{running_stat_line}" |
|
299 | logger.info "Stat line: #{running_stat_line}" |
|
291 |
|
300 | ||
|
292 | # extract running time |
|
301 | # extract running time |
|
293 | if res = /r(.*)u(.*)s/.match(running_stat_line) |
|
302 | if res = /r(.*)u(.*)s/.match(running_stat_line) |
|
294 | seconds = (res[1].to_f + res[2].to_f) |
|
303 | seconds = (res[1].to_f + res[2].to_f) |
|
295 | time_stat = "Time used: #{seconds} sec." |
|
304 | time_stat = "Time used: #{seconds} sec." |
|
296 | else |
|
305 | else |
|
297 | seconds = nil |
|
306 | seconds = nil |
|
298 | time_stat = "Time used: n/a sec." |
|
307 | time_stat = "Time used: n/a sec." |
|
299 | end |
|
308 | end |
|
300 |
|
309 | ||
|
301 | # extract memory usage |
|
310 | # extract memory usage |
|
302 | if res = /s(.*)m/.match(running_stat_line) |
|
311 | if res = /s(.*)m/.match(running_stat_line) |
|
303 | memory_used = res[1].to_i |
|
312 | memory_used = res[1].to_i |
|
304 | else |
|
313 | else |
|
305 | memory_used = -1 |
|
314 | memory_used = -1 |
|
306 | end |
|
315 | end |
|
307 |
|
316 | ||
|
308 | return { |
|
317 | return { |
|
309 | :msg => "#{run_stat}\n#{time_stat}", |
|
318 | :msg => "#{run_stat}\n#{time_stat}", |
|
310 | :running_time => seconds, |
|
319 | :running_time => seconds, |
|
311 | :exit_status => run_stat, |
|
320 | :exit_status => run_stat, |
|
312 | :memory_usage => memory_used |
|
321 | :memory_usage => memory_used |
|
313 | } |
|
322 | } |
|
314 | end |
|
323 | end |
|
315 |
|
324 | ||
|
316 | end |
|
325 | end |
|
317 |
|
326 |
@@ -1,336 +1,343 | |||||
|
1 | /* Main Default */ |
|
1 | /* Main Default */ |
|
2 | body { |
|
2 | body { |
|
3 | background: white url(../images/topbg.jpg) repeat-x top center; |
|
3 | background: white url(../images/topbg.jpg) repeat-x top center; |
|
4 | font-size: 13px; |
|
4 | font-size: 13px; |
|
5 | font-family: Tahoma, "sans-serif"; |
|
5 | font-family: Tahoma, "sans-serif"; |
|
6 | margin: 10px; |
|
6 | margin: 10px; |
|
7 | padding: 10px; |
|
7 | padding: 10px; |
|
8 | } |
|
8 | } |
|
9 |
|
9 | ||
|
10 | /* Form Font */ |
|
10 | /* Form Font */ |
|
11 | input { |
|
11 | input { |
|
12 | font-family: Tahoma, "sans-serif"; |
|
12 | font-family: Tahoma, "sans-serif"; |
|
13 | } |
|
13 | } |
|
14 |
|
14 | ||
|
15 |
- /* Heading 1 |
|
15 | + /* Heading 1&2 */ |
|
16 | h1 { |
|
16 | h1 { |
|
17 | font-size: 24px; |
|
17 | font-size: 24px; |
|
18 | color: #334488; |
|
18 | color: #334488; |
|
19 | line-height: 2em; |
|
19 | line-height: 2em; |
|
20 | } |
|
20 | } |
|
21 |
|
21 | ||
|
22 | h2 { |
|
22 | h2 { |
|
23 | font-size: 18px; |
|
23 | font-size: 18px; |
|
24 | color: #5566bb; |
|
24 | color: #5566bb; |
|
25 | line-height: 1.5em; |
|
25 | line-height: 1.5em; |
|
26 | } |
|
26 | } |
|
27 |
|
27 | ||
|
28 | /* Bar Line Color and Thickness */ |
|
28 | /* Bar Line Color and Thickness */ |
|
29 | hr { |
|
29 | hr { |
|
30 | border-top: 1px solid #dddddd; |
|
30 | border-top: 1px solid #dddddd; |
|
31 | border-bottom: 1px solid #eeeeee; |
|
31 | border-bottom: 1px solid #eeeeee; |
|
32 | } |
|
32 | } |
|
33 |
|
33 | ||
|
34 | /* Link + Anchor Color */ |
|
34 | /* Link + Anchor Color */ |
|
35 | a, a:link, a:visited { |
|
35 | a, a:link, a:visited { |
|
36 | color: #6666cc; |
|
36 | color: #6666cc; |
|
37 | text-decoration: none; |
|
37 | text-decoration: none; |
|
38 | } |
|
38 | } |
|
39 |
|
39 | ||
|
40 | a:hover, a:focus { |
|
40 | a:hover, a:focus { |
|
41 | color: #111166; |
|
41 | color: #111166; |
|
42 | text-decoration: none; |
|
42 | text-decoration: none; |
|
43 | } |
|
43 | } |
|
44 |
|
44 | ||
|
45 | /* This is the main menu bad*/ |
|
45 | /* This is the main menu bad*/ |
|
46 | div.userbar { |
|
46 | div.userbar { |
|
47 | line-height: 1.5em; |
|
47 | line-height: 1.5em; |
|
48 | text-align: right; |
|
48 | text-align: right; |
|
49 | font-size: 12px; |
|
49 | font-size: 12px; |
|
50 | } |
|
50 | } |
|
51 |
|
51 | ||
|
52 | /* This is the top bar, displaying user's full name */ |
|
52 | /* This is the top bar, displaying user's full name */ |
|
53 | div.title { |
|
53 | div.title { |
|
54 | // background: #ddddff; |
|
54 | // background: #ddddff; |
|
55 | // border: 1px dashed blue; |
|
55 | // border: 1px dashed blue; |
|
56 | padding: 10px 0px; |
|
56 | padding: 10px 0px; |
|
57 | line-height: 1.5em; |
|
57 | line-height: 1.5em; |
|
58 | font-size: 13px; |
|
58 | font-size: 13px; |
|
59 | } |
|
59 | } |
|
60 |
|
60 | ||
|
61 | div.title span.contest-over-msg { |
|
61 | div.title span.contest-over-msg { |
|
62 | font-size: 15px; |
|
62 | font-size: 15px; |
|
63 | color: red; |
|
63 | color: red; |
|
64 | } |
|
64 | } |
|
65 |
|
65 | ||
|
66 | div.title table { |
|
66 | div.title table { |
|
67 | width: 100%; |
|
67 | width: 100%; |
|
|
68 | + font-weight: bold; | ||
|
68 | } |
|
69 | } |
|
69 |
|
70 | ||
|
70 | div.title td.left-col { |
|
71 | div.title td.left-col { |
|
71 | text-align: left; |
|
72 | text-align: left; |
|
72 | vertical-align: top; |
|
73 | vertical-align: top; |
|
73 | color: #444444; |
|
74 | color: #444444; |
|
74 | } |
|
75 | } |
|
75 |
|
76 | ||
|
76 | div.title td.right-col { |
|
77 | div.title td.right-col { |
|
77 | text-align: right; |
|
78 | text-align: right; |
|
78 | vertical-align: top; |
|
79 | vertical-align: top; |
|
79 |
- font-size: 1 |
|
80 | + font-size: 18px; |
|
80 | - font-weight: bold; |
|
||
|
81 | color: #116699; |
|
81 | color: #116699; |
|
82 | } |
|
82 | } |
|
83 |
|
83 | ||
|
84 | /* Standard table with header and rows with alternating background */ |
|
84 | /* Standard table with header and rows with alternating background */ |
|
85 | table.info { |
|
85 | table.info { |
|
86 | margin: 10px 0; |
|
86 | margin: 10px 0; |
|
87 | border: 1px solid #666666; |
|
87 | border: 1px solid #666666; |
|
88 | border-collapse: collapse; |
|
88 | border-collapse: collapse; |
|
89 | font-size: 12px; |
|
89 | font-size: 12px; |
|
90 | } |
|
90 | } |
|
91 |
|
91 | ||
|
92 | table.info th { |
|
92 | table.info th { |
|
93 | border: 1px solid #666666; |
|
93 | border: 1px solid #666666; |
|
94 | line-height: 1.5em; |
|
94 | line-height: 1.5em; |
|
95 | padding: 0 0.5em; |
|
95 | padding: 0 0.5em; |
|
96 | } |
|
96 | } |
|
97 |
|
97 | ||
|
98 | table.info td { |
|
98 | table.info td { |
|
99 | border-left: 1px solid #666666; |
|
99 | border-left: 1px solid #666666; |
|
100 | border-right: 1px solid #666666; |
|
100 | border-right: 1px solid #666666; |
|
101 | line-height: 1.5em; |
|
101 | line-height: 1.5em; |
|
102 | padding: 0 0.5em; |
|
102 | padding: 0 0.5em; |
|
103 | } |
|
103 | } |
|
104 |
|
104 | ||
|
105 | tr.info-head { |
|
105 | tr.info-head { |
|
106 | background: #777777; |
|
106 | background: #777777; |
|
107 | color: white; |
|
107 | color: white; |
|
108 | } |
|
108 | } |
|
109 |
|
109 | ||
|
110 | tr.info-odd { |
|
110 | tr.info-odd { |
|
111 | background: #eeeeee; |
|
111 | background: #eeeeee; |
|
112 | } |
|
112 | } |
|
113 |
|
113 | ||
|
114 | tr.info-even { |
|
114 | tr.info-even { |
|
115 | background: #f9f9f9; |
|
115 | background: #f9f9f9; |
|
116 | } |
|
116 | } |
|
117 |
|
117 | ||
|
118 | /******************************* |
|
118 | /******************************* |
|
119 | [Main] |
|
119 | [Main] |
|
120 | ********************************/ |
|
120 | ********************************/ |
|
121 | div.submitbox { |
|
121 | div.submitbox { |
|
122 | background: #eeeeff; |
|
122 | background: #eeeeff; |
|
123 | border: 1px dotted #99aaee; |
|
123 | border: 1px dotted #99aaee; |
|
124 | padding: 5px; |
|
124 | padding: 5px; |
|
125 | margin: 10px 0px; |
|
125 | margin: 10px 0px; |
|
126 | color: black; |
|
126 | color: black; |
|
127 | font-weight: bold; |
|
127 | font-weight: bold; |
|
128 | font-size: 13px; |
|
128 | font-size: 13px; |
|
129 | } |
|
129 | } |
|
130 |
|
130 | ||
|
131 | div.errorExplanation { |
|
131 | div.errorExplanation { |
|
132 | border: 1px dotted gray; |
|
132 | border: 1px dotted gray; |
|
133 | color: #bb2222; |
|
133 | color: #bb2222; |
|
134 | padding: 5px 15px 5px 15px; |
|
134 | padding: 5px 15px 5px 15px; |
|
135 | margin-bottom: 5px; |
|
135 | margin-bottom: 5px; |
|
136 | background-color: white; |
|
136 | background-color: white; |
|
|
137 | + font-weight: normal; | ||
|
|
138 | + } | ||
|
|
139 | + | ||
|
|
140 | + | ||
|
|
141 | + div.errorExplanation h2 { | ||
|
|
142 | + color: #cc1111; | ||
|
|
143 | + font-weight: bold; | ||
|
137 | } |
|
144 | } |
|
138 |
|
145 | ||
|
139 | /******************************* |
|
146 | /******************************* |
|
140 | [Settings] |
|
147 | [Settings] |
|
141 | ********************************/ |
|
148 | ********************************/ |
|
142 | table.uinfo { |
|
149 | table.uinfo { |
|
143 | border-collapse: collapse; |
|
150 | border-collapse: collapse; |
|
144 | border: 1px solid black; |
|
151 | border: 1px solid black; |
|
145 | font-size: 13px; |
|
152 | font-size: 13px; |
|
146 | } |
|
153 | } |
|
147 |
|
154 | ||
|
148 | td.uinfo { |
|
155 | td.uinfo { |
|
149 | vertical-align: top; |
|
156 | vertical-align: top; |
|
150 | border: 1px solid black; |
|
157 | border: 1px solid black; |
|
151 | padding: 5px; |
|
158 | padding: 5px; |
|
152 | } |
|
159 | } |
|
153 |
|
160 | ||
|
154 | th.uinfo { |
|
161 | th.uinfo { |
|
155 | background: lightgreen; |
|
162 | background: lightgreen; |
|
156 | vertical-align: top; |
|
163 | vertical-align: top; |
|
157 | text-align: right; |
|
164 | text-align: right; |
|
158 | border: 1px solid black; |
|
165 | border: 1px solid black; |
|
159 | padding: 5px; |
|
166 | padding: 5px; |
|
160 | } |
|
167 | } |
|
161 |
|
168 | ||
|
162 | /******************************* |
|
169 | /******************************* |
|
163 | [Submission] |
|
170 | [Submission] |
|
164 | ********************************/ |
|
171 | ********************************/ |
|
165 | div.compilermsgbody { |
|
172 | div.compilermsgbody { |
|
166 | font-family: monospace; |
|
173 | font-family: monospace; |
|
167 | } |
|
174 | } |
|
168 |
|
175 | ||
|
169 | div.task-menu { |
|
176 | div.task-menu { |
|
170 | text-align: center; |
|
177 | text-align: center; |
|
171 | font-size: 13px; |
|
178 | font-size: 13px; |
|
172 | line-height: 1.75em; |
|
179 | line-height: 1.75em; |
|
173 | font-weight: bold; |
|
180 | font-weight: bold; |
|
174 | border-top: 1px dashed gray; |
|
181 | border-top: 1px dashed gray; |
|
175 | border-bottom: 1px dashed gray; |
|
182 | border-bottom: 1px dashed gray; |
|
176 | margin-top: 2px; |
|
183 | margin-top: 2px; |
|
177 | margin-bottom: 4px; |
|
184 | margin-bottom: 4px; |
|
178 | } |
|
185 | } |
|
179 |
|
186 | ||
|
180 | /******************************* |
|
187 | /******************************* |
|
181 | [Submission] |
|
188 | [Submission] |
|
182 | ********************************/ |
|
189 | ********************************/ |
|
183 | table.taskdesc { |
|
190 | table.taskdesc { |
|
184 | border: 2px solid #dddddd; |
|
191 | border: 2px solid #dddddd; |
|
185 | border-collapse: collapse; |
|
192 | border-collapse: collapse; |
|
186 | margin: 10px auto; |
|
193 | margin: 10px auto; |
|
187 | width: 90%; |
|
194 | width: 90%; |
|
188 | font-size: 13px; |
|
195 | font-size: 13px; |
|
189 | } |
|
196 | } |
|
190 |
|
197 | ||
|
191 | table.taskdesc p { |
|
198 | table.taskdesc p { |
|
192 | font-size: 13px; |
|
199 | font-size: 13px; |
|
193 | } |
|
200 | } |
|
194 |
|
201 | ||
|
195 | table.taskdesc tr.name { |
|
202 | table.taskdesc tr.name { |
|
196 | border: 2px solid #dddddd; |
|
203 | border: 2px solid #dddddd; |
|
197 | background: #dddddd; |
|
204 | background: #dddddd; |
|
198 | color: #333333; |
|
205 | color: #333333; |
|
199 | font-weight: bold; |
|
206 | font-weight: bold; |
|
200 | font-size: 14px; |
|
207 | font-size: 14px; |
|
201 | line-height: 1.5em; |
|
208 | line-height: 1.5em; |
|
202 | text-align: center; |
|
209 | text-align: center; |
|
203 | } |
|
210 | } |
|
204 |
|
211 | ||
|
205 | table.taskdesc td.desc-odd { |
|
212 | table.taskdesc td.desc-odd { |
|
206 | padding: 5px; |
|
213 | padding: 5px; |
|
207 | padding-left: 20px; |
|
214 | padding-left: 20px; |
|
208 | background: #fefeee; |
|
215 | background: #fefeee; |
|
209 | } |
|
216 | } |
|
210 |
|
217 | ||
|
211 | table.taskdesc td.desc-even { |
|
218 | table.taskdesc td.desc-even { |
|
212 | padding: 5px; |
|
219 | padding: 5px; |
|
213 | padding-left: 20px; |
|
220 | padding-left: 20px; |
|
214 | background: #feeefe; |
|
221 | background: #feeefe; |
|
215 | } |
|
222 | } |
|
216 |
|
223 | ||
|
217 | /********************** |
|
224 | /********************** |
|
218 | Announcement |
|
225 | Announcement |
|
219 | ***********************/ |
|
226 | ***********************/ |
|
220 |
|
227 | ||
|
221 | div.announcementbox { |
|
228 | div.announcementbox { |
|
222 | margin: 10px 0px; |
|
229 | margin: 10px 0px; |
|
223 | background: #bbddee; |
|
230 | background: #bbddee; |
|
224 | padding: 1px; |
|
231 | padding: 1px; |
|
225 | } |
|
232 | } |
|
226 |
|
233 | ||
|
227 | div.announcementbox span.title { |
|
234 | div.announcementbox span.title { |
|
228 | font-weight: bold; |
|
235 | font-weight: bold; |
|
229 | color: #224455; |
|
236 | color: #224455; |
|
230 | padding-left: 10px; |
|
237 | padding-left: 10px; |
|
231 | line-height: 1.6em; |
|
238 | line-height: 1.6em; |
|
232 | } |
|
239 | } |
|
233 |
|
240 | ||
|
234 | div.announcement { |
|
241 | div.announcement { |
|
235 | margin: 2px; |
|
242 | margin: 2px; |
|
236 | background: white; |
|
243 | background: white; |
|
237 | padding: 1px; |
|
244 | padding: 1px; |
|
238 | padding-left: 10px; |
|
245 | padding-left: 10px; |
|
239 | padding-right: 10px; |
|
246 | padding-right: 10px; |
|
240 | padding-top: 5px; |
|
247 | padding-top: 5px; |
|
241 | padding-bottom: 5px; |
|
248 | padding-bottom: 5px; |
|
242 | } |
|
249 | } |
|
243 |
|
250 | ||
|
244 | .announcement p { |
|
251 | .announcement p { |
|
245 | font-size: 12px; |
|
252 | font-size: 12px; |
|
246 | margin: 2px; |
|
253 | margin: 2px; |
|
247 | } |
|
254 | } |
|
248 |
|
255 | ||
|
249 | div.pub-info, div.pub-info p { |
|
256 | div.pub-info, div.pub-info p { |
|
250 | text-align: right; |
|
257 | text-align: right; |
|
251 | font-style: italic; |
|
258 | font-style: italic; |
|
252 | font-size: 9px; |
|
259 | font-size: 9px; |
|
253 | } |
|
260 | } |
|
254 |
|
261 | ||
|
255 | .announcement .toggles { |
|
262 | .announcement .toggles { |
|
256 | font-weight: normal; |
|
263 | font-weight: normal; |
|
257 | float: right; |
|
264 | float: right; |
|
258 | font-size: 80%; |
|
265 | font-size: 80%; |
|
259 | } |
|
266 | } |
|
260 |
|
267 | ||
|
261 | .announcement .announcement-title { |
|
268 | .announcement .announcement-title { |
|
262 | font-weight: bold; |
|
269 | font-weight: bold; |
|
263 | } |
|
270 | } |
|
264 |
|
271 | ||
|
265 | /****************** |
|
272 | /****************** |
|
266 | Messages |
|
273 | Messages |
|
267 | ******************/ |
|
274 | ******************/ |
|
268 |
|
275 | ||
|
269 | div.message { |
|
276 | div.message { |
|
270 | margin: 10px 0 0; |
|
277 | margin: 10px 0 0; |
|
271 | } |
|
278 | } |
|
272 |
|
279 | ||
|
273 | div.message div.message { |
|
280 | div.message div.message { |
|
274 | margin: 0 0 0 30px; |
|
281 | margin: 0 0 0 30px; |
|
275 | } |
|
282 | } |
|
276 |
|
283 | ||
|
277 | div.message div.body { |
|
284 | div.message div.body { |
|
278 | border: 2px solid #dddddd; |
|
285 | border: 2px solid #dddddd; |
|
279 | background: #fff8f8; |
|
286 | background: #fff8f8; |
|
280 | padding-left: 5px; |
|
287 | padding-left: 5px; |
|
281 | } |
|
288 | } |
|
282 |
|
289 | ||
|
283 | div.message div.reply-body { |
|
290 | div.message div.reply-body { |
|
284 | border: 2px solid #bbbbbb; |
|
291 | border: 2px solid #bbbbbb; |
|
285 | background: #fffff8; |
|
292 | background: #fffff8; |
|
286 | padding-left: 5px; |
|
293 | padding-left: 5px; |
|
287 | } |
|
294 | } |
|
288 |
|
295 | ||
|
289 | div.message div.stat { |
|
296 | div.message div.stat { |
|
290 | font-size: 10px; |
|
297 | font-size: 10px; |
|
291 | line-height: 1.75em; |
|
298 | line-height: 1.75em; |
|
292 | padding: 0 5px; |
|
299 | padding: 0 5px; |
|
293 | color: #333333; |
|
300 | color: #333333; |
|
294 | background: #dddddd; |
|
301 | background: #dddddd; |
|
295 | font-weight: bold; |
|
302 | font-weight: bold; |
|
296 | } |
|
303 | } |
|
297 |
|
304 | ||
|
298 | div.message div.message div.stat { |
|
305 | div.message div.message div.stat { |
|
299 | font-size: 10px; |
|
306 | font-size: 10px; |
|
300 | line-height: 1.75em; |
|
307 | line-height: 1.75em; |
|
301 | padding: 0 5px; |
|
308 | padding: 0 5px; |
|
302 | color: #444444; |
|
309 | color: #444444; |
|
303 | background: #bbbbbb; |
|
310 | background: #bbbbbb; |
|
304 | font-weight: bold; |
|
311 | font-weight: bold; |
|
305 | } |
|
312 | } |
|
306 |
|
313 | ||
|
307 | /******************** |
|
314 | /******************** |
|
308 | Registration |
|
315 | Registration |
|
309 | ********************/ |
|
316 | ********************/ |
|
310 | div.contest-title { |
|
317 | div.contest-title { |
|
311 | color: white; |
|
318 | color: white; |
|
312 | text-align: center; |
|
319 | text-align: center; |
|
313 | line-height: 2em; |
|
320 | line-height: 2em; |
|
314 | } |
|
321 | } |
|
315 |
|
322 | ||
|
316 | div.registration-desc { |
|
323 | div.registration-desc { |
|
317 | border: 1px dotted gray; |
|
324 | border: 1px dotted gray; |
|
318 | background: #f5f5f5; |
|
325 | background: #f5f5f5; |
|
319 | padding: 5px; |
|
326 | padding: 5px; |
|
320 | margin: 10px 0; |
|
327 | margin: 10px 0; |
|
321 | font-size: 12px; |
|
328 | font-size: 12px; |
|
322 | line-height: 1.5em; |
|
329 | line-height: 1.5em; |
|
323 | } |
|
330 | } |
|
324 |
|
331 | ||
|
325 | /******************** |
|
332 | /******************** |
|
326 | [Test Interface] |
|
333 | [Test Interface] |
|
327 | ********************/ |
|
334 | ********************/ |
|
328 |
|
335 | ||
|
329 | div.test-desc { |
|
336 | div.test-desc { |
|
330 | border: 1px dotted gray; |
|
337 | border: 1px dotted gray; |
|
331 | background: #f5f5f5; |
|
338 | background: #f5f5f5; |
|
332 | padding: 5px; |
|
339 | padding: 5px; |
|
333 | margin: 10px 0; |
|
340 | margin: 10px 0; |
|
334 | font-size: 12px; |
|
341 | font-size: 12px; |
|
335 | line-height: 1.5em; |
|
342 | line-height: 1.5em; |
|
336 | } |
|
343 | } |
You need to be logged in to leave comments.
Login now