Description:
* add forgotten toggle file
* main/submission changed to bootstrap
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r559:2e5e11be6cae - - 9 files changed: 91 inserted, 9 deleted
@@ -0,0 +1,6 | |||||
|
|
1 | + $ -> | ||
|
|
2 | + $("#submission_problem_go").on 'click', (event) -> | ||
|
|
3 | + url = $("#submission_problem_id").val() | ||
|
|
4 | + if (url) | ||
|
|
5 | + window.location = url | ||
|
|
6 | + |
@@ -0,0 +1,46 | |||||
|
|
1 | + - content_for :head do | ||
|
|
2 | + = stylesheet_link_tag 'problems' | ||
|
|
3 | + %h1 Listing problems | ||
|
|
4 | + %p | ||
|
|
5 | + = link_to 'New problem', new_problem_path, class: 'btn btn-default btn-sm' | ||
|
|
6 | + = link_to 'Manage problems', { action: 'manage'}, class: 'btn btn-default btn-sm' | ||
|
|
7 | + = link_to 'Import problems', {:action => 'import'}, class: 'btn btn-default btn-sm' | ||
|
|
8 | + = link_to 'Turn off all problems', {:action => 'turn_all_off'}, class: 'btn btn-default btn-sm' | ||
|
|
9 | + = link_to 'Turn on all problems', {:action => 'turn_all_on'}, class: 'btn btn-default btn-sm' | ||
|
|
10 | + .submitbox | ||
|
|
11 | + = form_tag :action => 'quick_create' do | ||
|
|
12 | + %b Quick New: | ||
|
|
13 | + %label{:for => "problem_name"} Name | ||
|
|
14 | + = text_field 'problem', 'name' | ||
|
|
15 | + | | ||
|
|
16 | + %label{:for => "problem_full_name"} Full name | ||
|
|
17 | + = text_field 'problem', 'full_name' | ||
|
|
18 | + = submit_tag "Create" | ||
|
|
19 | + %table.table.table-condensed.table-hover | ||
|
|
20 | + %thead | ||
|
|
21 | + %th Name | ||
|
|
22 | + %th Full name | ||
|
|
23 | + %th Full score | ||
|
|
24 | + %th Date added | ||
|
|
25 | + %th Avail? | ||
|
|
26 | + %th Test? | ||
|
|
27 | + - if GraderConfiguration.multicontests? | ||
|
|
28 | + %th Contests | ||
|
|
29 | + - for problem in @problems | ||
|
|
30 | + %tr{:class => "#{(problem.available) ? "success" : "danger"}", :id => "prob-#{problem.id}", :name => "prob-#{problem.id}"} | ||
|
|
31 | + - @problem=problem | ||
|
|
32 | + %td= in_place_editor_field :problem, :name, {}, :rows=>1 | ||
|
|
33 | + %td= in_place_editor_field :problem, :full_name, {}, :rows=>1 | ||
|
|
34 | + %td= in_place_editor_field :problem, :full_score, {}, :rows=>1 | ||
|
|
35 | + %td= problem.date_added | ||
|
|
36 | + %td{}= link_to (@problem.available? ? "Yes" : "No"), url_for(controller: :problems, action: :toggle, id: @problem), { class: "btn btn-block btn-sm btn-#{(@problem.available? ? 'success' : 'default')} ajax-toggle", id: "prob-#{@problem.id}-avail", data: {remote: true, method: 'post' } } | ||
|
|
37 | + %td= problem.test_allowed | ||
|
|
38 | + - if GraderConfiguration.multicontests? | ||
|
|
39 | + %td | ||
|
|
40 | + = problem.contests.collect { |c| c.name }.join(', ') | ||
|
|
41 | + %td= link_to 'Stat', {:action => 'stat', :id => problem.id}, class: 'btn btn-primary btn-sm' | ||
|
|
42 | + %td= link_to 'Show', {:action => 'show', :id => problem}, class: 'btn btn-primary btn-sm' | ||
|
|
43 | + %td= link_to 'Edit', {:action => 'edit', :id => problem}, class: 'btn btn-primary btn-sm' | ||
|
|
44 | + %td= link_to 'Destroy', { :action => 'destroy', :id => problem }, :confirm => 'Are you sure?', :method => :post, class: 'btn btn-danger btn-sm' | ||
|
|
45 | + %br/ | ||
|
|
46 | + = link_to '[New problem]', :action => 'new' |
@@ -0,0 +1,12 | |||||
|
|
1 | + :plain | ||
|
|
2 | + b = $("#prob-#{@problem.id}-avail"); | ||
|
|
3 | + b.removeClass('btn-default'); | ||
|
|
4 | + b.removeClass('btn-success'); | ||
|
|
5 | + b.removeClass('btn-warning'); | ||
|
|
6 | + b.addClass("btn-#{@problem.available? ? 'success' : 'default'}"); | ||
|
|
7 | + b.text("#{@problem.available? ? 'Yes' : 'No'}"); | ||
|
|
8 | + r = $("#prob-#{@problem.id}"); | ||
|
|
9 | + r.removeClass('success'); | ||
|
|
10 | + r.removeClass('danger'); | ||
|
|
11 | + r.addClass("#{@problem.available? ? 'success' : 'danger'}"); | ||
|
|
12 | + |
@@ -1,15 +1,14 | |||||
|
1 | #js for announcement |
|
1 | #js for announcement |
|
2 | $ -> |
|
2 | $ -> |
|
3 | $('.ajax-toggle').on 'click', (event) -> |
|
3 | $('.ajax-toggle').on 'click', (event) -> |
|
4 | - console.log event.target.id |
|
||
|
5 | target = $(event.target) |
|
4 | target = $(event.target) |
|
6 | target.removeClass 'btn-default' |
|
5 | target.removeClass 'btn-default' |
|
7 | target.removeClass 'btn-success' |
|
6 | target.removeClass 'btn-success' |
|
8 | target.addClass 'btn-warning' |
|
7 | target.addClass 'btn-warning' |
|
9 | target.text '...' |
|
8 | target.text '...' |
|
10 | return |
|
9 | return |
|
11 |
|
10 | ||
|
12 | $(document).ajaxError (event, jqxhr, settings, exception) -> |
|
11 | $(document).ajaxError (event, jqxhr, settings, exception) -> |
|
13 | if jqxhr.status |
|
12 | if jqxhr.status |
|
14 | alert 'We\'re sorry, but something went wrong (' + jqxhr.status + ')' |
|
13 | alert 'We\'re sorry, but something went wrong (' + jqxhr.status + ')' |
|
15 | return |
|
14 | return |
@@ -1,319 +1,319 | |||||
|
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.find_for_frontpage |
|
48 | @announcements = Announcement.find_for_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 | @submission.submitted_at = Time.new.gmtime |
|
72 | @submission.submitted_at = Time.new.gmtime |
|
73 | @submission.ip_address = request.remote_ip |
|
73 | @submission.ip_address = request.remote_ip |
|
74 |
|
74 | ||
|
75 | if GraderConfiguration.time_limit_mode? and user.contest_finished? |
|
75 | if GraderConfiguration.time_limit_mode? and user.contest_finished? |
|
76 | @submission.errors.add(:base,"The contest is over.") |
|
76 | @submission.errors.add(:base,"The contest is over.") |
|
77 | prepare_list_information |
|
77 | prepare_list_information |
|
78 | render :action => 'list' and return |
|
78 | render :action => 'list' and return |
|
79 | end |
|
79 | end |
|
80 |
|
80 | ||
|
81 | if @submission.valid? |
|
81 | if @submission.valid? |
|
82 | if @submission.save == false |
|
82 | if @submission.save == false |
|
83 | flash[:notice] = 'Error saving your submission' |
|
83 | flash[:notice] = 'Error saving your submission' |
|
84 | elsif Task.create(:submission_id => @submission.id, |
|
84 | elsif Task.create(:submission_id => @submission.id, |
|
85 | :status => Task::STATUS_INQUEUE) == false |
|
85 | :status => Task::STATUS_INQUEUE) == false |
|
86 | flash[:notice] = 'Error adding your submission to task queue' |
|
86 | flash[:notice] = 'Error adding your submission to task queue' |
|
87 | end |
|
87 | end |
|
88 | else |
|
88 | else |
|
89 | prepare_list_information |
|
89 | prepare_list_information |
|
90 | render :action => 'list' and return |
|
90 | render :action => 'list' and return |
|
91 | end |
|
91 | end |
|
92 | redirect_to :action => 'list' |
|
92 | redirect_to :action => 'list' |
|
93 | end |
|
93 | end |
|
94 |
|
94 | ||
|
95 | def source |
|
95 | def source |
|
96 | submission = Submission.find(params[:id]) |
|
96 | submission = Submission.find(params[:id]) |
|
97 | if ((submission.user_id == session[:user_id]) and |
|
97 | if ((submission.user_id == session[:user_id]) and |
|
98 | (submission.problem != nil) and |
|
98 | (submission.problem != nil) and |
|
99 | (submission.problem.available)) |
|
99 | (submission.problem.available)) |
|
100 | send_data(submission.source, |
|
100 | send_data(submission.source, |
|
101 | {:filename => submission.download_filename, |
|
101 | {:filename => submission.download_filename, |
|
102 | :type => 'text/plain'}) |
|
102 | :type => 'text/plain'}) |
|
103 | else |
|
103 | else |
|
104 | flash[:notice] = 'Error viewing source' |
|
104 | flash[:notice] = 'Error viewing source' |
|
105 | redirect_to :action => 'list' |
|
105 | redirect_to :action => 'list' |
|
106 | end |
|
106 | end |
|
107 | end |
|
107 | end |
|
108 |
|
108 | ||
|
109 | def compiler_msg |
|
109 | def compiler_msg |
|
110 | @submission = Submission.find(params[:id]) |
|
110 | @submission = Submission.find(params[:id]) |
|
111 | if @submission.user_id == session[:user_id] |
|
111 | if @submission.user_id == session[:user_id] |
|
112 | render :action => 'compiler_msg', :layout => 'empty' |
|
112 | render :action => 'compiler_msg', :layout => 'empty' |
|
113 | else |
|
113 | else |
|
114 | flash[:notice] = 'Error viewing source' |
|
114 | flash[:notice] = 'Error viewing source' |
|
115 | redirect_to :action => 'list' |
|
115 | redirect_to :action => 'list' |
|
116 | end |
|
116 | end |
|
117 | end |
|
117 | end |
|
118 |
|
118 | ||
|
119 | def submission |
|
119 | def submission |
|
120 | @user = User.find(session[:user_id]) |
|
120 | @user = User.find(session[:user_id]) |
|
121 | @problems = @user.available_problems |
|
121 | @problems = @user.available_problems |
|
122 | if params[:id]==nil |
|
122 | if params[:id]==nil |
|
123 | @problem = nil |
|
123 | @problem = nil |
|
124 | @submissions = nil |
|
124 | @submissions = nil |
|
125 | else |
|
125 | else |
|
126 |
- @problem = Problem.find_by_ |
|
126 | + @problem = Problem.find_by_id(params[:id]) |
|
127 | - if not @problem.available |
|
127 | + if (@problem == nil) or (not @problem.available) |
|
128 | redirect_to :action => 'list' |
|
128 | redirect_to :action => 'list' |
|
129 | flash[:notice] = 'Error: submissions for that problem are not viewable.' |
|
129 | flash[:notice] = 'Error: submissions for that problem are not viewable.' |
|
130 | return |
|
130 | return |
|
131 | end |
|
131 | end |
|
132 | @submissions = Submission.find_all_by_user_problem(@user.id, @problem.id) |
|
132 | @submissions = Submission.find_all_by_user_problem(@user.id, @problem.id) |
|
133 | end |
|
133 | end |
|
134 | end |
|
134 | end |
|
135 |
|
135 | ||
|
136 | def result |
|
136 | def result |
|
137 | if !GraderConfiguration.show_grading_result |
|
137 | if !GraderConfiguration.show_grading_result |
|
138 | redirect_to :action => 'list' and return |
|
138 | redirect_to :action => 'list' and return |
|
139 | end |
|
139 | end |
|
140 | @user = User.find(session[:user_id]) |
|
140 | @user = User.find(session[:user_id]) |
|
141 | @submission = Submission.find(params[:id]) |
|
141 | @submission = Submission.find(params[:id]) |
|
142 | if @submission.user!=@user |
|
142 | if @submission.user!=@user |
|
143 | flash[:notice] = 'You are not allowed to view result of other users.' |
|
143 | flash[:notice] = 'You are not allowed to view result of other users.' |
|
144 | redirect_to :action => 'list' and return |
|
144 | redirect_to :action => 'list' and return |
|
145 | end |
|
145 | end |
|
146 | prepare_grading_result(@submission) |
|
146 | prepare_grading_result(@submission) |
|
147 | end |
|
147 | end |
|
148 |
|
148 | ||
|
149 | def load_output |
|
149 | def load_output |
|
150 | if !GraderConfiguration.show_grading_result or params[:num]==nil |
|
150 | if !GraderConfiguration.show_grading_result or params[:num]==nil |
|
151 | redirect_to :action => 'list' and return |
|
151 | redirect_to :action => 'list' and return |
|
152 | end |
|
152 | end |
|
153 | @user = User.find(session[:user_id]) |
|
153 | @user = User.find(session[:user_id]) |
|
154 | @submission = Submission.find(params[:id]) |
|
154 | @submission = Submission.find(params[:id]) |
|
155 | if @submission.user!=@user |
|
155 | if @submission.user!=@user |
|
156 | flash[:notice] = 'You are not allowed to view result of other users.' |
|
156 | flash[:notice] = 'You are not allowed to view result of other users.' |
|
157 | redirect_to :action => 'list' and return |
|
157 | redirect_to :action => 'list' and return |
|
158 | end |
|
158 | end |
|
159 | case_num = params[:num].to_i |
|
159 | case_num = params[:num].to_i |
|
160 | out_filename = output_filename(@user.login, |
|
160 | out_filename = output_filename(@user.login, |
|
161 | @submission.problem.name, |
|
161 | @submission.problem.name, |
|
162 | @submission.id, |
|
162 | @submission.id, |
|
163 | case_num) |
|
163 | case_num) |
|
164 | if !FileTest.exists?(out_filename) |
|
164 | if !FileTest.exists?(out_filename) |
|
165 | flash[:notice] = 'Output not found.' |
|
165 | flash[:notice] = 'Output not found.' |
|
166 | redirect_to :action => 'list' and return |
|
166 | redirect_to :action => 'list' and return |
|
167 | end |
|
167 | end |
|
168 |
|
168 | ||
|
169 | if defined?(USE_APACHE_XSENDFILE) and USE_APACHE_XSENDFILE |
|
169 | if defined?(USE_APACHE_XSENDFILE) and USE_APACHE_XSENDFILE |
|
170 | response.headers['Content-Type'] = "application/force-download" |
|
170 | response.headers['Content-Type'] = "application/force-download" |
|
171 | response.headers['Content-Disposition'] = "attachment; filename=\"output-#{case_num}.txt\"" |
|
171 | response.headers['Content-Disposition'] = "attachment; filename=\"output-#{case_num}.txt\"" |
|
172 | response.headers["X-Sendfile"] = out_filename |
|
172 | response.headers["X-Sendfile"] = out_filename |
|
173 | response.headers['Content-length'] = File.size(out_filename) |
|
173 | response.headers['Content-length'] = File.size(out_filename) |
|
174 | render :nothing => true |
|
174 | render :nothing => true |
|
175 | else |
|
175 | else |
|
176 | send_file out_filename, :stream => false, :filename => "output-#{case_num}.txt", :type => "text/plain" |
|
176 | send_file out_filename, :stream => false, :filename => "output-#{case_num}.txt", :type => "text/plain" |
|
177 | end |
|
177 | end |
|
178 | end |
|
178 | end |
|
179 |
|
179 | ||
|
180 | def error |
|
180 | def error |
|
181 | @user = User.find(session[:user_id]) |
|
181 | @user = User.find(session[:user_id]) |
|
182 | end |
|
182 | end |
|
183 |
|
183 | ||
|
184 | # announcement refreshing and hiding methods |
|
184 | # announcement refreshing and hiding methods |
|
185 |
|
185 | ||
|
186 | def announcements |
|
186 | def announcements |
|
187 | if params.has_key? 'recent' |
|
187 | if params.has_key? 'recent' |
|
188 | prepare_announcements(params[:recent]) |
|
188 | prepare_announcements(params[:recent]) |
|
189 | else |
|
189 | else |
|
190 | prepare_announcements |
|
190 | prepare_announcements |
|
191 | end |
|
191 | end |
|
192 | render(:partial => 'announcement', |
|
192 | render(:partial => 'announcement', |
|
193 | :collection => @announcements, |
|
193 | :collection => @announcements, |
|
194 | :locals => {:announcement_effect => true}) |
|
194 | :locals => {:announcement_effect => true}) |
|
195 | end |
|
195 | end |
|
196 |
|
196 | ||
|
197 | def confirm_contest_start |
|
197 | def confirm_contest_start |
|
198 | user = User.find(session[:user_id]) |
|
198 | user = User.find(session[:user_id]) |
|
199 | if request.method == 'POST' |
|
199 | if request.method == 'POST' |
|
200 | user.update_start_time |
|
200 | user.update_start_time |
|
201 | redirect_to :action => 'list' |
|
201 | redirect_to :action => 'list' |
|
202 | else |
|
202 | else |
|
203 | @contests = user.contests |
|
203 | @contests = user.contests |
|
204 | @user = user |
|
204 | @user = user |
|
205 | end |
|
205 | end |
|
206 | end |
|
206 | end |
|
207 |
|
207 | ||
|
208 | protected |
|
208 | protected |
|
209 |
|
209 | ||
|
210 | def prepare_announcements(recent=nil) |
|
210 | def prepare_announcements(recent=nil) |
|
211 | if GraderConfiguration.show_tasks_to?(@user) |
|
211 | if GraderConfiguration.show_tasks_to?(@user) |
|
212 | @announcements = Announcement.find_published(true) |
|
212 | @announcements = Announcement.find_published(true) |
|
213 | else |
|
213 | else |
|
214 | @announcements = Announcement.find_published |
|
214 | @announcements = Announcement.find_published |
|
215 | end |
|
215 | end |
|
216 | if recent!=nil |
|
216 | if recent!=nil |
|
217 | recent_id = recent.to_i |
|
217 | recent_id = recent.to_i |
|
218 | @announcements = @announcements.find_all { |a| a.id > recent_id } |
|
218 | @announcements = @announcements.find_all { |a| a.id > recent_id } |
|
219 | end |
|
219 | end |
|
220 | end |
|
220 | end |
|
221 |
|
221 | ||
|
222 | def prepare_list_information |
|
222 | def prepare_list_information |
|
223 | @user = User.find(session[:user_id]) |
|
223 | @user = User.find(session[:user_id]) |
|
224 | if not GraderConfiguration.multicontests? |
|
224 | if not GraderConfiguration.multicontests? |
|
225 | @problems = @user.available_problems |
|
225 | @problems = @user.available_problems |
|
226 | else |
|
226 | else |
|
227 | @contest_problems = @user.available_problems_group_by_contests |
|
227 | @contest_problems = @user.available_problems_group_by_contests |
|
228 | @problems = @user.available_problems |
|
228 | @problems = @user.available_problems |
|
229 | end |
|
229 | end |
|
230 | @prob_submissions = {} |
|
230 | @prob_submissions = {} |
|
231 | @problems.each do |p| |
|
231 | @problems.each do |p| |
|
232 | sub = Submission.find_last_by_user_and_problem(@user.id,p.id) |
|
232 | sub = Submission.find_last_by_user_and_problem(@user.id,p.id) |
|
233 | if sub!=nil |
|
233 | if sub!=nil |
|
234 | @prob_submissions[p.id] = { :count => sub.number, :submission => sub } |
|
234 | @prob_submissions[p.id] = { :count => sub.number, :submission => sub } |
|
235 | else |
|
235 | else |
|
236 | @prob_submissions[p.id] = { :count => 0, :submission => nil } |
|
236 | @prob_submissions[p.id] = { :count => 0, :submission => nil } |
|
237 | end |
|
237 | end |
|
238 | end |
|
238 | end |
|
239 | prepare_announcements |
|
239 | prepare_announcements |
|
240 | end |
|
240 | end |
|
241 |
|
241 | ||
|
242 | def check_viewability |
|
242 | def check_viewability |
|
243 | @user = User.find(session[:user_id]) |
|
243 | @user = User.find(session[:user_id]) |
|
244 | if (!GraderConfiguration.show_tasks_to?(@user)) and |
|
244 | if (!GraderConfiguration.show_tasks_to?(@user)) and |
|
245 | ((action_name=='submission') or (action_name=='submit')) |
|
245 | ((action_name=='submission') or (action_name=='submit')) |
|
246 | redirect_to :action => 'list' and return |
|
246 | redirect_to :action => 'list' and return |
|
247 | end |
|
247 | end |
|
248 | end |
|
248 | end |
|
249 |
|
249 | ||
|
250 | def prepare_grading_result(submission) |
|
250 | def prepare_grading_result(submission) |
|
251 | if GraderConfiguration.task_grading_info.has_key? submission.problem.name |
|
251 | if GraderConfiguration.task_grading_info.has_key? submission.problem.name |
|
252 | grading_info = GraderConfiguration.task_grading_info[submission.problem.name] |
|
252 | grading_info = GraderConfiguration.task_grading_info[submission.problem.name] |
|
253 | else |
|
253 | else |
|
254 | # guess task info from problem.full_score |
|
254 | # guess task info from problem.full_score |
|
255 | cases = submission.problem.full_score / 10 |
|
255 | cases = submission.problem.full_score / 10 |
|
256 | grading_info = { |
|
256 | grading_info = { |
|
257 | 'testruns' => cases, |
|
257 | 'testruns' => cases, |
|
258 | 'testcases' => cases |
|
258 | 'testcases' => cases |
|
259 | } |
|
259 | } |
|
260 | end |
|
260 | end |
|
261 | @test_runs = [] |
|
261 | @test_runs = [] |
|
262 | if grading_info['testruns'].is_a? Integer |
|
262 | if grading_info['testruns'].is_a? Integer |
|
263 | trun_count = grading_info['testruns'] |
|
263 | trun_count = grading_info['testruns'] |
|
264 | trun_count.times do |i| |
|
264 | trun_count.times do |i| |
|
265 | @test_runs << [ read_grading_result(@user.login, |
|
265 | @test_runs << [ read_grading_result(@user.login, |
|
266 | submission.problem.name, |
|
266 | submission.problem.name, |
|
267 | submission.id, |
|
267 | submission.id, |
|
268 | i+1) ] |
|
268 | i+1) ] |
|
269 | end |
|
269 | end |
|
270 | else |
|
270 | else |
|
271 | grading_info['testruns'].keys.sort.each do |num| |
|
271 | grading_info['testruns'].keys.sort.each do |num| |
|
272 | run = [] |
|
272 | run = [] |
|
273 | testrun = grading_info['testruns'][num] |
|
273 | testrun = grading_info['testruns'][num] |
|
274 | testrun.each do |c| |
|
274 | testrun.each do |c| |
|
275 | run << read_grading_result(@user.login, |
|
275 | run << read_grading_result(@user.login, |
|
276 | submission.problem.name, |
|
276 | submission.problem.name, |
|
277 | submission.id, |
|
277 | submission.id, |
|
278 | c) |
|
278 | c) |
|
279 | end |
|
279 | end |
|
280 | @test_runs << run |
|
280 | @test_runs << run |
|
281 | end |
|
281 | end |
|
282 | end |
|
282 | end |
|
283 | end |
|
283 | end |
|
284 |
|
284 | ||
|
285 | def grading_result_dir(user_name, problem_name, submission_id, case_num) |
|
285 | def grading_result_dir(user_name, problem_name, submission_id, case_num) |
|
286 | return "#{GRADING_RESULT_DIR}/#{user_name}/#{problem_name}/#{submission_id}/test-result/#{case_num}" |
|
286 | return "#{GRADING_RESULT_DIR}/#{user_name}/#{problem_name}/#{submission_id}/test-result/#{case_num}" |
|
287 | end |
|
287 | end |
|
288 |
|
288 | ||
|
289 | def output_filename(user_name, problem_name, submission_id, case_num) |
|
289 | def output_filename(user_name, problem_name, submission_id, case_num) |
|
290 | dir = grading_result_dir(user_name,problem_name, submission_id, case_num) |
|
290 | dir = grading_result_dir(user_name,problem_name, submission_id, case_num) |
|
291 | return "#{dir}/output.txt" |
|
291 | return "#{dir}/output.txt" |
|
292 | end |
|
292 | end |
|
293 |
|
293 | ||
|
294 | def read_grading_result(user_name, problem_name, submission_id, case_num) |
|
294 | def read_grading_result(user_name, problem_name, submission_id, case_num) |
|
295 | dir = grading_result_dir(user_name,problem_name, submission_id, case_num) |
|
295 | dir = grading_result_dir(user_name,problem_name, submission_id, case_num) |
|
296 | result_file_name = "#{dir}/result" |
|
296 | result_file_name = "#{dir}/result" |
|
297 | if !FileTest.exists?(result_file_name) |
|
297 | if !FileTest.exists?(result_file_name) |
|
298 | return {:num => case_num, :msg => 'program did not run'} |
|
298 | return {:num => case_num, :msg => 'program did not run'} |
|
299 | else |
|
299 | else |
|
300 | results = File.open(result_file_name).readlines |
|
300 | results = File.open(result_file_name).readlines |
|
301 | run_stat = extract_running_stat(results) |
|
301 | run_stat = extract_running_stat(results) |
|
302 | output_filename = "#{dir}/output.txt" |
|
302 | output_filename = "#{dir}/output.txt" |
|
303 | if FileTest.exists?(output_filename) |
|
303 | if FileTest.exists?(output_filename) |
|
304 | output_file = true |
|
304 | output_file = true |
|
305 | output_size = File.size(output_filename) |
|
305 | output_size = File.size(output_filename) |
|
306 | else |
|
306 | else |
|
307 | output_file = false |
|
307 | output_file = false |
|
308 | output_size = 0 |
|
308 | output_size = 0 |
|
309 | end |
|
309 | end |
|
310 |
|
310 | ||
|
311 | return { |
|
311 | return { |
|
312 | :num => case_num, |
|
312 | :num => case_num, |
|
313 | :msg => results[0], |
|
313 | :msg => results[0], |
|
314 | :run_stat => run_stat, |
|
314 | :run_stat => run_stat, |
|
315 | :output => output_file, |
|
315 | :output => output_file, |
|
316 | :output_size => output_size |
|
316 | :output_size => output_size |
|
317 | } |
|
317 | } |
|
318 | end |
|
318 | end |
|
319 | end |
|
319 | end |
@@ -1,170 +1,182 | |||||
|
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 | def navbar_user_header |
|
4 | def navbar_user_header |
|
5 | left_menu = '' |
|
5 | left_menu = '' |
|
6 | right_menu = '' |
|
6 | right_menu = '' |
|
7 | user = User.find(session[:user_id]) |
|
7 | user = User.find(session[:user_id]) |
|
8 |
|
8 | ||
|
9 | if (user!=nil) and (GraderConfiguration.show_tasks_to?(user)) |
|
9 | if (user!=nil) and (GraderConfiguration.show_tasks_to?(user)) |
|
10 | left_menu << add_menu("#{I18n.t 'menu.tasks'}", 'tasks', 'list') |
|
10 | left_menu << add_menu("#{I18n.t 'menu.tasks'}", 'tasks', 'list') |
|
11 | left_menu << add_menu("#{I18n.t 'menu.submissions'}", 'main', 'submission') |
|
11 | left_menu << add_menu("#{I18n.t 'menu.submissions'}", 'main', 'submission') |
|
12 | left_menu << add_menu("#{I18n.t 'menu.test'}", 'test', 'index') |
|
12 | left_menu << add_menu("#{I18n.t 'menu.test'}", 'test', 'index') |
|
13 | end |
|
13 | end |
|
14 |
|
14 | ||
|
15 | if GraderConfiguration['right.user_hall_of_fame'] |
|
15 | if GraderConfiguration['right.user_hall_of_fame'] |
|
16 | left_menu << add_menu("#{I18n.t 'menu.hall_of_fame'}", 'report', 'problem_hof') |
|
16 | left_menu << add_menu("#{I18n.t 'menu.hall_of_fame'}", 'report', 'problem_hof') |
|
17 | end |
|
17 | end |
|
18 |
|
18 | ||
|
19 | right_menu << add_menu("#{content_tag(:span,'',class: 'glyphicon glyphicon-question-sign')}".html_safe, 'main', 'help') |
|
19 | 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-comment')}".html_safe, 'messages', 'list', {title: I18n.t('menu.messages'), data: {toggle: 'tooltip'}}) |
|
20 | right_menu << add_menu("#{content_tag(:span,'',class: 'glyphicon glyphicon-comment')}".html_safe, 'messages', 'list', {title: I18n.t('menu.messages'), data: {toggle: 'tooltip'}}) |
|
21 | if GraderConfiguration['system.user_setting_enabled'] |
|
21 | if GraderConfiguration['system.user_setting_enabled'] |
|
22 | right_menu << add_menu("#{content_tag(:span,'',class: 'glyphicon glyphicon-cog')}".html_safe, 'users', 'index', {title: I18n.t('menu.settings'), data: {toggle: 'tooltip'}}) |
|
22 | right_menu << add_menu("#{content_tag(:span,'',class: 'glyphicon glyphicon-cog')}".html_safe, 'users', 'index', {title: I18n.t('menu.settings'), data: {toggle: 'tooltip'}}) |
|
23 | end |
|
23 | end |
|
24 | 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'}}) |
|
24 | 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 |
|
25 | ||
|
26 |
|
26 | ||
|
27 | 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') |
|
27 | 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 | end |
|
28 | end |
|
29 |
|
29 | ||
|
30 | def add_menu(title, controller, action,html_option = {}) |
|
30 | def add_menu(title, controller, action,html_option = {}) |
|
31 | link_option = {controller: controller, action: action} |
|
31 | link_option = {controller: controller, action: action} |
|
32 | html_option[:class] = (html_option[:class] || '') + " active" if current_page?(link_option) |
|
32 | html_option[:class] = (html_option[:class] || '') + " active" if current_page?(link_option) |
|
33 | content_tag(:li, link_to(title,link_option),html_option) |
|
33 | content_tag(:li, link_to(title,link_option),html_option) |
|
34 | end |
|
34 | end |
|
35 |
|
35 | ||
|
36 | def user_header |
|
36 | def user_header |
|
37 | menu_items = '' |
|
37 | menu_items = '' |
|
38 | user = User.find(session[:user_id]) |
|
38 | user = User.find(session[:user_id]) |
|
39 |
|
39 | ||
|
40 | if (user!=nil) and (session[:admin]) |
|
40 | if (user!=nil) and (session[:admin]) |
|
41 | # admin menu |
|
41 | # admin menu |
|
42 | menu_items << "<b>Administrative task:</b> " |
|
42 | menu_items << "<b>Administrative task:</b> " |
|
43 | append_to menu_items, '[Announcements]', 'announcements', 'index' |
|
43 | append_to menu_items, '[Announcements]', 'announcements', 'index' |
|
44 | append_to menu_items, '[Msg console]', 'messages', 'console' |
|
44 | append_to menu_items, '[Msg console]', 'messages', 'console' |
|
45 | append_to menu_items, '[Problems]', 'problems', 'index' |
|
45 | append_to menu_items, '[Problems]', 'problems', 'index' |
|
46 | append_to menu_items, '[Users]', 'user_admin', 'index' |
|
46 | append_to menu_items, '[Users]', 'user_admin', 'index' |
|
47 | append_to menu_items, '[Results]', 'user_admin', 'user_stat' |
|
47 | append_to menu_items, '[Results]', 'user_admin', 'user_stat' |
|
48 | append_to menu_items, '[Report]', 'report', 'multiple_login' |
|
48 | append_to menu_items, '[Report]', 'report', 'multiple_login' |
|
49 | append_to menu_items, '[Graders]', 'graders', 'list' |
|
49 | append_to menu_items, '[Graders]', 'graders', 'list' |
|
50 | append_to menu_items, '[Contests]', 'contest_management', 'index' |
|
50 | append_to menu_items, '[Contests]', 'contest_management', 'index' |
|
51 | append_to menu_items, '[Sites]', 'sites', 'index' |
|
51 | append_to menu_items, '[Sites]', 'sites', 'index' |
|
52 | append_to menu_items, '[System config]', 'configurations', 'index' |
|
52 | append_to menu_items, '[System config]', 'configurations', 'index' |
|
53 | menu_items << "<br/>" |
|
53 | menu_items << "<br/>" |
|
54 | end |
|
54 | end |
|
55 |
|
55 | ||
|
56 | # main page |
|
56 | # main page |
|
57 | append_to menu_items, "[#{I18n.t 'menu.main'}]", 'main', 'list' |
|
57 | append_to menu_items, "[#{I18n.t 'menu.main'}]", 'main', 'list' |
|
58 | append_to menu_items, "[#{I18n.t 'menu.messages'}]", 'messages', 'list' |
|
58 | append_to menu_items, "[#{I18n.t 'menu.messages'}]", 'messages', 'list' |
|
59 |
|
59 | ||
|
60 | if (user!=nil) and (GraderConfiguration.show_tasks_to?(user)) |
|
60 | if (user!=nil) and (GraderConfiguration.show_tasks_to?(user)) |
|
61 | append_to menu_items, "[#{I18n.t 'menu.tasks'}]", 'tasks', 'list' |
|
61 | append_to menu_items, "[#{I18n.t 'menu.tasks'}]", 'tasks', 'list' |
|
62 | append_to menu_items, "[#{I18n.t 'menu.submissions'}]", 'main', 'submission' |
|
62 | append_to menu_items, "[#{I18n.t 'menu.submissions'}]", 'main', 'submission' |
|
63 | append_to menu_items, "[#{I18n.t 'menu.test'}]", 'test', 'index' |
|
63 | append_to menu_items, "[#{I18n.t 'menu.test'}]", 'test', 'index' |
|
64 | end |
|
64 | end |
|
65 |
|
65 | ||
|
66 | if GraderConfiguration['right.user_hall_of_fame'] |
|
66 | if GraderConfiguration['right.user_hall_of_fame'] |
|
67 | append_to menu_items, "[#{I18n.t 'menu.hall_of_fame'}]", 'report', 'problem_hof' |
|
67 | append_to menu_items, "[#{I18n.t 'menu.hall_of_fame'}]", 'report', 'problem_hof' |
|
68 | end |
|
68 | end |
|
69 | append_to menu_items, "[#{I18n.t 'menu.help'}]", 'main', 'help' |
|
69 | append_to menu_items, "[#{I18n.t 'menu.help'}]", 'main', 'help' |
|
70 |
|
70 | ||
|
71 | if GraderConfiguration['system.user_setting_enabled'] |
|
71 | if GraderConfiguration['system.user_setting_enabled'] |
|
72 | append_to menu_items, "[#{I18n.t 'menu.settings'}]", 'users', 'index' |
|
72 | append_to menu_items, "[#{I18n.t 'menu.settings'}]", 'users', 'index' |
|
73 | end |
|
73 | end |
|
74 | append_to menu_items, "[#{I18n.t 'menu.log_out'}]", 'main', 'login' |
|
74 | append_to menu_items, "[#{I18n.t 'menu.log_out'}]", 'main', 'login' |
|
75 |
|
75 | ||
|
76 | menu_items.html_safe |
|
76 | menu_items.html_safe |
|
77 | end |
|
77 | end |
|
78 |
|
78 | ||
|
79 | def append_to(option,label, controller, action) |
|
79 | def append_to(option,label, controller, action) |
|
80 | option << ' ' if option!='' |
|
80 | option << ' ' if option!='' |
|
81 | option << link_to_unless_current(label, |
|
81 | option << link_to_unless_current(label, |
|
82 | :controller => controller, |
|
82 | :controller => controller, |
|
83 | :action => action) |
|
83 | :action => action) |
|
84 | end |
|
84 | end |
|
85 |
|
85 | ||
|
86 | def format_short_time(time) |
|
86 | def format_short_time(time) |
|
87 | now = Time.now.gmtime |
|
87 | now = Time.now.gmtime |
|
88 | st = '' |
|
88 | st = '' |
|
89 | if (time.yday != now.yday) or |
|
89 | if (time.yday != now.yday) or |
|
90 | (time.year != now.year) |
|
90 | (time.year != now.year) |
|
91 | st = time.strftime("%x ") |
|
91 | st = time.strftime("%x ") |
|
92 | end |
|
92 | end |
|
93 | st + time.strftime("%X") |
|
93 | st + time.strftime("%X") |
|
94 | end |
|
94 | end |
|
95 |
|
95 | ||
|
96 | def format_short_duration(duration) |
|
96 | def format_short_duration(duration) |
|
97 | return '' if duration==nil |
|
97 | return '' if duration==nil |
|
98 | d = duration.to_f |
|
98 | d = duration.to_f |
|
99 | return Time.at(d).gmtime.strftime("%X") |
|
99 | return Time.at(d).gmtime.strftime("%X") |
|
100 | end |
|
100 | end |
|
101 |
|
101 | ||
|
102 | def read_textfile(fname,max_size=2048) |
|
102 | def read_textfile(fname,max_size=2048) |
|
103 | begin |
|
103 | begin |
|
104 | File.open(fname).read(max_size) |
|
104 | File.open(fname).read(max_size) |
|
105 | rescue |
|
105 | rescue |
|
106 | nil |
|
106 | nil |
|
107 | end |
|
107 | end |
|
108 | end |
|
108 | end |
|
109 |
|
109 | ||
|
|
110 | + def problem_select(problems, options = {}) | ||
|
|
111 | + prefix = options[:with_specific_in_header] ? [[(t 'main.specified_in_header'),'-1']] : [] | ||
|
|
112 | + selected = options[:selected] || (options[:with_specific_in_header] ? -1 : nil) | ||
|
|
113 | + puts "selected = #{selected} hehe" | ||
|
|
114 | + html_options = {class: 'select2 form-control'} | ||
|
|
115 | + html_options[:id] = options[:id]if options[:id] | ||
|
|
116 | + select 'submission', | ||
|
|
117 | + 'problem_id', prefix + problems.collect {|p| ["[#{p.name}] #{p.full_name}", p.id]}, | ||
|
|
118 | + (selected ? { selected: "#{selected}"} : {} ), | ||
|
|
119 | + html_options | ||
|
|
120 | + end | ||
|
|
121 | + | ||
|
110 | def user_title_bar(user) |
|
122 | def user_title_bar(user) |
|
111 | header = '' |
|
123 | header = '' |
|
112 | time_left = '' |
|
124 | time_left = '' |
|
113 |
|
125 | ||
|
114 | # |
|
126 | # |
|
115 | # if the contest is over |
|
127 | # if the contest is over |
|
116 | if GraderConfiguration.time_limit_mode? |
|
128 | if GraderConfiguration.time_limit_mode? |
|
117 | if user.contest_finished? |
|
129 | if user.contest_finished? |
|
118 | header = <<CONTEST_OVER |
|
130 | header = <<CONTEST_OVER |
|
119 | <tr><td colspan="2" align="center"> |
|
131 | <tr><td colspan="2" align="center"> |
|
120 | <span class="contest-over-msg">THE CONTEST IS OVER</span> |
|
132 | <span class="contest-over-msg">THE CONTEST IS OVER</span> |
|
121 | </td></tr> |
|
133 | </td></tr> |
|
122 | CONTEST_OVER |
|
134 | CONTEST_OVER |
|
123 | end |
|
135 | end |
|
124 | if !user.contest_started? |
|
136 | if !user.contest_started? |
|
125 | time_left = " " + (t 'title_bar.contest_not_started') |
|
137 | time_left = " " + (t 'title_bar.contest_not_started') |
|
126 | else |
|
138 | else |
|
127 | time_left = " " + (t 'title_bar.remaining_time') + |
|
139 | time_left = " " + (t 'title_bar.remaining_time') + |
|
128 | " #{format_short_duration(user.contest_time_left)}" |
|
140 | " #{format_short_duration(user.contest_time_left)}" |
|
129 | end |
|
141 | end |
|
130 | end |
|
142 | end |
|
131 |
|
143 | ||
|
132 | # |
|
144 | # |
|
133 | # if the contest is in the anaysis mode |
|
145 | # if the contest is in the anaysis mode |
|
134 | if GraderConfiguration.analysis_mode? |
|
146 | if GraderConfiguration.analysis_mode? |
|
135 | header = <<ANALYSISMODE |
|
147 | header = <<ANALYSISMODE |
|
136 | <tr><td colspan="2" align="center"> |
|
148 | <tr><td colspan="2" align="center"> |
|
137 | <span class="contest-over-msg">ANALYSIS MODE</span> |
|
149 | <span class="contest-over-msg">ANALYSIS MODE</span> |
|
138 | </td></tr> |
|
150 | </td></tr> |
|
139 | ANALYSISMODE |
|
151 | ANALYSISMODE |
|
140 | end |
|
152 | end |
|
141 |
|
153 | ||
|
142 | contest_name = GraderConfiguration['contest.name'] |
|
154 | contest_name = GraderConfiguration['contest.name'] |
|
143 |
|
155 | ||
|
144 | # |
|
156 | # |
|
145 | # build real title bar |
|
157 | # build real title bar |
|
146 | result = <<TITLEBAR |
|
158 | result = <<TITLEBAR |
|
147 | <div class="title"> |
|
159 | <div class="title"> |
|
148 | <table> |
|
160 | <table> |
|
149 | #{header} |
|
161 | #{header} |
|
150 | <tr> |
|
162 | <tr> |
|
151 | <td class="left-col"> |
|
163 | <td class="left-col"> |
|
152 | #{user.full_name}<br/> |
|
164 | #{user.full_name}<br/> |
|
153 | #{t 'title_bar.current_time'} #{format_short_time(Time.zone.now)} |
|
165 | #{t 'title_bar.current_time'} #{format_short_time(Time.zone.now)} |
|
154 | #{time_left} |
|
166 | #{time_left} |
|
155 | <br/> |
|
167 | <br/> |
|
156 | </td> |
|
168 | </td> |
|
157 | <td class="right-col">#{contest_name}</td> |
|
169 | <td class="right-col">#{contest_name}</td> |
|
158 | </tr> |
|
170 | </tr> |
|
159 | </table> |
|
171 | </table> |
|
160 | </div> |
|
172 | </div> |
|
161 | TITLEBAR |
|
173 | TITLEBAR |
|
162 | result.html_safe |
|
174 | result.html_safe |
|
163 | end |
|
175 | end |
|
164 |
|
176 | ||
|
165 | def markdown(text) |
|
177 | def markdown(text) |
|
166 | markdown = RDiscount.new(text) |
|
178 | markdown = RDiscount.new(text) |
|
167 | markdown.to_html.html_safe |
|
179 | markdown.to_html.html_safe |
|
168 | end |
|
180 | end |
|
169 |
|
181 | ||
|
170 | end |
|
182 | end |
@@ -1,20 +1,20 | |||||
|
1 | = form_tag({:action => 'submit'}, :multipart => true, class: 'form-inline') do |
|
1 | = form_tag({:action => 'submit'}, :multipart => true, class: 'form-inline') do |
|
2 | - if @submission and @submission.errors.any? |
|
2 | - if @submission and @submission.errors.any? |
|
3 | #error_explanation |
|
3 | #error_explanation |
|
4 | .alert.alert-danger |
|
4 | .alert.alert-danger |
|
5 | %h3= "#{pluralize(@submission.errors.count, "error")} prohibited this user from being saved:" |
|
5 | %h3= "#{pluralize(@submission.errors.count, "error")} prohibited this user from being saved:" |
|
6 | %ul |
|
6 | %ul |
|
7 | - @submission.errors.full_messages.each do |msg| |
|
7 | - @submission.errors.full_messages.each do |msg| |
|
8 | %li= msg |
|
8 | %li= msg |
|
9 | .form-group |
|
9 | .form-group |
|
10 | = label_tag :submission, 'Problem:' |
|
10 | = label_tag :submission, 'Problem:' |
|
11 | - = select 'submission', 'problem_id', [[(t 'main.specified_in_header'),'-1']] + @problems.collect {|p| [p.full_name, p.id]}, {:selected => '-1'}, { class: 'select2 form-control' } |
|
11 | + = select 'submission', 'problem_id', [[(t 'main.specified_in_header'),'-1']] + @problems.collect {|p| ["[#{p.name}] #{p.full_name}", p.id]}, {:selected => '-1'}, { class: 'select2 form-control' } |
|
12 | .form-group |
|
12 | .form-group |
|
13 | = label_tag :file, 'File:' |
|
13 | = label_tag :file, 'File:' |
|
14 | .input-group |
|
14 | .input-group |
|
15 | %span.input-group-btn |
|
15 | %span.input-group-btn |
|
16 | %span.btn.btn-default.btn-file |
|
16 | %span.btn.btn-default.btn-file |
|
17 | Browse |
|
17 | Browse |
|
18 | = file_field_tag 'file' |
|
18 | = file_field_tag 'file' |
|
19 | = text_field_tag '' , nil, {readonly: true, class: 'form-control'} |
|
19 | = text_field_tag '' , nil, {readonly: true, class: 'form-control'} |
|
20 | = submit_tag 'Submit', class: 'btn btn-default' |
|
20 | = submit_tag 'Submit', class: 'btn btn-default' |
@@ -1,25 +1,31 | |||||
|
1 | = user_title_bar(@user) |
|
1 | = user_title_bar(@user) |
|
2 |
|
2 | ||
|
3 | - .task-menu |
|
3 | + .panel.panel-info |
|
4 | - Task List |
|
4 | + .panel-heading |
|
5 | - %br/ |
|
5 | + Select Problems |
|
6 | - - @problems.each do |problem| |
|
6 | + .panel-body |
|
7 | - = link_to problem.name, :action => 'submission', :id => problem.name |
|
7 | + .form-inline |
|
|
8 | + = select 'submission', | ||
|
|
9 | + 'problem_id', | ||
|
|
10 | + @problems.collect {|p| ["[#{p.name}] #{p.full_name}", main_submission_url(p.id)]}, | ||
|
|
11 | + {:selected => '-1'}, | ||
|
|
12 | + { class: 'select2 form-control' } | ||
|
|
13 | + %button.btn.btn-primary.btn-sm#submission_problem_go Go | ||
|
8 |
|
14 | ||
|
9 | - if @problem!=nil |
|
15 | - if @problem!=nil |
|
10 | %h2= "Task: #{@problem.full_name} (#{@problem.name})" |
|
16 | %h2= "Task: #{@problem.full_name} (#{@problem.name})" |
|
11 |
|
17 | ||
|
12 | - if @submissions!=nil |
|
18 | - if @submissions!=nil |
|
13 | - if @submissions.length>0 |
|
19 | - if @submissions.length>0 |
|
14 | %table.info |
|
20 | %table.info |
|
15 | %tr.info-head |
|
21 | %tr.info-head |
|
16 | %th.info No. |
|
22 | %th.info No. |
|
17 | %th.info # |
|
23 | %th.info # |
|
18 | %th.info At |
|
24 | %th.info At |
|
19 | %th.info Source |
|
25 | %th.info Source |
|
20 | %th.info Result |
|
26 | %th.info Result |
|
21 | %th.info{:width => "300px"} |
|
27 | %th.info{:width => "300px"} |
|
22 | Compiler message |
|
28 | Compiler message |
|
23 | = render :partial => 'submission', :collection => @submissions |
|
29 | = render :partial => 'submission', :collection => @submissions |
|
24 | - else |
|
30 | - else |
|
25 | No submission |
|
31 | No submission |
@@ -1,29 +1,30 | |||||
|
1 | CafeGrader::Application.routes.draw do |
|
1 | CafeGrader::Application.routes.draw do |
|
2 | root :to => 'main#login' |
|
2 | root :to => 'main#login' |
|
3 |
|
3 | ||
|
4 | get "report/login" |
|
4 | get "report/login" |
|
5 |
|
5 | ||
|
6 | resources :contests |
|
6 | resources :contests |
|
7 |
|
7 | ||
|
8 | resources :announcements |
|
8 | resources :announcements |
|
9 | match 'announcements/toggle/:id' => 'announcements#toggle' |
|
9 | match 'announcements/toggle/:id' => 'announcements#toggle' |
|
10 |
|
10 | ||
|
11 | resources :sites |
|
11 | resources :sites |
|
12 |
|
12 | ||
|
13 | resources :problem |
|
13 | resources :problem |
|
14 |
|
14 | ||
|
15 | resources :grader_configuration, controller: 'configurations' |
|
15 | resources :grader_configuration, controller: 'configurations' |
|
16 |
|
16 | ||
|
17 | match 'tasks/view/:file.:ext' => 'tasks#view' |
|
17 | match 'tasks/view/:file.:ext' => 'tasks#view' |
|
18 | match 'tasks/download/:id/:file.:ext' => 'tasks#download' |
|
18 | match 'tasks/download/:id/:file.:ext' => 'tasks#download' |
|
19 | match 'heartbeat/:id/edit' => 'heartbeat#edit' |
|
19 | match 'heartbeat/:id/edit' => 'heartbeat#edit' |
|
20 |
|
20 | ||
|
21 | #main |
|
21 | #main |
|
22 | get "main/list" |
|
22 | get "main/list" |
|
|
23 | + get 'main/submission(/:id)', to: 'main#submission', as: 'main_submission' | ||
|
23 |
|
24 | ||
|
24 | # See how all your routes lay out with "rake routes" |
|
25 | # See how all your routes lay out with "rake routes" |
|
25 |
|
26 | ||
|
26 | # This is a legacy wild controller route that's not recommended for RESTful applications. |
|
27 | # This is a legacy wild controller route that's not recommended for RESTful applications. |
|
27 | # Note: This route will make all actions in every controller accessible via GET requests. |
|
28 | # Note: This route will make all actions in every controller accessible via GET requests. |
|
28 | match ':controller(/:action(/:id))(.:format)' |
|
29 | match ':controller(/:action(/:id))(.:format)' |
|
29 | end |
|
30 | end |
You need to be logged in to leave comments.
Login now