Description:
- add problem manage toggle test interface
- remove old erb file
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r569:47e6e54a036a - - 6 files changed: 28 inserted, 171 deleted
@@ -1,274 +1,282 | |||||
|
1 | class ProblemsController < ApplicationController |
|
1 | class ProblemsController < ApplicationController |
|
2 |
|
2 | ||
|
3 | before_filter :authenticate, :authorization |
|
3 | before_filter :authenticate, :authorization |
|
4 |
|
4 | ||
|
5 | in_place_edit_for :problem, :name |
|
5 | in_place_edit_for :problem, :name |
|
6 | in_place_edit_for :problem, :full_name |
|
6 | in_place_edit_for :problem, :full_name |
|
7 | in_place_edit_for :problem, :full_score |
|
7 | in_place_edit_for :problem, :full_score |
|
8 |
|
8 | ||
|
9 | def index |
|
9 | def index |
|
10 | @problems = Problem.find(:all, :order => 'date_added DESC') |
|
10 | @problems = Problem.find(:all, :order => 'date_added DESC') |
|
11 | end |
|
11 | end |
|
12 |
|
12 | ||
|
13 | # GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html) |
|
13 | # GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html) |
|
14 | verify :method => :post, :only => [ :destroy, |
|
14 | verify :method => :post, :only => [ :destroy, |
|
15 | :create, :quick_create, |
|
15 | :create, :quick_create, |
|
16 | :do_manage, |
|
16 | :do_manage, |
|
17 | :do_import, |
|
17 | :do_import, |
|
18 | :update ], |
|
18 | :update ], |
|
19 | :redirect_to => { :action => :index } |
|
19 | :redirect_to => { :action => :index } |
|
20 |
|
20 | ||
|
21 | def show |
|
21 | def show |
|
22 | @problem = Problem.find(params[:id]) |
|
22 | @problem = Problem.find(params[:id]) |
|
23 | end |
|
23 | end |
|
24 |
|
24 | ||
|
25 | def new |
|
25 | def new |
|
26 | @problem = Problem.new |
|
26 | @problem = Problem.new |
|
27 | @description = nil |
|
27 | @description = nil |
|
28 | end |
|
28 | end |
|
29 |
|
29 | ||
|
30 | def create |
|
30 | def create |
|
31 | @problem = Problem.new(params[:problem]) |
|
31 | @problem = Problem.new(params[:problem]) |
|
32 | @description = Description.new(params[:description]) |
|
32 | @description = Description.new(params[:description]) |
|
33 | if @description.body!='' |
|
33 | if @description.body!='' |
|
34 | if !@description.save |
|
34 | if !@description.save |
|
35 | render :action => new and return |
|
35 | render :action => new and return |
|
36 | end |
|
36 | end |
|
37 | else |
|
37 | else |
|
38 | @description = nil |
|
38 | @description = nil |
|
39 | end |
|
39 | end |
|
40 | @problem.description = @description |
|
40 | @problem.description = @description |
|
41 | if @problem.save |
|
41 | if @problem.save |
|
42 | flash[:notice] = 'Problem was successfully created.' |
|
42 | flash[:notice] = 'Problem was successfully created.' |
|
43 | redirect_to action: :index |
|
43 | redirect_to action: :index |
|
44 | else |
|
44 | else |
|
45 | render :action => 'new' |
|
45 | render :action => 'new' |
|
46 | end |
|
46 | end |
|
47 | end |
|
47 | end |
|
48 |
|
48 | ||
|
49 | def quick_create |
|
49 | def quick_create |
|
50 | @problem = Problem.new(params[:problem]) |
|
50 | @problem = Problem.new(params[:problem]) |
|
51 | @problem.full_name = @problem.name if @problem.full_name == '' |
|
51 | @problem.full_name = @problem.name if @problem.full_name == '' |
|
52 | @problem.full_score = 100 |
|
52 | @problem.full_score = 100 |
|
53 | @problem.available = false |
|
53 | @problem.available = false |
|
54 | @problem.test_allowed = true |
|
54 | @problem.test_allowed = true |
|
55 | @problem.output_only = false |
|
55 | @problem.output_only = false |
|
56 | @problem.date_added = Time.new |
|
56 | @problem.date_added = Time.new |
|
57 | if @problem.save |
|
57 | if @problem.save |
|
58 | flash[:notice] = 'Problem was successfully created.' |
|
58 | flash[:notice] = 'Problem was successfully created.' |
|
59 | redirect_to action: :index |
|
59 | redirect_to action: :index |
|
60 | else |
|
60 | else |
|
61 | flash[:notice] = 'Error saving problem' |
|
61 | flash[:notice] = 'Error saving problem' |
|
62 | redirect_to action: :index |
|
62 | redirect_to action: :index |
|
63 | end |
|
63 | end |
|
64 | end |
|
64 | end |
|
65 |
|
65 | ||
|
66 | def edit |
|
66 | def edit |
|
67 | @problem = Problem.find(params[:id]) |
|
67 | @problem = Problem.find(params[:id]) |
|
68 | @description = @problem.description |
|
68 | @description = @problem.description |
|
69 | end |
|
69 | end |
|
70 |
|
70 | ||
|
71 | def update |
|
71 | def update |
|
72 | @problem = Problem.find(params[:id]) |
|
72 | @problem = Problem.find(params[:id]) |
|
73 | @description = @problem.description |
|
73 | @description = @problem.description |
|
74 | if @description == nil and params[:description][:body]!='' |
|
74 | if @description == nil and params[:description][:body]!='' |
|
75 | @description = Description.new(params[:description]) |
|
75 | @description = Description.new(params[:description]) |
|
76 | if !@description.save |
|
76 | if !@description.save |
|
77 | flash[:notice] = 'Error saving description' |
|
77 | flash[:notice] = 'Error saving description' |
|
78 | render :action => 'edit' and return |
|
78 | render :action => 'edit' and return |
|
79 | end |
|
79 | end |
|
80 | @problem.description = @description |
|
80 | @problem.description = @description |
|
81 | elsif @description!=nil |
|
81 | elsif @description!=nil |
|
82 | if !@description.update_attributes(params[:description]) |
|
82 | if !@description.update_attributes(params[:description]) |
|
83 | flash[:notice] = 'Error saving description' |
|
83 | flash[:notice] = 'Error saving description' |
|
84 | render :action => 'edit' and return |
|
84 | render :action => 'edit' and return |
|
85 | end |
|
85 | end |
|
86 | end |
|
86 | end |
|
87 | if params[:file] and params[:file].content_type != 'application/pdf' |
|
87 | if params[:file] and params[:file].content_type != 'application/pdf' |
|
88 | flash[:notice] = 'Error: Uploaded file is not PDF' |
|
88 | flash[:notice] = 'Error: Uploaded file is not PDF' |
|
89 | render :action => 'edit' and return |
|
89 | render :action => 'edit' and return |
|
90 | end |
|
90 | end |
|
91 | if @problem.update_attributes(params[:problem]) |
|
91 | if @problem.update_attributes(params[:problem]) |
|
92 | flash[:notice] = 'Problem was successfully updated.' |
|
92 | flash[:notice] = 'Problem was successfully updated.' |
|
93 | unless params[:file] == nil or params[:file] == '' |
|
93 | unless params[:file] == nil or params[:file] == '' |
|
94 | flash[:notice] = 'Problem was successfully updated and a new PDF file is uploaded.' |
|
94 | flash[:notice] = 'Problem was successfully updated and a new PDF file is uploaded.' |
|
95 | out_dirname = "#{Problem.download_file_basedir}/#{@problem.id}" |
|
95 | out_dirname = "#{Problem.download_file_basedir}/#{@problem.id}" |
|
96 | if not FileTest.exists? out_dirname |
|
96 | if not FileTest.exists? out_dirname |
|
97 | Dir.mkdir out_dirname |
|
97 | Dir.mkdir out_dirname |
|
98 | end |
|
98 | end |
|
99 |
|
99 | ||
|
100 | out_filename = "#{out_dirname}/#{@problem.name}.pdf" |
|
100 | out_filename = "#{out_dirname}/#{@problem.name}.pdf" |
|
101 | if FileTest.exists? out_filename |
|
101 | if FileTest.exists? out_filename |
|
102 | File.delete out_filename |
|
102 | File.delete out_filename |
|
103 | end |
|
103 | end |
|
104 |
|
104 | ||
|
105 | File.open(out_filename,"wb") do |file| |
|
105 | File.open(out_filename,"wb") do |file| |
|
106 | file.write(params[:file].read) |
|
106 | file.write(params[:file].read) |
|
107 | end |
|
107 | end |
|
108 | @problem.description_filename = "#{@problem.name}.pdf" |
|
108 | @problem.description_filename = "#{@problem.name}.pdf" |
|
109 | @problem.save |
|
109 | @problem.save |
|
110 | end |
|
110 | end |
|
111 | redirect_to :action => 'show', :id => @problem |
|
111 | redirect_to :action => 'show', :id => @problem |
|
112 | else |
|
112 | else |
|
113 | render :action => 'edit' |
|
113 | render :action => 'edit' |
|
114 | end |
|
114 | end |
|
115 | end |
|
115 | end |
|
116 |
|
116 | ||
|
117 | def destroy |
|
117 | def destroy |
|
118 | Problem.find(params[:id]).destroy |
|
118 | Problem.find(params[:id]).destroy |
|
119 | redirect_to action: :index |
|
119 | redirect_to action: :index |
|
120 | end |
|
120 | end |
|
121 |
|
121 | ||
|
122 | def toggle |
|
122 | def toggle |
|
123 | @problem = Problem.find(params[:id]) |
|
123 | @problem = Problem.find(params[:id]) |
|
124 | @problem.update_attributes(available: !(@problem.available) ) |
|
124 | @problem.update_attributes(available: !(@problem.available) ) |
|
125 | respond_to do |format| |
|
125 | respond_to do |format| |
|
126 | format.js { } |
|
126 | format.js { } |
|
127 | end |
|
127 | end |
|
128 | end |
|
128 | end |
|
129 |
|
129 | ||
|
|
130 | + def toggle_test | ||
|
|
131 | + @problem = Problem.find(params[:id]) | ||
|
|
132 | + @problem.update_attributes(test_allowed: !(@problem.test_allowed?) ) | ||
|
|
133 | + respond_to do |format| | ||
|
|
134 | + format.js { } | ||
|
|
135 | + end | ||
|
|
136 | + end | ||
|
|
137 | + | ||
|
130 | def turn_all_off |
|
138 | def turn_all_off |
|
131 | Problem.find(:all, |
|
139 | Problem.find(:all, |
|
132 | :conditions => "available = 1").each do |problem| |
|
140 | :conditions => "available = 1").each do |problem| |
|
133 | problem.available = false |
|
141 | problem.available = false |
|
134 | problem.save |
|
142 | problem.save |
|
135 | end |
|
143 | end |
|
136 | redirect_to action: :index |
|
144 | redirect_to action: :index |
|
137 | end |
|
145 | end |
|
138 |
|
146 | ||
|
139 | def turn_all_on |
|
147 | def turn_all_on |
|
140 | Problem.find(:all, |
|
148 | Problem.find(:all, |
|
141 | :conditions => "available = 0").each do |problem| |
|
149 | :conditions => "available = 0").each do |problem| |
|
142 | problem.available = true |
|
150 | problem.available = true |
|
143 | problem.save |
|
151 | problem.save |
|
144 | end |
|
152 | end |
|
145 | redirect_to action: :index |
|
153 | redirect_to action: :index |
|
146 | end |
|
154 | end |
|
147 |
|
155 | ||
|
148 | def stat |
|
156 | def stat |
|
149 | @problem = Problem.find(params[:id]) |
|
157 | @problem = Problem.find(params[:id]) |
|
150 | unless @problem.available or session[:admin] |
|
158 | unless @problem.available or session[:admin] |
|
151 | redirect_to :controller => 'main', :action => 'list' |
|
159 | redirect_to :controller => 'main', :action => 'list' |
|
152 | return |
|
160 | return |
|
153 | end |
|
161 | end |
|
154 | @submissions = Submission.includes(:user).where(problem_id: params[:id]).order(:user_id,:id) |
|
162 | @submissions = Submission.includes(:user).where(problem_id: params[:id]).order(:user_id,:id) |
|
155 |
|
163 | ||
|
156 | #stat summary |
|
164 | #stat summary |
|
157 | range =65 |
|
165 | range =65 |
|
158 | @histogram = { data: Array.new(range,0), summary: {} } |
|
166 | @histogram = { data: Array.new(range,0), summary: {} } |
|
159 | user = Hash.new(0) |
|
167 | user = Hash.new(0) |
|
160 | @submissions.find_each do |sub| |
|
168 | @submissions.find_each do |sub| |
|
161 | d = (DateTime.now.in_time_zone - sub.submitted_at) / 24 / 60 / 60 |
|
169 | d = (DateTime.now.in_time_zone - sub.submitted_at) / 24 / 60 / 60 |
|
162 | @histogram[:data][d.to_i] += 1 if d < range |
|
170 | @histogram[:data][d.to_i] += 1 if d < range |
|
163 | user[sub.user_id] = [user[sub.user_id], ((sub.try(:points) || 0) >= @problem.full_score) ? 1 : 0].max |
|
171 | user[sub.user_id] = [user[sub.user_id], ((sub.try(:points) || 0) >= @problem.full_score) ? 1 : 0].max |
|
164 | end |
|
172 | end |
|
165 | @histogram[:summary][:max] = [@histogram[:data].max,1].max |
|
173 | @histogram[:summary][:max] = [@histogram[:data].max,1].max |
|
166 |
|
174 | ||
|
167 | @summary = { attempt: user.count, solve: 0 } |
|
175 | @summary = { attempt: user.count, solve: 0 } |
|
168 | user.each_value { |v| @summary[:solve] += 1 if v == 1 } |
|
176 | user.each_value { |v| @summary[:solve] += 1 if v == 1 } |
|
169 | end |
|
177 | end |
|
170 |
|
178 | ||
|
171 | def manage |
|
179 | def manage |
|
172 | @problems = Problem.find(:all, :order => 'date_added DESC') |
|
180 | @problems = Problem.find(:all, :order => 'date_added DESC') |
|
173 | end |
|
181 | end |
|
174 |
|
182 | ||
|
175 | def do_manage |
|
183 | def do_manage |
|
176 | if params.has_key? 'change_date_added' |
|
184 | if params.has_key? 'change_date_added' |
|
177 | change_date_added |
|
185 | change_date_added |
|
178 | elsif params.has_key? 'add_to_contest' |
|
186 | elsif params.has_key? 'add_to_contest' |
|
179 | add_to_contest |
|
187 | add_to_contest |
|
180 | elsif params.has_key? 'enable_problem' |
|
188 | elsif params.has_key? 'enable_problem' |
|
181 | set_available(true) |
|
189 | set_available(true) |
|
182 | elsif params.has_key? 'disable_problem' |
|
190 | elsif params.has_key? 'disable_problem' |
|
183 | set_available(false) |
|
191 | set_available(false) |
|
184 | end |
|
192 | end |
|
185 | redirect_to :action => 'manage' |
|
193 | redirect_to :action => 'manage' |
|
186 | end |
|
194 | end |
|
187 |
|
195 | ||
|
188 | def import |
|
196 | def import |
|
189 | @allow_test_pair_import = allow_test_pair_import? |
|
197 | @allow_test_pair_import = allow_test_pair_import? |
|
190 | end |
|
198 | end |
|
191 |
|
199 | ||
|
192 | def do_import |
|
200 | def do_import |
|
193 | old_problem = Problem.find_by_name(params[:name]) |
|
201 | old_problem = Problem.find_by_name(params[:name]) |
|
194 | if !allow_test_pair_import? and params.has_key? :import_to_db |
|
202 | if !allow_test_pair_import? and params.has_key? :import_to_db |
|
195 | params.delete :import_to_db |
|
203 | params.delete :import_to_db |
|
196 | end |
|
204 | end |
|
197 | @problem, import_log = Problem.create_from_import_form_params(params, |
|
205 | @problem, import_log = Problem.create_from_import_form_params(params, |
|
198 | old_problem) |
|
206 | old_problem) |
|
199 |
|
207 | ||
|
200 | if !@problem.errors.empty? |
|
208 | if !@problem.errors.empty? |
|
201 | render :action => 'import' and return |
|
209 | render :action => 'import' and return |
|
202 | end |
|
210 | end |
|
203 |
|
211 | ||
|
204 | if old_problem!=nil |
|
212 | if old_problem!=nil |
|
205 | flash[:notice] = "The test data has been replaced for problem #{@problem.name}" |
|
213 | flash[:notice] = "The test data has been replaced for problem #{@problem.name}" |
|
206 | end |
|
214 | end |
|
207 | @log = import_log |
|
215 | @log = import_log |
|
208 | end |
|
216 | end |
|
209 |
|
217 | ||
|
210 | def remove_contest |
|
218 | def remove_contest |
|
211 | problem = Problem.find(params[:id]) |
|
219 | problem = Problem.find(params[:id]) |
|
212 | contest = Contest.find(params[:contest_id]) |
|
220 | contest = Contest.find(params[:contest_id]) |
|
213 | if problem!=nil and contest!=nil |
|
221 | if problem!=nil and contest!=nil |
|
214 | problem.contests.delete(contest) |
|
222 | problem.contests.delete(contest) |
|
215 | end |
|
223 | end |
|
216 | redirect_to :action => 'manage' |
|
224 | redirect_to :action => 'manage' |
|
217 | end |
|
225 | end |
|
218 |
|
226 | ||
|
219 | ################################## |
|
227 | ################################## |
|
220 | protected |
|
228 | protected |
|
221 |
|
229 | ||
|
222 | def allow_test_pair_import? |
|
230 | def allow_test_pair_import? |
|
223 | if defined? ALLOW_TEST_PAIR_IMPORT |
|
231 | if defined? ALLOW_TEST_PAIR_IMPORT |
|
224 | return ALLOW_TEST_PAIR_IMPORT |
|
232 | return ALLOW_TEST_PAIR_IMPORT |
|
225 | else |
|
233 | else |
|
226 | return false |
|
234 | return false |
|
227 | end |
|
235 | end |
|
228 | end |
|
236 | end |
|
229 |
|
237 | ||
|
230 | def change_date_added |
|
238 | def change_date_added |
|
231 | problems = get_problems_from_params |
|
239 | problems = get_problems_from_params |
|
232 | year = params[:date_added][:year].to_i |
|
240 | year = params[:date_added][:year].to_i |
|
233 | month = params[:date_added][:month].to_i |
|
241 | month = params[:date_added][:month].to_i |
|
234 | day = params[:date_added][:day].to_i |
|
242 | day = params[:date_added][:day].to_i |
|
235 | date = Date.new(year,month,day) |
|
243 | date = Date.new(year,month,day) |
|
236 | problems.each do |p| |
|
244 | problems.each do |p| |
|
237 | p.date_added = date |
|
245 | p.date_added = date |
|
238 | p.save |
|
246 | p.save |
|
239 | end |
|
247 | end |
|
240 | end |
|
248 | end |
|
241 |
|
249 | ||
|
242 | def add_to_contest |
|
250 | def add_to_contest |
|
243 | problems = get_problems_from_params |
|
251 | problems = get_problems_from_params |
|
244 | contest = Contest.find(params[:contest][:id]) |
|
252 | contest = Contest.find(params[:contest][:id]) |
|
245 | if contest!=nil and contest.enabled |
|
253 | if contest!=nil and contest.enabled |
|
246 | problems.each do |p| |
|
254 | problems.each do |p| |
|
247 | p.contests << contest |
|
255 | p.contests << contest |
|
248 | end |
|
256 | end |
|
249 | end |
|
257 | end |
|
250 | end |
|
258 | end |
|
251 |
|
259 | ||
|
252 | def set_available(avail) |
|
260 | def set_available(avail) |
|
253 | problems = get_problems_from_params |
|
261 | problems = get_problems_from_params |
|
254 | problems.each do |p| |
|
262 | problems.each do |p| |
|
255 | p.available = avail |
|
263 | p.available = avail |
|
256 | p.save |
|
264 | p.save |
|
257 | end |
|
265 | end |
|
258 | end |
|
266 | end |
|
259 |
|
267 | ||
|
260 | def get_problems_from_params |
|
268 | def get_problems_from_params |
|
261 | problems = [] |
|
269 | problems = [] |
|
262 | params.keys.each do |k| |
|
270 | params.keys.each do |k| |
|
263 | if k.index('prob-')==0 |
|
271 | if k.index('prob-')==0 |
|
264 | name, id, order = k.split('-') |
|
272 | name, id, order = k.split('-') |
|
265 | problems << Problem.find(id) |
|
273 | problems << Problem.find(id) |
|
266 | end |
|
274 | end |
|
267 | end |
|
275 | end |
|
268 | problems |
|
276 | problems |
|
269 | end |
|
277 | end |
|
270 |
|
278 | ||
|
271 | def get_problems_stat |
|
279 | def get_problems_stat |
|
272 | end |
|
280 | end |
|
273 |
|
281 | ||
|
274 | end |
|
282 | end |
@@ -1,70 +1,73 | |||||
|
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 | %a.navbar-brand{href: main_list_path} |
|
5 | %a.navbar-brand{href: main_list_path} |
|
6 | %span.glyphicon.glyphicon-home |
|
6 | %span.glyphicon.glyphicon-home |
|
7 | MAIN |
|
7 | MAIN |
|
8 | .collapse.navbar-collapse |
|
8 | .collapse.navbar-collapse |
|
9 | %ul.nav.navbar-nav |
|
9 | %ul.nav.navbar-nav |
|
10 | - if (@current_user!=nil) and (GraderConfiguration.show_tasks_to?(@current_user)) |
|
10 | - if (@current_user!=nil) and (GraderConfiguration.show_tasks_to?(@current_user)) |
|
11 | //= add_menu("#{I18n.t 'menu.tasks'}", 'tasks', 'list') |
|
11 | //= add_menu("#{I18n.t 'menu.tasks'}", 'tasks', 'list') |
|
12 | %li.dropdown |
|
12 | %li.dropdown |
|
13 | %a.dropdown-toggle{href: '#', data: {toggle:'dropdown'}, aria: {haspopup:"true", expanded:"false"}, role: "button"} |
|
13 | %a.dropdown-toggle{href: '#', data: {toggle:'dropdown'}, aria: {haspopup:"true", expanded:"false"}, role: "button"} |
|
14 | = "#{I18n.t 'menu.submissions'}" |
|
14 | = "#{I18n.t 'menu.submissions'}" |
|
15 | %span.caret |
|
15 | %span.caret |
|
16 | %ul.dropdown-menu |
|
16 | %ul.dropdown-menu |
|
17 | = add_menu("View", 'main', 'submission') |
|
17 | = add_menu("View", 'main', 'submission') |
|
18 | = add_menu("Self Test", 'test', 'index') |
|
18 | = add_menu("Self Test", 'test', 'index') |
|
19 | - if GraderConfiguration['right.user_hall_of_fame'] |
|
19 | - if GraderConfiguration['right.user_hall_of_fame'] |
|
20 | = add_menu("#{I18n.t 'menu.hall_of_fame'}", 'report', 'problem_hof') |
|
20 | = add_menu("#{I18n.t 'menu.hall_of_fame'}", 'report', 'problem_hof') |
|
21 | - if (@current_user!=nil) and (session[:admin]) |
|
21 | - if (@current_user!=nil) and (session[:admin]) |
|
22 | %li.dropdown |
|
22 | %li.dropdown |
|
23 | %a.dropdown-toggle{href: '#', data: {toggle:'dropdown'}, aria: {haspopup:"true", expanded:"false"}, role: "button"} |
|
23 | %a.dropdown-toggle{href: '#', data: {toggle:'dropdown'}, aria: {haspopup:"true", expanded:"false"}, role: "button"} |
|
24 | Manage |
|
24 | Manage |
|
25 | %span.caret |
|
25 | %span.caret |
|
26 | %ul.dropdown-menu |
|
26 | %ul.dropdown-menu |
|
27 | = add_menu( 'Announcements', 'announcements', 'index') |
|
27 | = add_menu( 'Announcements', 'announcements', 'index') |
|
28 | = add_menu( 'Problems', 'problems', 'index') |
|
28 | = add_menu( 'Problems', 'problems', 'index') |
|
29 | = add_menu( 'Users', 'user_admin', 'index') |
|
29 | = add_menu( 'Users', 'user_admin', 'index') |
|
30 | = add_menu( 'Graders', 'graders', 'list') |
|
30 | = add_menu( 'Graders', 'graders', 'list') |
|
31 | = add_menu( 'Message ', 'messages', 'console') |
|
31 | = add_menu( 'Message ', 'messages', 'console') |
|
32 | %li.divider{role: 'separator'} |
|
32 | %li.divider{role: 'separator'} |
|
33 | = add_menu( 'System config', 'configurations', 'index') |
|
33 | = add_menu( 'System config', 'configurations', 'index') |
|
34 | %li.divider{role: 'separator'} |
|
34 | %li.divider{role: 'separator'} |
|
35 | = add_menu( 'Sites', 'sites', 'index') |
|
35 | = add_menu( 'Sites', 'sites', 'index') |
|
36 | = add_menu( 'Contests', 'contest_management', 'index') |
|
36 | = add_menu( 'Contests', 'contest_management', 'index') |
|
37 | %li.dropdown |
|
37 | %li.dropdown |
|
38 | %a.dropdown-toggle{href: '#', data: {toggle:'dropdown'}, aria: {haspopup:"true", expanded:"false"}, role: "button"} |
|
38 | %a.dropdown-toggle{href: '#', data: {toggle:'dropdown'}, aria: {haspopup:"true", expanded:"false"}, role: "button"} |
|
39 | Report |
|
39 | Report |
|
40 | %span.caret |
|
40 | %span.caret |
|
41 | %ul.dropdown-menu |
|
41 | %ul.dropdown-menu |
|
42 | = add_menu( 'Results', 'user_admin', 'user_stat') |
|
42 | = add_menu( 'Results', 'user_admin', 'user_stat') |
|
43 | = add_menu( 'Report', 'report', 'multiple_login') |
|
43 | = add_menu( 'Report', 'report', 'multiple_login') |
|
44 | - %button.navbar-btn.btn.btn-default.btn-warning |
|
44 | + - if (ungraded = Submission.where('graded_at is null').where('submitted_at < ?', 1.minutes.ago).count) > 0 |
|
45 | - hahaha |
|
45 | + =link_to "#{ungraded} backlogs!", |
|
46 | - |
|
46 | + grader_list_path, |
|
|
47 | + class: 'navbar-btn btn btn-default btn-warning', data: {toggle: 'tooltip'},title: 'Number of ungraded submission' | ||
|
|
48 | + =link_to 'Contest Mode, time remain: 00:20:33',grader_list_path, | ||
|
|
49 | + class: 'navbar-btn btn btn-primary' | ||
|
47 |
|
50 | ||
|
48 | %ul.nav.navbar-nav.navbar-right |
|
51 | %ul.nav.navbar-nav.navbar-right |
|
49 | = add_menu("#{content_tag(:span,'',class: 'glyphicon glyphicon-question-sign')}".html_safe, 'main', 'help') |
|
52 | = add_menu("#{content_tag(:span,'',class: 'glyphicon glyphicon-question-sign')}".html_safe, 'main', 'help') |
|
50 | = add_menu("#{content_tag(:span,'',class: 'glyphicon glyphicon-comment')}".html_safe, 'messages', 'list', {title: I18n.t('menu.messages'), data: {toggle: 'tooltip'}}) |
|
53 | = add_menu("#{content_tag(:span,'',class: 'glyphicon glyphicon-comment')}".html_safe, 'messages', 'list', {title: I18n.t('menu.messages'), data: {toggle: 'tooltip'}}) |
|
51 | - if GraderConfiguration['system.user_setting_enabled'] |
|
54 | - if GraderConfiguration['system.user_setting_enabled'] |
|
52 | = add_menu("#{content_tag(:span,'',class: 'glyphicon glyphicon-cog')}".html_safe, 'users', 'index', {title: I18n.t('menu.settings'), data: {toggle: 'tooltip'}}) |
|
55 | = add_menu("#{content_tag(:span,'',class: 'glyphicon glyphicon-cog')}".html_safe, 'users', 'index', {title: I18n.t('menu.settings'), data: {toggle: 'tooltip'}}) |
|
53 | = 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'}}) |
|
56 | = 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'}}) |
|
54 |
|
57 | ||
|
55 | / |
|
58 | / |
|
56 | - if (@current_user!=nil) and (session[:admin]) |
|
59 | - if (@current_user!=nil) and (session[:admin]) |
|
57 | %nav.navbar.navbar-fixed-top.navbar-inverse.secondnavbar |
|
60 | %nav.navbar.navbar-fixed-top.navbar-inverse.secondnavbar |
|
58 | .container-fluid |
|
61 | .container-fluid |
|
59 | .collapse.navbar-collapse |
|
62 | .collapse.navbar-collapse |
|
60 | %ul.nav.navbar-nav |
|
63 | %ul.nav.navbar-nav |
|
61 | = add_menu( '[Announcements]', 'announcements', 'index') |
|
64 | = add_menu( '[Announcements]', 'announcements', 'index') |
|
62 | = add_menu( '[Msg console]', 'messages', 'console') |
|
65 | = add_menu( '[Msg console]', 'messages', 'console') |
|
63 | = add_menu( '[Problems]', 'problems', 'index') |
|
66 | = add_menu( '[Problems]', 'problems', 'index') |
|
64 | = add_menu( '[Users]', 'user_admin', 'index') |
|
67 | = add_menu( '[Users]', 'user_admin', 'index') |
|
65 | = add_menu( '[Results]', 'user_admin', 'user_stat') |
|
68 | = add_menu( '[Results]', 'user_admin', 'user_stat') |
|
66 | = add_menu( '[Report]', 'report', 'multiple_login') |
|
69 | = add_menu( '[Report]', 'report', 'multiple_login') |
|
67 | = add_menu( '[Graders]', 'graders', 'list') |
|
70 | = add_menu( '[Graders]', 'graders', 'list') |
|
68 | = add_menu( '[Contests]', 'contest_management', 'index') |
|
71 | = add_menu( '[Contests]', 'contest_management', 'index') |
|
69 | = add_menu( '[Sites]', 'sites', 'index') |
|
72 | = add_menu( '[Sites]', 'sites', 'index') |
|
70 | = add_menu( '[System config]', 'configurations', 'index') |
|
73 | = add_menu( '[System config]', 'configurations', 'index') |
@@ -1,47 +1,50 | |||||
|
1 | - content_for :head do |
|
1 | - content_for :head do |
|
2 | = stylesheet_link_tag 'problems' |
|
2 | = stylesheet_link_tag 'problems' |
|
3 | %h1 Listing problems |
|
3 | %h1 Listing problems |
|
4 | %p |
|
4 | %p |
|
5 | = link_to 'New problem', new_problem_path, class: 'btn btn-default btn-sm' |
|
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' |
|
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' |
|
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' |
|
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' |
|
9 | = link_to 'Turn on all problems', {:action => 'turn_all_on'}, class: 'btn btn-default btn-sm' |
|
10 | .submitbox |
|
10 | .submitbox |
|
11 | = form_tag :action => 'quick_create' do |
|
11 | = form_tag :action => 'quick_create' do |
|
12 | %b Quick New: |
|
12 | %b Quick New: |
|
13 | %label{:for => "problem_name"} Name |
|
13 | %label{:for => "problem_name"} Name |
|
14 | = text_field 'problem', 'name' |
|
14 | = text_field 'problem', 'name' |
|
15 | | |
|
15 | | |
|
16 | %label{:for => "problem_full_name"} Full name |
|
16 | %label{:for => "problem_full_name"} Full name |
|
17 | = text_field 'problem', 'full_name' |
|
17 | = text_field 'problem', 'full_name' |
|
18 | = submit_tag "Create" |
|
18 | = submit_tag "Create" |
|
19 | %table.table.table-condense.table-hover |
|
19 | %table.table.table-condense.table-hover |
|
20 | %thead |
|
20 | %thead |
|
21 | %th Name |
|
21 | %th Name |
|
22 | %th Full name |
|
22 | %th Full name |
|
23 | - %th Full score |
|
23 | + %th.text-right Full score |
|
24 | %th Date added |
|
24 | %th Date added |
|
25 | - %th Avail? |
|
25 | + %th.text-center |
|
26 | - %th Test? |
|
26 | + Avail? |
|
|
27 | + %sup{class: 'text-primary',data: {toggle: 'tooltip'}, title: 'Let user submits to this problem?' } [?] | ||
|
|
28 | + %th.text-center | ||
|
|
29 | + Test? | ||
|
|
30 | + %sup{class: 'text-primary',data: {toggle: 'tooltip'}, title: 'Let user uses test interface on this problem?' } [?] | ||
|
27 | - if GraderConfiguration.multicontests? |
|
31 | - if GraderConfiguration.multicontests? |
|
28 | %th Contests |
|
32 | %th Contests |
|
29 | - for problem in @problems |
|
33 | - for problem in @problems |
|
30 | %tr{:class => "#{(problem.available) ? "success" : "danger"}", :id => "prob-#{problem.id}", :name => "prob-#{problem.id}"} |
|
34 | %tr{:class => "#{(problem.available) ? "success" : "danger"}", :id => "prob-#{problem.id}", :name => "prob-#{problem.id}"} |
|
31 | - @problem=problem |
|
35 | - @problem=problem |
|
32 | %td= in_place_editor_field :problem, :name, {}, :rows=>1 |
|
36 | %td= in_place_editor_field :problem, :name, {}, :rows=>1 |
|
33 | %td= in_place_editor_field :problem, :full_name, {}, :rows=>1 |
|
37 | %td= in_place_editor_field :problem, :full_name, {}, :rows=>1 |
|
34 | - %td= in_place_editor_field :problem, :full_score, {}, :rows=>1 |
|
38 | + %td.text-right= in_place_editor_field :problem, :full_score, {}, :rows=>1 |
|
35 | %td= problem.date_added |
|
39 | %td= problem.date_added |
|
36 |
- %td= toggle_button(@problem.available?, |
|
40 | + %td= toggle_button(@problem.available?, toggle_problem_url(@problem), "problem-avail-#{@problem.id}") |
|
37 | - //%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: "problem-avail-#{@problem.id}", data: {remote: true, method: 'post' } } |
|
41 | + %td= toggle_button(@problem.test_allowed?, toggle_test_problem_url(@problem), "problem-test-#{@problem.id}") |
|
38 | - %td= problem.test_allowed |
|
||
|
39 | - if GraderConfiguration.multicontests? |
|
42 | - if GraderConfiguration.multicontests? |
|
40 | %td |
|
43 | %td |
|
41 | = problem.contests.collect { |c| c.name }.join(', ') |
|
44 | = problem.contests.collect { |c| c.name }.join(', ') |
|
42 | %td= link_to 'Stat', {:action => 'stat', :id => problem.id}, class: 'btn btn-info btn-xs btn-block' |
|
45 | %td= link_to 'Stat', {:action => 'stat', :id => problem.id}, class: 'btn btn-info btn-xs btn-block' |
|
43 | %td= link_to 'Show', {:action => 'show', :id => problem}, class: 'btn btn-info btn-xs btn-block' |
|
46 | %td= link_to 'Show', {:action => 'show', :id => problem}, class: 'btn btn-info btn-xs btn-block' |
|
44 | %td= link_to 'Edit', {:action => 'edit', :id => problem}, class: 'btn btn-info btn-xs btn-block' |
|
47 | %td= link_to 'Edit', {:action => 'edit', :id => problem}, class: 'btn btn-info btn-xs btn-block' |
|
45 | %td= link_to 'Destroy', { :action => 'destroy', :id => problem }, :confirm => 'Are you sure?', :method => :post, class: 'btn btn-danger btn-xs btn-block' |
|
48 | %td= link_to 'Destroy', { :action => 'destroy', :id => problem }, :confirm => 'Are you sure?', :method => :post, class: 'btn btn-danger btn-xs btn-block' |
|
46 | %br/ |
|
49 | %br/ |
|
47 | = link_to '[New problem]', :action => 'new' |
|
50 | = link_to '[New problem]', :action => 'new' |
@@ -1,63 +1,61 | |||||
|
1 | CafeGrader::Application.routes.draw do |
|
1 | CafeGrader::Application.routes.draw do |
|
2 | get "sources/direct_edit" |
|
2 | get "sources/direct_edit" |
|
3 |
|
3 | ||
|
4 | root :to => 'main#login' |
|
4 | root :to => 'main#login' |
|
5 |
|
5 | ||
|
6 | - |
|
||
|
7 | resources :contests |
|
6 | resources :contests |
|
8 |
|
7 | ||
|
9 | resources :sites |
|
8 | resources :sites |
|
10 |
|
9 | ||
|
11 | resources :announcements do |
|
10 | resources :announcements do |
|
12 | member do |
|
11 | member do |
|
13 | get 'toggle','toggle_front' |
|
12 | get 'toggle','toggle_front' |
|
14 | end |
|
13 | end |
|
15 | end |
|
14 | end |
|
16 |
|
15 | ||
|
17 | - |
|
||
|
18 | resources :problems do |
|
16 | resources :problems do |
|
19 | member do |
|
17 | member do |
|
20 | get 'toggle' |
|
18 | get 'toggle' |
|
|
19 | + get 'toggle_test' | ||
|
21 | end |
|
20 | end |
|
22 | collection do |
|
21 | collection do |
|
23 | get 'turn_all_off' |
|
22 | get 'turn_all_off' |
|
24 | get 'turn_all_on' |
|
23 | get 'turn_all_on' |
|
25 | get 'import' |
|
24 | get 'import' |
|
26 | get 'manage' |
|
25 | get 'manage' |
|
27 | end |
|
26 | end |
|
28 | end |
|
27 | end |
|
29 |
|
28 | ||
|
30 | resources :grader_configuration, controller: 'configurations' |
|
29 | resources :grader_configuration, controller: 'configurations' |
|
31 |
|
30 | ||
|
32 | resources :users do |
|
31 | resources :users do |
|
33 | member do |
|
32 | member do |
|
34 | get 'toggle_activate', 'toggle_enable' |
|
33 | get 'toggle_activate', 'toggle_enable' |
|
35 | end |
|
34 | end |
|
36 | end |
|
35 | end |
|
37 |
|
36 | ||
|
38 | - #resources :sources do |
|
||
|
39 | - # collection do |
|
||
|
40 | - # end |
|
||
|
41 | - #end |
|
||
|
42 | get 'sources/direct_edit/:pid', to: 'sources#direct_edit', as: 'direct_edit' |
|
37 | get 'sources/direct_edit/:pid', to: 'sources#direct_edit', as: 'direct_edit' |
|
43 | get 'sources/direct_edit_submission/:sid', to: 'sources#direct_edit_submission', as: 'direct_edit_submission' |
|
38 | get 'sources/direct_edit_submission/:sid', to: 'sources#direct_edit_submission', as: 'direct_edit_submission' |
|
44 |
|
39 | ||
|
45 |
|
40 | ||
|
46 | match 'tasks/view/:file.:ext' => 'tasks#view' |
|
41 | match 'tasks/view/:file.:ext' => 'tasks#view' |
|
47 | match 'tasks/download/:id/:file.:ext' => 'tasks#download' |
|
42 | match 'tasks/download/:id/:file.:ext' => 'tasks#download' |
|
48 | match 'heartbeat/:id/edit' => 'heartbeat#edit' |
|
43 | match 'heartbeat/:id/edit' => 'heartbeat#edit' |
|
49 |
|
44 | ||
|
50 | #main |
|
45 | #main |
|
51 | get "main/list" |
|
46 | get "main/list" |
|
52 | get 'main/submission(/:id)', to: 'main#submission', as: 'main_submission' |
|
47 | get 'main/submission(/:id)', to: 'main#submission', as: 'main_submission' |
|
53 |
|
48 | ||
|
54 | #report |
|
49 | #report |
|
55 | get 'report/problem_hof(/:id)', to: 'report#problem_hof', as: 'report_problem_hof' |
|
50 | get 'report/problem_hof(/:id)', to: 'report#problem_hof', as: 'report_problem_hof' |
|
56 | get "report/login" |
|
51 | get "report/login" |
|
57 |
|
52 | ||
|
|
53 | + #grader | ||
|
|
54 | + get 'graders/list', to: 'graders#list', as: 'grader_list' | ||
|
|
55 | + | ||
|
58 | # See how all your routes lay out with "rake routes" |
|
56 | # See how all your routes lay out with "rake routes" |
|
59 |
|
57 | ||
|
60 | # This is a legacy wild controller route that's not recommended for RESTful applications. |
|
58 | # This is a legacy wild controller route that's not recommended for RESTful applications. |
|
61 | # Note: This route will make all actions in every controller accessible via GET requests. |
|
59 | # Note: This route will make all actions in every controller accessible via GET requests. |
|
62 | match ':controller(/:action(/:id))(.:format)' |
|
60 | match ':controller(/:action(/:id))(.:format)' |
|
63 | end |
|
61 | end |
deleted file |
deleted file |
You need to be logged in to leave comments.
Login now