Description:
reorder submission and remove duplicate code for submission
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r644:6431e2ef4265 - - 7 files changed: 8 inserted, 55 deleted
@@ -1,393 +1,376 | |||||
|
1 | class MainController < ApplicationController |
|
1 | class MainController < ApplicationController |
|
2 |
|
2 | ||
|
3 | before_filter :authenticate, :except => [:index, :login] |
|
3 | before_filter :authenticate, :except => [:index, :login] |
|
4 | before_filter :check_viewability, :except => [:index, :login] |
|
4 | before_filter :check_viewability, :except => [:index, :login] |
|
5 |
|
5 | ||
|
6 | append_before_filter :confirm_and_update_start_time, |
|
6 | append_before_filter :confirm_and_update_start_time, |
|
7 | :except => [:index, |
|
7 | :except => [:index, |
|
8 | :login, |
|
8 | :login, |
|
9 | :confirm_contest_start] |
|
9 | :confirm_contest_start] |
|
10 |
|
10 | ||
|
11 | # to prevent log in box to be shown when user logged out of the |
|
11 | # to prevent log in box to be shown when user logged out of the |
|
12 | # system only in some tab |
|
12 | # system only in some tab |
|
13 | prepend_before_filter :reject_announcement_refresh_when_logged_out, |
|
13 | prepend_before_filter :reject_announcement_refresh_when_logged_out, |
|
14 | :only => [:announcements] |
|
14 | :only => [:announcements] |
|
15 |
|
15 | ||
|
16 | before_filter :authenticate_by_ip_address, :only => [:list] |
|
16 | before_filter :authenticate_by_ip_address, :only => [:list] |
|
17 |
|
17 | ||
|
18 | # COMMENTED OUT: filter in each action instead |
|
18 | # COMMENTED OUT: filter in each action instead |
|
19 | # before_filter :verify_time_limit, :only => [:submit] |
|
19 | # before_filter :verify_time_limit, :only => [:submit] |
|
20 |
|
20 | ||
|
21 | verify :method => :post, :only => [:submit], |
|
21 | verify :method => :post, :only => [:submit], |
|
22 | :redirect_to => { :action => :index } |
|
22 | :redirect_to => { :action => :index } |
|
23 |
|
23 | ||
|
24 | # COMMENT OUT: only need when having high load |
|
24 | # COMMENT OUT: only need when having high load |
|
25 | # caches_action :index, :login |
|
25 | # caches_action :index, :login |
|
26 |
|
26 | ||
|
27 | # NOTE: This method is not actually needed, 'config/routes.rb' has |
|
27 | # NOTE: This method is not actually needed, 'config/routes.rb' has |
|
28 | # assigned action login as a default action. |
|
28 | # assigned action login as a default action. |
|
29 | def index |
|
29 | def index |
|
30 | redirect_to :action => 'login' |
|
30 | redirect_to :action => 'login' |
|
31 | end |
|
31 | end |
|
32 |
|
32 | ||
|
33 | def login |
|
33 | def login |
|
34 | saved_notice = flash[:notice] |
|
34 | saved_notice = flash[:notice] |
|
35 | reset_session |
|
35 | reset_session |
|
36 | flash.now[:notice] = saved_notice |
|
36 | flash.now[:notice] = saved_notice |
|
37 |
|
37 | ||
|
38 | # EXPERIMENT: |
|
38 | # EXPERIMENT: |
|
39 | # Hide login if in single user mode and the url does not |
|
39 | # Hide login if in single user mode and the url does not |
|
40 | # explicitly specify /login |
|
40 | # explicitly specify /login |
|
41 | # |
|
41 | # |
|
42 | # logger.info "PATH: #{request.path}" |
|
42 | # logger.info "PATH: #{request.path}" |
|
43 | # if GraderConfiguration['system.single_user_mode'] and |
|
43 | # if GraderConfiguration['system.single_user_mode'] and |
|
44 | # request.path!='/main/login' |
|
44 | # request.path!='/main/login' |
|
45 | # @hidelogin = true |
|
45 | # @hidelogin = true |
|
46 | # end |
|
46 | # end |
|
47 |
|
47 | ||
|
48 | @announcements = Announcement.frontpage |
|
48 | @announcements = Announcement.frontpage |
|
49 | render :action => 'login', :layout => 'empty' |
|
49 | render :action => 'login', :layout => 'empty' |
|
50 | end |
|
50 | end |
|
51 |
|
51 | ||
|
52 | def list |
|
52 | def list |
|
53 | prepare_list_information |
|
53 | prepare_list_information |
|
54 | end |
|
54 | end |
|
55 |
|
55 | ||
|
56 | def help |
|
56 | def help |
|
57 | @user = User.find(session[:user_id]) |
|
57 | @user = User.find(session[:user_id]) |
|
58 | end |
|
58 | end |
|
59 |
|
59 | ||
|
60 | def submit |
|
60 | def submit |
|
61 | user = User.find(session[:user_id]) |
|
61 | user = User.find(session[:user_id]) |
|
62 |
|
62 | ||
|
63 | @submission = Submission.new |
|
63 | @submission = Submission.new |
|
64 | @submission.problem_id = params[:submission][:problem_id] |
|
64 | @submission.problem_id = params[:submission][:problem_id] |
|
65 | @submission.user = user |
|
65 | @submission.user = user |
|
66 | @submission.language_id = 0 |
|
66 | @submission.language_id = 0 |
|
67 | if (params['file']) and (params['file']!='') |
|
67 | if (params['file']) and (params['file']!='') |
|
68 | @submission.source = File.open(params['file'].path,'r:UTF-8',&:read) |
|
68 | @submission.source = File.open(params['file'].path,'r:UTF-8',&:read) |
|
69 | @submission.source.encode!('UTF-8','UTF-8',invalid: :replace, replace: '') |
|
69 | @submission.source.encode!('UTF-8','UTF-8',invalid: :replace, replace: '') |
|
70 | @submission.source_filename = params['file'].original_filename |
|
70 | @submission.source_filename = params['file'].original_filename |
|
71 | end |
|
71 | end |
|
72 |
|
72 | ||
|
73 | if (params[:editor_text]) |
|
73 | if (params[:editor_text]) |
|
74 | language = Language.find_by_id(params[:language_id]) |
|
74 | language = Language.find_by_id(params[:language_id]) |
|
75 | @submission.source = params[:editor_text] |
|
75 | @submission.source = params[:editor_text] |
|
76 | @submission.source_filename = "live_edit.#{language.ext}" |
|
76 | @submission.source_filename = "live_edit.#{language.ext}" |
|
77 | @submission.language = language |
|
77 | @submission.language = language |
|
78 | end |
|
78 | end |
|
79 |
|
79 | ||
|
80 | @submission.submitted_at = Time.new.gmtime |
|
80 | @submission.submitted_at = Time.new.gmtime |
|
81 | @submission.ip_address = request.remote_ip |
|
81 | @submission.ip_address = request.remote_ip |
|
82 |
|
82 | ||
|
83 | if GraderConfiguration.time_limit_mode? and user.contest_finished? |
|
83 | if GraderConfiguration.time_limit_mode? and user.contest_finished? |
|
84 | @submission.errors.add(:base,"The contest is over.") |
|
84 | @submission.errors.add(:base,"The contest is over.") |
|
85 | prepare_list_information |
|
85 | prepare_list_information |
|
86 | render :action => 'list' and return |
|
86 | render :action => 'list' and return |
|
87 | end |
|
87 | end |
|
88 |
|
88 | ||
|
89 | if @submission.valid? |
|
89 | if @submission.valid? |
|
90 | if @submission.save == false |
|
90 | if @submission.save == false |
|
91 | flash[:notice] = 'Error saving your submission' |
|
91 | flash[:notice] = 'Error saving your submission' |
|
92 | elsif Task.create(:submission_id => @submission.id, |
|
92 | elsif Task.create(:submission_id => @submission.id, |
|
93 | :status => Task::STATUS_INQUEUE) == false |
|
93 | :status => Task::STATUS_INQUEUE) == false |
|
94 | flash[:notice] = 'Error adding your submission to task queue' |
|
94 | flash[:notice] = 'Error adding your submission to task queue' |
|
95 | end |
|
95 | end |
|
96 | else |
|
96 | else |
|
97 | prepare_list_information |
|
97 | prepare_list_information |
|
98 | render :action => 'list' and return |
|
98 | render :action => 'list' and return |
|
99 | end |
|
99 | end |
|
100 | redirect_to :action => 'list' |
|
100 | redirect_to :action => 'list' |
|
101 | end |
|
101 | end |
|
102 |
|
102 | ||
|
103 | def source |
|
103 | def source |
|
104 | submission = Submission.find(params[:id]) |
|
104 | submission = Submission.find(params[:id]) |
|
105 | if ((submission.user_id == session[:user_id]) and |
|
105 | if ((submission.user_id == session[:user_id]) and |
|
106 | (submission.problem != nil) and |
|
106 | (submission.problem != nil) and |
|
107 | (submission.problem.available)) |
|
107 | (submission.problem.available)) |
|
108 | send_data(submission.source, |
|
108 | send_data(submission.source, |
|
109 | {:filename => submission.download_filename, |
|
109 | {:filename => submission.download_filename, |
|
110 | :type => 'text/plain'}) |
|
110 | :type => 'text/plain'}) |
|
111 | else |
|
111 | else |
|
112 | flash[:notice] = 'Error viewing source' |
|
112 | flash[:notice] = 'Error viewing source' |
|
113 | redirect_to :action => 'list' |
|
113 | redirect_to :action => 'list' |
|
114 | end |
|
114 | end |
|
115 | end |
|
115 | end |
|
116 |
|
116 | ||
|
117 | def compiler_msg |
|
117 | def compiler_msg |
|
118 | @submission = Submission.find(params[:id]) |
|
118 | @submission = Submission.find(params[:id]) |
|
119 | if @submission.user_id == session[:user_id] |
|
119 | if @submission.user_id == session[:user_id] |
|
120 | render :action => 'compiler_msg', :layout => 'empty' |
|
120 | render :action => 'compiler_msg', :layout => 'empty' |
|
121 | else |
|
121 | else |
|
122 | flash[:notice] = 'Error viewing source' |
|
122 | flash[:notice] = 'Error viewing source' |
|
123 | redirect_to :action => 'list' |
|
123 | redirect_to :action => 'list' |
|
124 | end |
|
124 | end |
|
125 | end |
|
125 | end |
|
126 |
|
126 | ||
|
127 | - def submission |
|
||
|
128 | - @user = User.find(session[:user_id]) |
|
||
|
129 | - @problems = @user.available_problems |
|
||
|
130 | - if params[:id]==nil |
|
||
|
131 | - @problem = nil |
|
||
|
132 | - @submissions = nil |
|
||
|
133 | - else |
|
||
|
134 | - @problem = Problem.find_by_id(params[:id]) |
|
||
|
135 | - if (@problem == nil) or (not @problem.available) |
|
||
|
136 | - redirect_to :action => 'list' |
|
||
|
137 | - flash[:notice] = 'Error: submissions for that problem are not viewable.' |
|
||
|
138 | - return |
|
||
|
139 | - end |
|
||
|
140 | - @submissions = Submission.find_all_by_user_problem(@user.id, @problem.id) |
|
||
|
141 | - end |
|
||
|
142 | - end |
|
||
|
143 | - |
|
||
|
144 | def result |
|
127 | def result |
|
145 | if !GraderConfiguration.show_grading_result |
|
128 | if !GraderConfiguration.show_grading_result |
|
146 | redirect_to :action => 'list' and return |
|
129 | redirect_to :action => 'list' and return |
|
147 | end |
|
130 | end |
|
148 | @user = User.find(session[:user_id]) |
|
131 | @user = User.find(session[:user_id]) |
|
149 | @submission = Submission.find(params[:id]) |
|
132 | @submission = Submission.find(params[:id]) |
|
150 | if @submission.user!=@user |
|
133 | if @submission.user!=@user |
|
151 | flash[:notice] = 'You are not allowed to view result of other users.' |
|
134 | flash[:notice] = 'You are not allowed to view result of other users.' |
|
152 | redirect_to :action => 'list' and return |
|
135 | redirect_to :action => 'list' and return |
|
153 | end |
|
136 | end |
|
154 | prepare_grading_result(@submission) |
|
137 | prepare_grading_result(@submission) |
|
155 | end |
|
138 | end |
|
156 |
|
139 | ||
|
157 | def load_output |
|
140 | def load_output |
|
158 | if !GraderConfiguration.show_grading_result or params[:num]==nil |
|
141 | if !GraderConfiguration.show_grading_result or params[:num]==nil |
|
159 | redirect_to :action => 'list' and return |
|
142 | redirect_to :action => 'list' and return |
|
160 | end |
|
143 | end |
|
161 | @user = User.find(session[:user_id]) |
|
144 | @user = User.find(session[:user_id]) |
|
162 | @submission = Submission.find(params[:id]) |
|
145 | @submission = Submission.find(params[:id]) |
|
163 | if @submission.user!=@user |
|
146 | if @submission.user!=@user |
|
164 | flash[:notice] = 'You are not allowed to view result of other users.' |
|
147 | flash[:notice] = 'You are not allowed to view result of other users.' |
|
165 | redirect_to :action => 'list' and return |
|
148 | redirect_to :action => 'list' and return |
|
166 | end |
|
149 | end |
|
167 | case_num = params[:num].to_i |
|
150 | case_num = params[:num].to_i |
|
168 | out_filename = output_filename(@user.login, |
|
151 | out_filename = output_filename(@user.login, |
|
169 | @submission.problem.name, |
|
152 | @submission.problem.name, |
|
170 | @submission.id, |
|
153 | @submission.id, |
|
171 | case_num) |
|
154 | case_num) |
|
172 | if !FileTest.exists?(out_filename) |
|
155 | if !FileTest.exists?(out_filename) |
|
173 | flash[:notice] = 'Output not found.' |
|
156 | flash[:notice] = 'Output not found.' |
|
174 | redirect_to :action => 'list' and return |
|
157 | redirect_to :action => 'list' and return |
|
175 | end |
|
158 | end |
|
176 |
|
159 | ||
|
177 | if defined?(USE_APACHE_XSENDFILE) and USE_APACHE_XSENDFILE |
|
160 | if defined?(USE_APACHE_XSENDFILE) and USE_APACHE_XSENDFILE |
|
178 | response.headers['Content-Type'] = "application/force-download" |
|
161 | response.headers['Content-Type'] = "application/force-download" |
|
179 | response.headers['Content-Disposition'] = "attachment; filename=\"output-#{case_num}.txt\"" |
|
162 | response.headers['Content-Disposition'] = "attachment; filename=\"output-#{case_num}.txt\"" |
|
180 | response.headers["X-Sendfile"] = out_filename |
|
163 | response.headers["X-Sendfile"] = out_filename |
|
181 | response.headers['Content-length'] = File.size(out_filename) |
|
164 | response.headers['Content-length'] = File.size(out_filename) |
|
182 | render :nothing => true |
|
165 | render :nothing => true |
|
183 | else |
|
166 | else |
|
184 | send_file out_filename, :stream => false, :filename => "output-#{case_num}.txt", :type => "text/plain" |
|
167 | send_file out_filename, :stream => false, :filename => "output-#{case_num}.txt", :type => "text/plain" |
|
185 | end |
|
168 | end |
|
186 | end |
|
169 | end |
|
187 |
|
170 | ||
|
188 | def error |
|
171 | def error |
|
189 | @user = User.find(session[:user_id]) |
|
172 | @user = User.find(session[:user_id]) |
|
190 | end |
|
173 | end |
|
191 |
|
174 | ||
|
192 | # announcement refreshing and hiding methods |
|
175 | # announcement refreshing and hiding methods |
|
193 |
|
176 | ||
|
194 | def announcements |
|
177 | def announcements |
|
195 | if params.has_key? 'recent' |
|
178 | if params.has_key? 'recent' |
|
196 | prepare_announcements(params[:recent]) |
|
179 | prepare_announcements(params[:recent]) |
|
197 | else |
|
180 | else |
|
198 | prepare_announcements |
|
181 | prepare_announcements |
|
199 | end |
|
182 | end |
|
200 | render(:partial => 'announcement', |
|
183 | render(:partial => 'announcement', |
|
201 | :collection => @announcements, |
|
184 | :collection => @announcements, |
|
202 | :locals => {:announcement_effect => true}) |
|
185 | :locals => {:announcement_effect => true}) |
|
203 | end |
|
186 | end |
|
204 |
|
187 | ||
|
205 | def confirm_contest_start |
|
188 | def confirm_contest_start |
|
206 | user = User.find(session[:user_id]) |
|
189 | user = User.find(session[:user_id]) |
|
207 | if request.method == 'POST' |
|
190 | if request.method == 'POST' |
|
208 | user.update_start_time |
|
191 | user.update_start_time |
|
209 | redirect_to :action => 'list' |
|
192 | redirect_to :action => 'list' |
|
210 | else |
|
193 | else |
|
211 | @contests = user.contests |
|
194 | @contests = user.contests |
|
212 | @user = user |
|
195 | @user = user |
|
213 | end |
|
196 | end |
|
214 | end |
|
197 | end |
|
215 |
|
198 | ||
|
216 | protected |
|
199 | protected |
|
217 |
|
200 | ||
|
218 | def prepare_announcements(recent=nil) |
|
201 | def prepare_announcements(recent=nil) |
|
219 | if GraderConfiguration.show_tasks_to?(@user) |
|
202 | if GraderConfiguration.show_tasks_to?(@user) |
|
220 | @announcements = Announcement.published(true) |
|
203 | @announcements = Announcement.published(true) |
|
221 | else |
|
204 | else |
|
222 | @announcements = Announcement.published |
|
205 | @announcements = Announcement.published |
|
223 | end |
|
206 | end |
|
224 | if recent!=nil |
|
207 | if recent!=nil |
|
225 | recent_id = recent.to_i |
|
208 | recent_id = recent.to_i |
|
226 | @announcements = @announcements.find_all { |a| a.id > recent_id } |
|
209 | @announcements = @announcements.find_all { |a| a.id > recent_id } |
|
227 | end |
|
210 | end |
|
228 | end |
|
211 | end |
|
229 |
|
212 | ||
|
230 | def prepare_list_information |
|
213 | def prepare_list_information |
|
231 | @user = User.find(session[:user_id]) |
|
214 | @user = User.find(session[:user_id]) |
|
232 | if not GraderConfiguration.multicontests? |
|
215 | if not GraderConfiguration.multicontests? |
|
233 | @problems = @user.available_problems |
|
216 | @problems = @user.available_problems |
|
234 | else |
|
217 | else |
|
235 | @contest_problems = @user.available_problems_group_by_contests |
|
218 | @contest_problems = @user.available_problems_group_by_contests |
|
236 | @problems = @user.available_problems |
|
219 | @problems = @user.available_problems |
|
237 | end |
|
220 | end |
|
238 | @prob_submissions = {} |
|
221 | @prob_submissions = {} |
|
239 | @problems.each do |p| |
|
222 | @problems.each do |p| |
|
240 | sub = Submission.find_last_by_user_and_problem(@user.id,p.id) |
|
223 | sub = Submission.find_last_by_user_and_problem(@user.id,p.id) |
|
241 | if sub!=nil |
|
224 | if sub!=nil |
|
242 | @prob_submissions[p.id] = { :count => sub.number, :submission => sub } |
|
225 | @prob_submissions[p.id] = { :count => sub.number, :submission => sub } |
|
243 | else |
|
226 | else |
|
244 | @prob_submissions[p.id] = { :count => 0, :submission => nil } |
|
227 | @prob_submissions[p.id] = { :count => 0, :submission => nil } |
|
245 | end |
|
228 | end |
|
246 | end |
|
229 | end |
|
247 | prepare_announcements |
|
230 | prepare_announcements |
|
248 | end |
|
231 | end |
|
249 |
|
232 | ||
|
250 | def check_viewability |
|
233 | def check_viewability |
|
251 | @user = User.find(session[:user_id]) |
|
234 | @user = User.find(session[:user_id]) |
|
252 | if (!GraderConfiguration.show_tasks_to?(@user)) and |
|
235 | if (!GraderConfiguration.show_tasks_to?(@user)) and |
|
253 | ((action_name=='submission') or (action_name=='submit')) |
|
236 | ((action_name=='submission') or (action_name=='submit')) |
|
254 | redirect_to :action => 'list' and return |
|
237 | redirect_to :action => 'list' and return |
|
255 | end |
|
238 | end |
|
256 | end |
|
239 | end |
|
257 |
|
240 | ||
|
258 | def prepare_grading_result(submission) |
|
241 | def prepare_grading_result(submission) |
|
259 | if GraderConfiguration.task_grading_info.has_key? submission.problem.name |
|
242 | if GraderConfiguration.task_grading_info.has_key? submission.problem.name |
|
260 | grading_info = GraderConfiguration.task_grading_info[submission.problem.name] |
|
243 | grading_info = GraderConfiguration.task_grading_info[submission.problem.name] |
|
261 | else |
|
244 | else |
|
262 | # guess task info from problem.full_score |
|
245 | # guess task info from problem.full_score |
|
263 | cases = submission.problem.full_score / 10 |
|
246 | cases = submission.problem.full_score / 10 |
|
264 | grading_info = { |
|
247 | grading_info = { |
|
265 | 'testruns' => cases, |
|
248 | 'testruns' => cases, |
|
266 | 'testcases' => cases |
|
249 | 'testcases' => cases |
|
267 | } |
|
250 | } |
|
268 | end |
|
251 | end |
|
269 | @test_runs = [] |
|
252 | @test_runs = [] |
|
270 | if grading_info['testruns'].is_a? Integer |
|
253 | if grading_info['testruns'].is_a? Integer |
|
271 | trun_count = grading_info['testruns'] |
|
254 | trun_count = grading_info['testruns'] |
|
272 | trun_count.times do |i| |
|
255 | trun_count.times do |i| |
|
273 | @test_runs << [ read_grading_result(@user.login, |
|
256 | @test_runs << [ read_grading_result(@user.login, |
|
274 | submission.problem.name, |
|
257 | submission.problem.name, |
|
275 | submission.id, |
|
258 | submission.id, |
|
276 | i+1) ] |
|
259 | i+1) ] |
|
277 | end |
|
260 | end |
|
278 | else |
|
261 | else |
|
279 | grading_info['testruns'].keys.sort.each do |num| |
|
262 | grading_info['testruns'].keys.sort.each do |num| |
|
280 | run = [] |
|
263 | run = [] |
|
281 | testrun = grading_info['testruns'][num] |
|
264 | testrun = grading_info['testruns'][num] |
|
282 | testrun.each do |c| |
|
265 | testrun.each do |c| |
|
283 | run << read_grading_result(@user.login, |
|
266 | run << read_grading_result(@user.login, |
|
284 | submission.problem.name, |
|
267 | submission.problem.name, |
|
285 | submission.id, |
|
268 | submission.id, |
|
286 | c) |
|
269 | c) |
|
287 | end |
|
270 | end |
|
288 | @test_runs << run |
|
271 | @test_runs << run |
|
289 | end |
|
272 | end |
|
290 | end |
|
273 | end |
|
291 | end |
|
274 | end |
|
292 |
|
275 | ||
|
293 | def grading_result_dir(user_name, problem_name, submission_id, case_num) |
|
276 | def grading_result_dir(user_name, problem_name, submission_id, case_num) |
|
294 | return "#{GRADING_RESULT_DIR}/#{user_name}/#{problem_name}/#{submission_id}/test-result/#{case_num}" |
|
277 | return "#{GRADING_RESULT_DIR}/#{user_name}/#{problem_name}/#{submission_id}/test-result/#{case_num}" |
|
295 | end |
|
278 | end |
|
296 |
|
279 | ||
|
297 | def output_filename(user_name, problem_name, submission_id, case_num) |
|
280 | def output_filename(user_name, problem_name, submission_id, case_num) |
|
298 | dir = grading_result_dir(user_name,problem_name, submission_id, case_num) |
|
281 | dir = grading_result_dir(user_name,problem_name, submission_id, case_num) |
|
299 | return "#{dir}/output.txt" |
|
282 | return "#{dir}/output.txt" |
|
300 | end |
|
283 | end |
|
301 |
|
284 | ||
|
302 | def read_grading_result(user_name, problem_name, submission_id, case_num) |
|
285 | def read_grading_result(user_name, problem_name, submission_id, case_num) |
|
303 | dir = grading_result_dir(user_name,problem_name, submission_id, case_num) |
|
286 | dir = grading_result_dir(user_name,problem_name, submission_id, case_num) |
|
304 | result_file_name = "#{dir}/result" |
|
287 | result_file_name = "#{dir}/result" |
|
305 | if !FileTest.exists?(result_file_name) |
|
288 | if !FileTest.exists?(result_file_name) |
|
306 | return {:num => case_num, :msg => 'program did not run'} |
|
289 | return {:num => case_num, :msg => 'program did not run'} |
|
307 | else |
|
290 | else |
|
308 | results = File.open(result_file_name).readlines |
|
291 | results = File.open(result_file_name).readlines |
|
309 | run_stat = extract_running_stat(results) |
|
292 | run_stat = extract_running_stat(results) |
|
310 | output_filename = "#{dir}/output.txt" |
|
293 | output_filename = "#{dir}/output.txt" |
|
311 | if FileTest.exists?(output_filename) |
|
294 | if FileTest.exists?(output_filename) |
|
312 | output_file = true |
|
295 | output_file = true |
|
313 | output_size = File.size(output_filename) |
|
296 | output_size = File.size(output_filename) |
|
314 | else |
|
297 | else |
|
315 | output_file = false |
|
298 | output_file = false |
|
316 | output_size = 0 |
|
299 | output_size = 0 |
|
317 | end |
|
300 | end |
|
318 |
|
301 | ||
|
319 | return { |
|
302 | return { |
|
320 | :num => case_num, |
|
303 | :num => case_num, |
|
321 | :msg => results[0], |
|
304 | :msg => results[0], |
|
322 | :run_stat => run_stat, |
|
305 | :run_stat => run_stat, |
|
323 | :output => output_file, |
|
306 | :output => output_file, |
|
324 | :output_size => output_size |
|
307 | :output_size => output_size |
|
325 | } |
|
308 | } |
|
326 | end |
|
309 | end |
|
327 | end |
|
310 | end |
|
328 |
|
311 | ||
|
329 | # copied from grader/script/lib/test_request_helper.rb |
|
312 | # copied from grader/script/lib/test_request_helper.rb |
|
330 | def extract_running_stat(results) |
|
313 | def extract_running_stat(results) |
|
331 | running_stat_line = results[-1] |
|
314 | running_stat_line = results[-1] |
|
332 |
|
315 | ||
|
333 | # extract exit status line |
|
316 | # extract exit status line |
|
334 | run_stat = "" |
|
317 | run_stat = "" |
|
335 | if !(/[Cc]orrect/.match(results[0])) |
|
318 | if !(/[Cc]orrect/.match(results[0])) |
|
336 | run_stat = results[0].chomp |
|
319 | run_stat = results[0].chomp |
|
337 | else |
|
320 | else |
|
338 | run_stat = 'Program exited normally' |
|
321 | run_stat = 'Program exited normally' |
|
339 | end |
|
322 | end |
|
340 |
|
323 | ||
|
341 | logger.info "Stat line: #{running_stat_line}" |
|
324 | logger.info "Stat line: #{running_stat_line}" |
|
342 |
|
325 | ||
|
343 | # extract running time |
|
326 | # extract running time |
|
344 | if res = /r(.*)u(.*)s/.match(running_stat_line) |
|
327 | if res = /r(.*)u(.*)s/.match(running_stat_line) |
|
345 | seconds = (res[1].to_f + res[2].to_f) |
|
328 | seconds = (res[1].to_f + res[2].to_f) |
|
346 | time_stat = "Time used: #{seconds} sec." |
|
329 | time_stat = "Time used: #{seconds} sec." |
|
347 | else |
|
330 | else |
|
348 | seconds = nil |
|
331 | seconds = nil |
|
349 | time_stat = "Time used: n/a sec." |
|
332 | time_stat = "Time used: n/a sec." |
|
350 | end |
|
333 | end |
|
351 |
|
334 | ||
|
352 | # extract memory usage |
|
335 | # extract memory usage |
|
353 | if res = /s(.*)m/.match(running_stat_line) |
|
336 | if res = /s(.*)m/.match(running_stat_line) |
|
354 | memory_used = res[1].to_i |
|
337 | memory_used = res[1].to_i |
|
355 | else |
|
338 | else |
|
356 | memory_used = -1 |
|
339 | memory_used = -1 |
|
357 | end |
|
340 | end |
|
358 |
|
341 | ||
|
359 | return { |
|
342 | return { |
|
360 | :msg => "#{run_stat}\n#{time_stat}", |
|
343 | :msg => "#{run_stat}\n#{time_stat}", |
|
361 | :running_time => seconds, |
|
344 | :running_time => seconds, |
|
362 | :exit_status => run_stat, |
|
345 | :exit_status => run_stat, |
|
363 | :memory_usage => memory_used |
|
346 | :memory_usage => memory_used |
|
364 | } |
|
347 | } |
|
365 | end |
|
348 | end |
|
366 |
|
349 | ||
|
367 | def confirm_and_update_start_time |
|
350 | def confirm_and_update_start_time |
|
368 | user = User.find(session[:user_id]) |
|
351 | user = User.find(session[:user_id]) |
|
369 | if (GraderConfiguration.indv_contest_mode? and |
|
352 | if (GraderConfiguration.indv_contest_mode? and |
|
370 | GraderConfiguration['contest.confirm_indv_contest_start'] and |
|
353 | GraderConfiguration['contest.confirm_indv_contest_start'] and |
|
371 | !user.contest_started?) |
|
354 | !user.contest_started?) |
|
372 | redirect_to :action => 'confirm_contest_start' and return |
|
355 | redirect_to :action => 'confirm_contest_start' and return |
|
373 | end |
|
356 | end |
|
374 | if not GraderConfiguration.analysis_mode? |
|
357 | if not GraderConfiguration.analysis_mode? |
|
375 | user.update_start_time |
|
358 | user.update_start_time |
|
376 | end |
|
359 | end |
|
377 | end |
|
360 | end |
|
378 |
|
361 | ||
|
379 | def reject_announcement_refresh_when_logged_out |
|
362 | def reject_announcement_refresh_when_logged_out |
|
380 | if not session[:user_id] |
|
363 | if not session[:user_id] |
|
381 | render :text => 'Access forbidden', :status => 403 |
|
364 | render :text => 'Access forbidden', :status => 403 |
|
382 | end |
|
365 | end |
|
383 |
|
366 | ||
|
384 | if GraderConfiguration.multicontests? |
|
367 | if GraderConfiguration.multicontests? |
|
385 | user = User.find(session[:user_id]) |
|
368 | user = User.find(session[:user_id]) |
|
386 | if user.contest_stat.forced_logout |
|
369 | if user.contest_stat.forced_logout |
|
387 | render :text => 'Access forbidden', :status => 403 |
|
370 | render :text => 'Access forbidden', :status => 403 |
|
388 | end |
|
371 | end |
|
389 | end |
|
372 | end |
|
390 | end |
|
373 | end |
|
391 |
|
374 | ||
|
392 | end |
|
375 | end |
|
393 |
|
376 |
@@ -1,96 +1,96 | |||||
|
1 | class SubmissionsController < ApplicationController |
|
1 | class SubmissionsController < ApplicationController |
|
2 | before_filter :authenticate |
|
2 | before_filter :authenticate |
|
3 | before_filter :submission_authorization, only: [:show, :direct_edit_submission, :download, :edit] |
|
3 | before_filter :submission_authorization, only: [:show, :direct_edit_submission, :download, :edit] |
|
4 |
|
4 | ||
|
5 | # GET /submissions |
|
5 | # GET /submissions |
|
6 | # GET /submissions.json |
|
6 | # GET /submissions.json |
|
7 | # Show problem selection and user's submission of that problem |
|
7 | # Show problem selection and user's submission of that problem |
|
8 | def index |
|
8 | def index |
|
9 | @user = @current_user |
|
9 | @user = @current_user |
|
10 | @problems = @user.available_problems |
|
10 | @problems = @user.available_problems |
|
11 |
|
11 | ||
|
12 | if params[:problem_id]==nil |
|
12 | if params[:problem_id]==nil |
|
13 | @problem = nil |
|
13 | @problem = nil |
|
14 | @submissions = nil |
|
14 | @submissions = nil |
|
15 | else |
|
15 | else |
|
16 | @problem = Problem.find_by_id(params[:problem_id]) |
|
16 | @problem = Problem.find_by_id(params[:problem_id]) |
|
17 | if (@problem == nil) or (not @problem.available) |
|
17 | if (@problem == nil) or (not @problem.available) |
|
18 | redirect_to main_list_path |
|
18 | redirect_to main_list_path |
|
19 | flash[:notice] = 'Error: submissions for that problem are not viewable.' |
|
19 | flash[:notice] = 'Error: submissions for that problem are not viewable.' |
|
20 | return |
|
20 | return |
|
21 | end |
|
21 | end |
|
22 | - @submissions = Submission.find_all_by_user_problem(@user.id, @problem.id) |
|
22 | + @submissions = Submission.find_all_by_user_problem(@user.id, @problem.id).order(id: :desc) |
|
23 | end |
|
23 | end |
|
24 | end |
|
24 | end |
|
25 |
|
25 | ||
|
26 | # GET /submissions/1 |
|
26 | # GET /submissions/1 |
|
27 | # GET /submissions/1.json |
|
27 | # GET /submissions/1.json |
|
28 | def show |
|
28 | def show |
|
29 | @submission = Submission.find(params[:id]) |
|
29 | @submission = Submission.find(params[:id]) |
|
30 |
|
30 | ||
|
31 | #log the viewing |
|
31 | #log the viewing |
|
32 | user = User.find(session[:user_id]) |
|
32 | user = User.find(session[:user_id]) |
|
33 | SubmissionViewLog.create(user_id: session[:user_id],submission_id: @submission.id) unless user.admin? |
|
33 | SubmissionViewLog.create(user_id: session[:user_id],submission_id: @submission.id) unless user.admin? |
|
34 | end |
|
34 | end |
|
35 |
|
35 | ||
|
36 | def download |
|
36 | def download |
|
37 | @submission = Submission.find(params[:id]) |
|
37 | @submission = Submission.find(params[:id]) |
|
38 | send_data(@submission.source, {:filename => @submission.download_filename, :type => 'text/plain'}) |
|
38 | send_data(@submission.source, {:filename => @submission.download_filename, :type => 'text/plain'}) |
|
39 | end |
|
39 | end |
|
40 |
|
40 | ||
|
41 | def compiler_msg |
|
41 | def compiler_msg |
|
42 | @submission = Submission.find(params[:id]) |
|
42 | @submission = Submission.find(params[:id]) |
|
43 | respond_to do |format| |
|
43 | respond_to do |format| |
|
44 | format.js |
|
44 | format.js |
|
45 | end |
|
45 | end |
|
46 | end |
|
46 | end |
|
47 |
|
47 | ||
|
48 | #on-site new submission on specific problem |
|
48 | #on-site new submission on specific problem |
|
49 | def direct_edit_problem |
|
49 | def direct_edit_problem |
|
50 | @problem = Problem.find(params[:problem_id]) |
|
50 | @problem = Problem.find(params[:problem_id]) |
|
51 | @source = '' |
|
51 | @source = '' |
|
52 | render 'edit' |
|
52 | render 'edit' |
|
53 | end |
|
53 | end |
|
54 |
|
54 | ||
|
55 | # GET /submissions/1/edit |
|
55 | # GET /submissions/1/edit |
|
56 | def edit |
|
56 | def edit |
|
57 | @submission = Submission.find(params[:id]) |
|
57 | @submission = Submission.find(params[:id]) |
|
58 | @source = @submission.source.to_s |
|
58 | @source = @submission.source.to_s |
|
59 | @problem = @submission.problem |
|
59 | @problem = @submission.problem |
|
60 | @lang_id = @submission.language.id |
|
60 | @lang_id = @submission.language.id |
|
61 | end |
|
61 | end |
|
62 |
|
62 | ||
|
63 |
|
63 | ||
|
64 | def get_latest_submission_status |
|
64 | def get_latest_submission_status |
|
65 | @problem = Problem.find(params[:pid]) |
|
65 | @problem = Problem.find(params[:pid]) |
|
66 | @submission = Submission.find_last_by_user_and_problem(params[:uid],params[:pid]) |
|
66 | @submission = Submission.find_last_by_user_and_problem(params[:uid],params[:pid]) |
|
67 | puts User.find(params[:uid]).login |
|
67 | puts User.find(params[:uid]).login |
|
68 | puts Problem.find(params[:pid]).name |
|
68 | puts Problem.find(params[:pid]).name |
|
69 | puts 'nil' unless @submission |
|
69 | puts 'nil' unless @submission |
|
70 | respond_to do |format| |
|
70 | respond_to do |format| |
|
71 | format.js |
|
71 | format.js |
|
72 | end |
|
72 | end |
|
73 | end |
|
73 | end |
|
74 |
|
74 | ||
|
75 |
|
75 | ||
|
76 | protected |
|
76 | protected |
|
77 |
|
77 | ||
|
78 | def submission_authorization |
|
78 | def submission_authorization |
|
79 | #admin always has privileged |
|
79 | #admin always has privileged |
|
80 | if @current_user.admin? |
|
80 | if @current_user.admin? |
|
81 | return true |
|
81 | return true |
|
82 | end |
|
82 | end |
|
83 |
|
83 | ||
|
84 | sub = Submission.find(params[:id]) |
|
84 | sub = Submission.find(params[:id]) |
|
85 | if sub.problem.available? |
|
85 | if sub.problem.available? |
|
86 | puts "sub = #{sub.user.id}, current = #{@current_user.id}" |
|
86 | puts "sub = #{sub.user.id}, current = #{@current_user.id}" |
|
87 | return true if GraderConfiguration["right.user_view_submission"] or sub.user == @current_user |
|
87 | return true if GraderConfiguration["right.user_view_submission"] or sub.user == @current_user |
|
88 | end |
|
88 | end |
|
89 |
|
89 | ||
|
90 | #default to NO |
|
90 | #default to NO |
|
91 | unauthorized_redirect |
|
91 | unauthorized_redirect |
|
92 | return false |
|
92 | return false |
|
93 | end |
|
93 | end |
|
94 |
|
94 | ||
|
95 |
|
95 | ||
|
96 | end |
|
96 | end |
@@ -1,222 +1,222 | |||||
|
1 | # Methods added to this helper will be available to all templates in the application. |
|
1 | # Methods added to this helper will be available to all templates in the application. |
|
2 | module ApplicationHelper |
|
2 | module ApplicationHelper |
|
3 |
|
3 | ||
|
4 | #new bootstrap header |
|
4 | #new bootstrap header |
|
5 | def navbar_user_header |
|
5 | def navbar_user_header |
|
6 | left_menu = '' |
|
6 | left_menu = '' |
|
7 | right_menu = '' |
|
7 | right_menu = '' |
|
8 | user = User.find(session[:user_id]) |
|
8 | user = User.find(session[:user_id]) |
|
9 |
|
9 | ||
|
10 | if (user!=nil) and (GraderConfiguration.show_tasks_to?(user)) |
|
10 | if (user!=nil) and (GraderConfiguration.show_tasks_to?(user)) |
|
11 | left_menu << add_menu("#{I18n.t 'menu.tasks'}", 'tasks', 'list') |
|
11 | left_menu << add_menu("#{I18n.t 'menu.tasks'}", 'tasks', 'list') |
|
12 | left_menu << add_menu("#{I18n.t 'menu.submissions'}", 'main', 'submission') |
|
12 | left_menu << add_menu("#{I18n.t 'menu.submissions'}", 'main', 'submission') |
|
13 | left_menu << add_menu("#{I18n.t 'menu.test'}", 'test', 'index') |
|
13 | left_menu << add_menu("#{I18n.t 'menu.test'}", 'test', 'index') |
|
14 | end |
|
14 | end |
|
15 |
|
15 | ||
|
16 | if GraderConfiguration['right.user_hall_of_fame'] |
|
16 | if GraderConfiguration['right.user_hall_of_fame'] |
|
17 | left_menu << add_menu("#{I18n.t 'menu.hall_of_fame'}", 'report', 'problem_hof') |
|
17 | left_menu << add_menu("#{I18n.t 'menu.hall_of_fame'}", 'report', 'problem_hof') |
|
18 | end |
|
18 | end |
|
19 |
|
19 | ||
|
20 | right_menu << add_menu("#{content_tag(:span,'',class: 'glyphicon glyphicon-question-sign')}".html_safe, 'main', 'help') |
|
20 | right_menu << add_menu("#{content_tag(:span,'',class: 'glyphicon glyphicon-question-sign')}".html_safe, 'main', 'help') |
|
21 | right_menu << add_menu("#{content_tag(:span,'',class: 'glyphicon glyphicon-comment')}".html_safe, 'messages', 'list', {title: I18n.t('menu.messages'), data: {toggle: 'tooltip'}}) |
|
21 | right_menu << add_menu("#{content_tag(:span,'',class: 'glyphicon glyphicon-comment')}".html_safe, 'messages', 'list', {title: I18n.t('menu.messages'), data: {toggle: 'tooltip'}}) |
|
22 | if GraderConfiguration['system.user_setting_enabled'] |
|
22 | if GraderConfiguration['system.user_setting_enabled'] |
|
23 | right_menu << add_menu("#{content_tag(:span,'',class: 'glyphicon glyphicon-cog')}".html_safe, 'users', 'index', {title: I18n.t('menu.settings'), data: {toggle: 'tooltip'}}) |
|
23 | right_menu << add_menu("#{content_tag(:span,'',class: 'glyphicon glyphicon-cog')}".html_safe, 'users', 'index', {title: I18n.t('menu.settings'), data: {toggle: 'tooltip'}}) |
|
24 | end |
|
24 | end |
|
25 | right_menu << add_menu("#{content_tag(:span,'',class: 'glyphicon glyphicon-log-out')} #{user.full_name}".html_safe, 'main', 'login', {title: I18n.t('menu.log_out'), data: {toggle: 'tooltip'}}) |
|
25 | right_menu << add_menu("#{content_tag(:span,'',class: 'glyphicon glyphicon-log-out')} #{user.full_name}".html_safe, 'main', 'login', {title: I18n.t('menu.log_out'), data: {toggle: 'tooltip'}}) |
|
26 |
|
26 | ||
|
27 |
|
27 | ||
|
28 | result = content_tag(:ul,left_menu.html_safe,class: 'nav navbar-nav') + content_tag(:ul,right_menu.html_safe,class: 'nav navbar-nav navbar-right') |
|
28 | result = content_tag(:ul,left_menu.html_safe,class: 'nav navbar-nav') + content_tag(:ul,right_menu.html_safe,class: 'nav navbar-nav navbar-right') |
|
29 | end |
|
29 | end |
|
30 |
|
30 | ||
|
31 | - def add_menu(title, controller, action,html_option = {}) |
|
31 | + def add_menu(title, controller, action, html_option = {}) |
|
32 | link_option = {controller: controller, action: action} |
|
32 | link_option = {controller: controller, action: action} |
|
33 | html_option[:class] = (html_option[:class] || '') + " active" if current_page?(link_option) |
|
33 | html_option[:class] = (html_option[:class] || '') + " active" if current_page?(link_option) |
|
34 | content_tag(:li, link_to(title,link_option),html_option) |
|
34 | content_tag(:li, link_to(title,link_option),html_option) |
|
35 | end |
|
35 | end |
|
36 |
|
36 | ||
|
37 | def user_header |
|
37 | def user_header |
|
38 | menu_items = '' |
|
38 | menu_items = '' |
|
39 | user = User.find(session[:user_id]) |
|
39 | user = User.find(session[:user_id]) |
|
40 |
|
40 | ||
|
41 | if (user!=nil) and (session[:admin]) |
|
41 | if (user!=nil) and (session[:admin]) |
|
42 | # admin menu |
|
42 | # admin menu |
|
43 | menu_items << "<b>Administrative task:</b> " |
|
43 | menu_items << "<b>Administrative task:</b> " |
|
44 | append_to menu_items, '[Announcements]', 'announcements', 'index' |
|
44 | append_to menu_items, '[Announcements]', 'announcements', 'index' |
|
45 | append_to menu_items, '[Msg console]', 'messages', 'console' |
|
45 | append_to menu_items, '[Msg console]', 'messages', 'console' |
|
46 | append_to menu_items, '[Problems]', 'problems', 'index' |
|
46 | append_to menu_items, '[Problems]', 'problems', 'index' |
|
47 | append_to menu_items, '[Users]', 'user_admin', 'index' |
|
47 | append_to menu_items, '[Users]', 'user_admin', 'index' |
|
48 | append_to menu_items, '[Results]', 'user_admin', 'user_stat' |
|
48 | append_to menu_items, '[Results]', 'user_admin', 'user_stat' |
|
49 | append_to menu_items, '[Report]', 'report', 'multiple_login' |
|
49 | append_to menu_items, '[Report]', 'report', 'multiple_login' |
|
50 | append_to menu_items, '[Graders]', 'graders', 'list' |
|
50 | append_to menu_items, '[Graders]', 'graders', 'list' |
|
51 | append_to menu_items, '[Contests]', 'contest_management', 'index' |
|
51 | append_to menu_items, '[Contests]', 'contest_management', 'index' |
|
52 | append_to menu_items, '[Sites]', 'sites', 'index' |
|
52 | append_to menu_items, '[Sites]', 'sites', 'index' |
|
53 | append_to menu_items, '[System config]', 'configurations', 'index' |
|
53 | append_to menu_items, '[System config]', 'configurations', 'index' |
|
54 | menu_items << "<br/>" |
|
54 | menu_items << "<br/>" |
|
55 | end |
|
55 | end |
|
56 |
|
56 | ||
|
57 | # main page |
|
57 | # main page |
|
58 | append_to menu_items, "[#{I18n.t 'menu.main'}]", 'main', 'list' |
|
58 | append_to menu_items, "[#{I18n.t 'menu.main'}]", 'main', 'list' |
|
59 | append_to menu_items, "[#{I18n.t 'menu.messages'}]", 'messages', 'list' |
|
59 | append_to menu_items, "[#{I18n.t 'menu.messages'}]", 'messages', 'list' |
|
60 |
|
60 | ||
|
61 | if (user!=nil) and (GraderConfiguration.show_tasks_to?(user)) |
|
61 | if (user!=nil) and (GraderConfiguration.show_tasks_to?(user)) |
|
62 | append_to menu_items, "[#{I18n.t 'menu.tasks'}]", 'tasks', 'list' |
|
62 | append_to menu_items, "[#{I18n.t 'menu.tasks'}]", 'tasks', 'list' |
|
63 | append_to menu_items, "[#{I18n.t 'menu.submissions'}]", 'main', 'submission' |
|
63 | append_to menu_items, "[#{I18n.t 'menu.submissions'}]", 'main', 'submission' |
|
64 | append_to menu_items, "[#{I18n.t 'menu.test'}]", 'test', 'index' |
|
64 | append_to menu_items, "[#{I18n.t 'menu.test'}]", 'test', 'index' |
|
65 | end |
|
65 | end |
|
66 |
|
66 | ||
|
67 | if GraderConfiguration['right.user_hall_of_fame'] |
|
67 | if GraderConfiguration['right.user_hall_of_fame'] |
|
68 | append_to menu_items, "[#{I18n.t 'menu.hall_of_fame'}]", 'report', 'problem_hof' |
|
68 | append_to menu_items, "[#{I18n.t 'menu.hall_of_fame'}]", 'report', 'problem_hof' |
|
69 | end |
|
69 | end |
|
70 | append_to menu_items, "[#{I18n.t 'menu.help'}]", 'main', 'help' |
|
70 | append_to menu_items, "[#{I18n.t 'menu.help'}]", 'main', 'help' |
|
71 |
|
71 | ||
|
72 | if GraderConfiguration['system.user_setting_enabled'] |
|
72 | if GraderConfiguration['system.user_setting_enabled'] |
|
73 | append_to menu_items, "[#{I18n.t 'menu.settings'}]", 'users', 'index' |
|
73 | append_to menu_items, "[#{I18n.t 'menu.settings'}]", 'users', 'index' |
|
74 | end |
|
74 | end |
|
75 | append_to menu_items, "[#{I18n.t 'menu.log_out'}]", 'main', 'login' |
|
75 | append_to menu_items, "[#{I18n.t 'menu.log_out'}]", 'main', 'login' |
|
76 |
|
76 | ||
|
77 | menu_items.html_safe |
|
77 | menu_items.html_safe |
|
78 | end |
|
78 | end |
|
79 |
|
79 | ||
|
80 | def append_to(option,label, controller, action) |
|
80 | def append_to(option,label, controller, action) |
|
81 | option << ' ' if option!='' |
|
81 | option << ' ' if option!='' |
|
82 | option << link_to_unless_current(label, |
|
82 | option << link_to_unless_current(label, |
|
83 | :controller => controller, |
|
83 | :controller => controller, |
|
84 | :action => action) |
|
84 | :action => action) |
|
85 | end |
|
85 | end |
|
86 |
|
86 | ||
|
87 | def format_short_time(time) |
|
87 | def format_short_time(time) |
|
88 | now = Time.now.gmtime |
|
88 | now = Time.now.gmtime |
|
89 | st = '' |
|
89 | st = '' |
|
90 | if (time.yday != now.yday) or |
|
90 | if (time.yday != now.yday) or |
|
91 | (time.year != now.year) |
|
91 | (time.year != now.year) |
|
92 | st = time.strftime("%x ") |
|
92 | st = time.strftime("%x ") |
|
93 | end |
|
93 | end |
|
94 | st + time.strftime("%X") |
|
94 | st + time.strftime("%X") |
|
95 | end |
|
95 | end |
|
96 |
|
96 | ||
|
97 | def format_short_duration(duration) |
|
97 | def format_short_duration(duration) |
|
98 | return '' if duration==nil |
|
98 | return '' if duration==nil |
|
99 | d = duration.to_f |
|
99 | d = duration.to_f |
|
100 | return Time.at(d).gmtime.strftime("%X") |
|
100 | return Time.at(d).gmtime.strftime("%X") |
|
101 | end |
|
101 | end |
|
102 |
|
102 | ||
|
103 | def read_textfile(fname,max_size=2048) |
|
103 | def read_textfile(fname,max_size=2048) |
|
104 | begin |
|
104 | begin |
|
105 | File.open(fname).read(max_size) |
|
105 | File.open(fname).read(max_size) |
|
106 | rescue |
|
106 | rescue |
|
107 | nil |
|
107 | nil |
|
108 | end |
|
108 | end |
|
109 | end |
|
109 | end |
|
110 |
|
110 | ||
|
111 | def toggle_button(on,toggle_url,id, option={}) |
|
111 | def toggle_button(on,toggle_url,id, option={}) |
|
112 | btn_size = option[:size] || 'btn-xs' |
|
112 | btn_size = option[:size] || 'btn-xs' |
|
113 | link_to (on ? "Yes" : "No"), toggle_url, |
|
113 | link_to (on ? "Yes" : "No"), toggle_url, |
|
114 | {class: "btn btn-block #{btn_size} btn-#{on ? 'success' : 'default'} ajax-toggle", |
|
114 | {class: "btn btn-block #{btn_size} btn-#{on ? 'success' : 'default'} ajax-toggle", |
|
115 | id: id, |
|
115 | id: id, |
|
116 | data: {remote: true, method: 'get'}} |
|
116 | data: {remote: true, method: 'get'}} |
|
117 | end |
|
117 | end |
|
118 |
|
118 | ||
|
119 | def get_ace_mode(language) |
|
119 | def get_ace_mode(language) |
|
120 | # return ace mode string from Language |
|
120 | # return ace mode string from Language |
|
121 |
|
121 | ||
|
122 | case language.pretty_name |
|
122 | case language.pretty_name |
|
123 | when 'Pascal' |
|
123 | when 'Pascal' |
|
124 | 'ace/mode/pascal' |
|
124 | 'ace/mode/pascal' |
|
125 | when 'C++','C' |
|
125 | when 'C++','C' |
|
126 | 'ace/mode/c_cpp' |
|
126 | 'ace/mode/c_cpp' |
|
127 | when 'Ruby' |
|
127 | when 'Ruby' |
|
128 | 'ace/mode/ruby' |
|
128 | 'ace/mode/ruby' |
|
129 | when 'Python' |
|
129 | when 'Python' |
|
130 | 'ace/mode/python' |
|
130 | 'ace/mode/python' |
|
131 | when 'Java' |
|
131 | when 'Java' |
|
132 | 'ace/mode/java' |
|
132 | 'ace/mode/java' |
|
133 | else |
|
133 | else |
|
134 | 'ace/mode/c_cpp' |
|
134 | 'ace/mode/c_cpp' |
|
135 | end |
|
135 | end |
|
136 | end |
|
136 | end |
|
137 |
|
137 | ||
|
138 |
|
138 | ||
|
139 | def user_title_bar(user) |
|
139 | def user_title_bar(user) |
|
140 | header = '' |
|
140 | header = '' |
|
141 | time_left = '' |
|
141 | time_left = '' |
|
142 |
|
142 | ||
|
143 | # |
|
143 | # |
|
144 | # if the contest is over |
|
144 | # if the contest is over |
|
145 | if GraderConfiguration.time_limit_mode? |
|
145 | if GraderConfiguration.time_limit_mode? |
|
146 | if user.contest_finished? |
|
146 | if user.contest_finished? |
|
147 | header = <<CONTEST_OVER |
|
147 | header = <<CONTEST_OVER |
|
148 | <tr><td colspan="2" align="center"> |
|
148 | <tr><td colspan="2" align="center"> |
|
149 | <span class="contest-over-msg">THE CONTEST IS OVER</span> |
|
149 | <span class="contest-over-msg">THE CONTEST IS OVER</span> |
|
150 | </td></tr> |
|
150 | </td></tr> |
|
151 | CONTEST_OVER |
|
151 | CONTEST_OVER |
|
152 | end |
|
152 | end |
|
153 | if !user.contest_started? |
|
153 | if !user.contest_started? |
|
154 | time_left = " " + (t 'title_bar.contest_not_started') |
|
154 | time_left = " " + (t 'title_bar.contest_not_started') |
|
155 | else |
|
155 | else |
|
156 | time_left = " " + (t 'title_bar.remaining_time') + |
|
156 | time_left = " " + (t 'title_bar.remaining_time') + |
|
157 | " #{format_short_duration(user.contest_time_left)}" |
|
157 | " #{format_short_duration(user.contest_time_left)}" |
|
158 | end |
|
158 | end |
|
159 | end |
|
159 | end |
|
160 |
|
160 | ||
|
161 | # |
|
161 | # |
|
162 | # if the contest is in the anaysis mode |
|
162 | # if the contest is in the anaysis mode |
|
163 | if GraderConfiguration.analysis_mode? |
|
163 | if GraderConfiguration.analysis_mode? |
|
164 | header = <<ANALYSISMODE |
|
164 | header = <<ANALYSISMODE |
|
165 | <tr><td colspan="2" align="center"> |
|
165 | <tr><td colspan="2" align="center"> |
|
166 | <span class="contest-over-msg">ANALYSIS MODE</span> |
|
166 | <span class="contest-over-msg">ANALYSIS MODE</span> |
|
167 | </td></tr> |
|
167 | </td></tr> |
|
168 | ANALYSISMODE |
|
168 | ANALYSISMODE |
|
169 | end |
|
169 | end |
|
170 |
|
170 | ||
|
171 | contest_name = GraderConfiguration['contest.name'] |
|
171 | contest_name = GraderConfiguration['contest.name'] |
|
172 |
|
172 | ||
|
173 | # |
|
173 | # |
|
174 | # build real title bar |
|
174 | # build real title bar |
|
175 | result = <<TITLEBAR |
|
175 | result = <<TITLEBAR |
|
176 | <div class="title"> |
|
176 | <div class="title"> |
|
177 | <table> |
|
177 | <table> |
|
178 | #{header} |
|
178 | #{header} |
|
179 | <tr> |
|
179 | <tr> |
|
180 | <td class="left-col"> |
|
180 | <td class="left-col"> |
|
181 | #{user.full_name}<br/> |
|
181 | #{user.full_name}<br/> |
|
182 | #{t 'title_bar.current_time'} #{format_short_time(Time.zone.now)} |
|
182 | #{t 'title_bar.current_time'} #{format_short_time(Time.zone.now)} |
|
183 | #{time_left} |
|
183 | #{time_left} |
|
184 | <br/> |
|
184 | <br/> |
|
185 | </td> |
|
185 | </td> |
|
186 | <td class="right-col">#{contest_name}</td> |
|
186 | <td class="right-col">#{contest_name}</td> |
|
187 | </tr> |
|
187 | </tr> |
|
188 | </table> |
|
188 | </table> |
|
189 | </div> |
|
189 | </div> |
|
190 | TITLEBAR |
|
190 | TITLEBAR |
|
191 | result.html_safe |
|
191 | result.html_safe |
|
192 | end |
|
192 | end |
|
193 |
|
193 | ||
|
194 | def markdown(text) |
|
194 | def markdown(text) |
|
195 | markdown = RDiscount.new(text) |
|
195 | markdown = RDiscount.new(text) |
|
196 | markdown.to_html.html_safe |
|
196 | markdown.to_html.html_safe |
|
197 | end |
|
197 | end |
|
198 |
|
198 | ||
|
199 |
|
199 | ||
|
200 | BOOTSTRAP_FLASH_MSG = { |
|
200 | BOOTSTRAP_FLASH_MSG = { |
|
201 | success: 'alert-success', |
|
201 | success: 'alert-success', |
|
202 | error: 'alert-danger', |
|
202 | error: 'alert-danger', |
|
203 | alert: 'alert-block', |
|
203 | alert: 'alert-block', |
|
204 | notice: 'alert-info' |
|
204 | notice: 'alert-info' |
|
205 | } |
|
205 | } |
|
206 |
|
206 | ||
|
207 | def bootstrap_class_for(flash_type) |
|
207 | def bootstrap_class_for(flash_type) |
|
208 | BOOTSTRAP_FLASH_MSG.fetch(flash_type.to_sym, flash_type.to_s) |
|
208 | BOOTSTRAP_FLASH_MSG.fetch(flash_type.to_sym, flash_type.to_s) |
|
209 | end |
|
209 | end |
|
210 |
|
210 | ||
|
211 | def flash_messages |
|
211 | def flash_messages |
|
212 | puts "flahs size = #{flash.count}" |
|
212 | puts "flahs size = #{flash.count}" |
|
213 | flash.each do |msg_type, message| |
|
213 | flash.each do |msg_type, message| |
|
214 | concat(content_tag(:div, message, class: "alert #{bootstrap_class_for(msg_type)} fade in") do |
|
214 | concat(content_tag(:div, message, class: "alert #{bootstrap_class_for(msg_type)} fade in") do |
|
215 | concat content_tag(:button, 'x', class: "close", data: { dismiss: 'alert' }) |
|
215 | concat content_tag(:button, 'x', class: "close", data: { dismiss: 'alert' }) |
|
216 | concat message |
|
216 | concat message |
|
217 | end) |
|
217 | end) |
|
218 | end |
|
218 | end |
|
219 | nil |
|
219 | nil |
|
220 | end |
|
220 | end |
|
221 |
|
221 | ||
|
222 | end |
|
222 | end |
@@ -1,26 +1,26 | |||||
|
1 |
|
1 | ||
|
2 | %tr |
|
2 | %tr |
|
3 | %td{:align => "center"} |
|
3 | %td{:align => "center"} |
|
4 |
- = submission |
|
4 | + = submission.number |
|
5 | - %td{:align => "center"} |
|
5 | + %td.text-right |
|
6 | = link_to "##{submission.id}", submission_path(submission.id) |
|
6 | = link_to "##{submission.id}", submission_path(submission.id) |
|
7 | %td |
|
7 | %td |
|
8 | = l submission.submitted_at, format: :long |
|
8 | = l submission.submitted_at, format: :long |
|
9 | = "( #{time_ago_in_words(submission.submitted_at)} ago)" |
|
9 | = "( #{time_ago_in_words(submission.submitted_at)} ago)" |
|
10 | %td |
|
10 | %td |
|
11 | = submission.source_filename |
|
11 | = submission.source_filename |
|
12 | = " (#{submission.language.pretty_name}) " |
|
12 | = " (#{submission.language.pretty_name}) " |
|
13 | = link_to('[load]',{:action => 'source', :id => submission.id}) |
|
13 | = link_to('[load]',{:action => 'source', :id => submission.id}) |
|
14 | %td |
|
14 | %td |
|
15 | - if submission.graded_at |
|
15 | - if submission.graded_at |
|
16 | = "Graded at #{format_short_time(submission.graded_at)}." |
|
16 | = "Graded at #{format_short_time(submission.graded_at)}." |
|
17 | %br/ |
|
17 | %br/ |
|
18 | = "Score: #{(submission.points*100/submission.problem.full_score).to_i} " if GraderConfiguration['ui.show_score'] |
|
18 | = "Score: #{(submission.points*100/submission.problem.full_score).to_i} " if GraderConfiguration['ui.show_score'] |
|
19 | = " [" |
|
19 | = " [" |
|
20 | %tt |
|
20 | %tt |
|
21 | = submission.grader_comment |
|
21 | = submission.grader_comment |
|
22 | = "]" |
|
22 | = "]" |
|
23 | %td |
|
23 | %td |
|
24 | = render :partial => 'compiler_message', :locals => {:compiler_message => submission.compiler_message } |
|
24 | = render :partial => 'compiler_message', :locals => {:compiler_message => submission.compiler_message } |
|
25 | %td |
|
25 | %td |
|
26 | = link_to 'Edit', edit_submission_path(submission.id), class: 'btn btn-success' |
|
26 | = link_to 'Edit', edit_submission_path(submission.id), class: 'btn btn-success' |
@@ -1,92 +1,93 | |||||
|
1 | %header.navbar.navbar-default.navbar-fixed-top |
|
1 | %header.navbar.navbar-default.navbar-fixed-top |
|
2 | %nav |
|
2 | %nav |
|
3 | .container-fluid |
|
3 | .container-fluid |
|
4 | .navbar-header |
|
4 | .navbar-header |
|
5 | %button.navbar-toggle.collapsed{ data: {toggle: 'collapse', target: '#navbar-collapse'} } |
|
5 | %button.navbar-toggle.collapsed{ data: {toggle: 'collapse', target: '#navbar-collapse'} } |
|
6 | %span.sr-only Togggle Navigation |
|
6 | %span.sr-only Togggle Navigation |
|
7 | %span.icon-bar |
|
7 | %span.icon-bar |
|
8 | %span.icon-bar |
|
8 | %span.icon-bar |
|
9 | %span.icon-bar |
|
9 | %span.icon-bar |
|
10 | %a.navbar-brand{href: main_list_path} |
|
10 | %a.navbar-brand{href: main_list_path} |
|
11 | %span.glyphicon.glyphicon-home |
|
11 | %span.glyphicon.glyphicon-home |
|
12 | MAIN |
|
12 | MAIN |
|
13 | .collapse.navbar-collapse#navbar-collapse |
|
13 | .collapse.navbar-collapse#navbar-collapse |
|
14 | %ul.nav.navbar-nav |
|
14 | %ul.nav.navbar-nav |
|
|
15 | + / submission | ||
|
15 | - if (@current_user!=nil) and (GraderConfiguration.show_tasks_to?(@current_user)) |
|
16 | - if (@current_user!=nil) and (GraderConfiguration.show_tasks_to?(@current_user)) |
|
16 | - //= add_menu("#{I18n.t 'menu.tasks'}", 'tasks', 'list') |
|
||
|
17 | %li.dropdown |
|
17 | %li.dropdown |
|
18 | %a.dropdown-toggle{href: '#', data: {toggle:'dropdown'}, aria: {haspopup:"true", expanded:"false"}, role: "button"} |
|
18 | %a.dropdown-toggle{href: '#', data: {toggle:'dropdown'}, aria: {haspopup:"true", expanded:"false"}, role: "button"} |
|
19 | = "#{I18n.t 'menu.submissions'}" |
|
19 | = "#{I18n.t 'menu.submissions'}" |
|
20 | %span.caret |
|
20 | %span.caret |
|
21 | %ul.dropdown-menu |
|
21 | %ul.dropdown-menu |
|
22 |
- = add_menu("View", ' |
|
22 | + = add_menu("View", 'submissions', 'index') |
|
23 | = add_menu("Self Test", 'test', 'index') |
|
23 | = add_menu("Self Test", 'test', 'index') |
|
|
24 | + / hall of fame | ||
|
24 | - if GraderConfiguration['right.user_hall_of_fame'] |
|
25 | - if GraderConfiguration['right.user_hall_of_fame'] |
|
25 | = add_menu("#{I18n.t 'menu.hall_of_fame'}", 'report', 'problem_hof') |
|
26 | = add_menu("#{I18n.t 'menu.hall_of_fame'}", 'report', 'problem_hof') |
|
26 | / display MODE button (with countdown in contest mode) |
|
27 | / display MODE button (with countdown in contest mode) |
|
27 | - if GraderConfiguration.analysis_mode? |
|
28 | - if GraderConfiguration.analysis_mode? |
|
28 | %div.navbar-btn.btn.btn-success#countdown= "ANALYSIS MODE" |
|
29 | %div.navbar-btn.btn.btn-success#countdown= "ANALYSIS MODE" |
|
29 | - elsif GraderConfiguration.time_limit_mode? |
|
30 | - elsif GraderConfiguration.time_limit_mode? |
|
30 | - if @current_user.contest_finished? |
|
31 | - if @current_user.contest_finished? |
|
31 | %div.navbar-btn.btn.btn-danger#countdown= "Contest is over" |
|
32 | %div.navbar-btn.btn.btn-danger#countdown= "Contest is over" |
|
32 | - elsif !@current_user.contest_started? |
|
33 | - elsif !@current_user.contest_started? |
|
33 | %div.navbar-btn.btn.btn-primary#countdown= (t 'title_bar.contest_not_started') |
|
34 | %div.navbar-btn.btn.btn-primary#countdown= (t 'title_bar.contest_not_started') |
|
34 | - else |
|
35 | - else |
|
35 | %div.navbar-btn.btn.btn-primary#countdown asdf |
|
36 | %div.navbar-btn.btn.btn-primary#countdown asdf |
|
36 | :javascript |
|
37 | :javascript |
|
37 | $("#countdown").countdown({until: "+#{@current_user.contest_time_left.to_i}s", layout: 'Time left: {hnn}:{mnn}:{snn}'}); |
|
38 | $("#countdown").countdown({until: "+#{@current_user.contest_time_left.to_i}s", layout: 'Time left: {hnn}:{mnn}:{snn}'}); |
|
38 | / admin section |
|
39 | / admin section |
|
39 | - if (@current_user!=nil) and (session[:admin]) |
|
40 | - if (@current_user!=nil) and (session[:admin]) |
|
40 | / management |
|
41 | / management |
|
41 | %li.dropdown |
|
42 | %li.dropdown |
|
42 | %a.dropdown-toggle{href: '#', data: {toggle:'dropdown'}, aria: {haspopup:"true", expanded:"false"}, role: "button"} |
|
43 | %a.dropdown-toggle{href: '#', data: {toggle:'dropdown'}, aria: {haspopup:"true", expanded:"false"}, role: "button"} |
|
43 | Manage |
|
44 | Manage |
|
44 | %span.caret |
|
45 | %span.caret |
|
45 | %ul.dropdown-menu |
|
46 | %ul.dropdown-menu |
|
46 | = add_menu( 'Announcements', 'announcements', 'index') |
|
47 | = add_menu( 'Announcements', 'announcements', 'index') |
|
47 | = add_menu( 'Problems', 'problems', 'index') |
|
48 | = add_menu( 'Problems', 'problems', 'index') |
|
48 | = add_menu( 'Users', 'user_admin', 'index') |
|
49 | = add_menu( 'Users', 'user_admin', 'index') |
|
49 | = add_menu( 'Graders', 'graders', 'list') |
|
50 | = add_menu( 'Graders', 'graders', 'list') |
|
50 | = add_menu( 'Message ', 'messages', 'console') |
|
51 | = add_menu( 'Message ', 'messages', 'console') |
|
51 | %li.divider{role: 'separator'} |
|
52 | %li.divider{role: 'separator'} |
|
52 | = add_menu( 'System config', 'configurations', 'index') |
|
53 | = add_menu( 'System config', 'configurations', 'index') |
|
53 | %li.divider{role: 'separator'} |
|
54 | %li.divider{role: 'separator'} |
|
54 | = add_menu( 'Sites', 'sites', 'index') |
|
55 | = add_menu( 'Sites', 'sites', 'index') |
|
55 | = add_menu( 'Contests', 'contest_management', 'index') |
|
56 | = add_menu( 'Contests', 'contest_management', 'index') |
|
56 | / report |
|
57 | / report |
|
57 | %li.dropdown |
|
58 | %li.dropdown |
|
58 | %a.dropdown-toggle{href: '#', data: {toggle:'dropdown'}, aria: {haspopup:"true", expanded:"false"}, role: "button"} |
|
59 | %a.dropdown-toggle{href: '#', data: {toggle:'dropdown'}, aria: {haspopup:"true", expanded:"false"}, role: "button"} |
|
59 | Report |
|
60 | Report |
|
60 | %span.caret |
|
61 | %span.caret |
|
61 | %ul.dropdown-menu |
|
62 | %ul.dropdown-menu |
|
62 | = add_menu( 'Current Score', 'report', 'current_score') |
|
63 | = add_menu( 'Current Score', 'report', 'current_score') |
|
63 | = add_menu( 'Score Report', 'report', 'max_score') |
|
64 | = add_menu( 'Score Report', 'report', 'max_score') |
|
64 | = add_menu( 'Report', 'report', 'multiple_login') |
|
65 | = add_menu( 'Report', 'report', 'multiple_login') |
|
65 | - if (ungraded = Submission.where('graded_at is null').where('submitted_at < ?', 1.minutes.ago).count) > 0 |
|
66 | - if (ungraded = Submission.where('graded_at is null').where('submitted_at < ?', 1.minutes.ago).count) > 0 |
|
66 | =link_to "#{ungraded} backlogs!", |
|
67 | =link_to "#{ungraded} backlogs!", |
|
67 | grader_list_path, |
|
68 | grader_list_path, |
|
68 | class: 'navbar-btn btn btn-default btn-warning', data: {toggle: 'tooltip'},title: 'Number of ungraded submission' |
|
69 | class: 'navbar-btn btn btn-default btn-warning', data: {toggle: 'tooltip'},title: 'Number of ungraded submission' |
|
69 |
|
70 | ||
|
70 | %ul.nav.navbar-nav.navbar-right |
|
71 | %ul.nav.navbar-nav.navbar-right |
|
71 | = add_menu("#{content_tag(:span,'',class: 'glyphicon glyphicon-question-sign')}".html_safe, 'main', 'help') |
|
72 | = add_menu("#{content_tag(:span,'',class: 'glyphicon glyphicon-question-sign')}".html_safe, 'main', 'help') |
|
72 | = add_menu("#{content_tag(:span,'',class: 'glyphicon glyphicon-comment')}".html_safe, 'messages', 'list', {title: I18n.t('menu.messages'), data: {toggle: 'tooltip'}}) |
|
73 | = add_menu("#{content_tag(:span,'',class: 'glyphicon glyphicon-comment')}".html_safe, 'messages', 'list', {title: I18n.t('menu.messages'), data: {toggle: 'tooltip'}}) |
|
73 | - if GraderConfiguration['system.user_setting_enabled'] |
|
74 | - if GraderConfiguration['system.user_setting_enabled'] |
|
74 | = add_menu("#{content_tag(:span,'',class: 'glyphicon glyphicon-cog')}".html_safe, 'users', 'index', {title: I18n.t('menu.settings'), data: {toggle: 'tooltip'}}) |
|
75 | = add_menu("#{content_tag(:span,'',class: 'glyphicon glyphicon-cog')}".html_safe, 'users', 'index', {title: I18n.t('menu.settings'), data: {toggle: 'tooltip'}}) |
|
75 | = add_menu("#{content_tag(:span,'',class: 'glyphicon glyphicon-log-out')} #{@current_user.full_name}".html_safe, 'main', 'login', {title: I18n.t('menu.log_out'), data: {toggle: 'tooltip'}}) |
|
76 | = add_menu("#{content_tag(:span,'',class: 'glyphicon glyphicon-log-out')} #{@current_user.full_name}".html_safe, 'main', 'login', {title: I18n.t('menu.log_out'), data: {toggle: 'tooltip'}}) |
|
76 |
|
77 | ||
|
77 | / |
|
78 | / |
|
78 | - if (@current_user!=nil) and (session[:admin]) |
|
79 | - if (@current_user!=nil) and (session[:admin]) |
|
79 | %nav.navbar.navbar-fixed-top.navbar-inverse.secondnavbar |
|
80 | %nav.navbar.navbar-fixed-top.navbar-inverse.secondnavbar |
|
80 | .container-fluid |
|
81 | .container-fluid |
|
81 | .collapse.navbar-collapse |
|
82 | .collapse.navbar-collapse |
|
82 | %ul.nav.navbar-nav |
|
83 | %ul.nav.navbar-nav |
|
83 | = add_menu( '[Announcements]', 'announcements', 'index') |
|
84 | = add_menu( '[Announcements]', 'announcements', 'index') |
|
84 | = add_menu( '[Msg console]', 'messages', 'console') |
|
85 | = add_menu( '[Msg console]', 'messages', 'console') |
|
85 | = add_menu( '[Problems]', 'problems', 'index') |
|
86 | = add_menu( '[Problems]', 'problems', 'index') |
|
86 | = add_menu( '[Users]', 'user_admin', 'index') |
|
87 | = add_menu( '[Users]', 'user_admin', 'index') |
|
87 | = add_menu( '[Results]', 'user_admin', 'user_stat') |
|
88 | = add_menu( '[Results]', 'user_admin', 'user_stat') |
|
88 | = add_menu( '[Report]', 'report', 'multiple_login') |
|
89 | = add_menu( '[Report]', 'report', 'multiple_login') |
|
89 | = add_menu( '[Graders]', 'graders', 'list') |
|
90 | = add_menu( '[Graders]', 'graders', 'list') |
|
90 | = add_menu( '[Contests]', 'contest_management', 'index') |
|
91 | = add_menu( '[Contests]', 'contest_management', 'index') |
|
91 | = add_menu( '[Sites]', 'sites', 'index') |
|
92 | = add_menu( '[Sites]', 'sites', 'index') |
|
92 | = add_menu( '[System config]', 'configurations', 'index') |
|
93 | = add_menu( '[System config]', 'configurations', 'index') |
@@ -1,29 +1,29 | |||||
|
1 | .panel.panel-info |
|
1 | .panel.panel-info |
|
2 | .panel-heading |
|
2 | .panel-heading |
|
3 | Select Problems |
|
3 | Select Problems |
|
4 | .panel-body |
|
4 | .panel-body |
|
5 | .form-inline |
|
5 | .form-inline |
|
6 | = select 'submission', |
|
6 | = select 'submission', |
|
7 | 'problem_id', |
|
7 | 'problem_id', |
|
8 | @problems.collect {|p| ["[#{p.name}] #{p.full_name}", problem_submissions_url(p.id)]}, |
|
8 | @problems.collect {|p| ["[#{p.name}] #{p.full_name}", problem_submissions_url(p.id)]}, |
|
9 | { selected: (@problem ? problem_submissions_url(@problem) : -1) }, |
|
9 | { selected: (@problem ? problem_submissions_url(@problem) : -1) }, |
|
10 | { class: 'select2 form-control'} |
|
10 | { class: 'select2 form-control'} |
|
11 | %button.btn.btn-primary.btn-sm.go-button#problem_go{data: {source: '#submission_problem_id'}} Go |
|
11 | %button.btn.btn-primary.btn-sm.go-button#problem_go{data: {source: '#submission_problem_id'}} Go |
|
12 |
|
12 | ||
|
13 | - if @problem!=nil |
|
13 | - if @problem!=nil |
|
14 | %h2= "Task: #{@problem.full_name} (#{@problem.name})" |
|
14 | %h2= "Task: #{@problem.full_name} (#{@problem.name})" |
|
15 |
|
15 | ||
|
16 | - if @submissions!=nil |
|
16 | - if @submissions!=nil |
|
17 | - if @submissions.length>0 |
|
17 | - if @submissions.length>0 |
|
18 | %table.table |
|
18 | %table.table |
|
19 | %thead |
|
19 | %thead |
|
20 | %th No. |
|
20 | %th No. |
|
21 | - %th # |
|
21 | + %th.text-right # |
|
22 | %th At |
|
22 | %th At |
|
23 | %th Source |
|
23 | %th Source |
|
24 | %th Result |
|
24 | %th Result |
|
25 | %th{:width => "300px"} Compiler message |
|
25 | %th{:width => "300px"} Compiler message |
|
26 | %th |
|
26 | %th |
|
27 | = render :partial => 'submission', :collection => @submissions |
|
27 | = render :partial => 'submission', :collection => @submissions |
|
28 | - else |
|
28 | - else |
|
29 | No submission |
|
29 | No submission |
deleted file |
You need to be logged in to leave comments.
Login now