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 - - 6 files changed: 7 inserted, 54 deleted
@@ -31,209 +31,192 | |||||
|
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| |
@@ -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,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