Description:
- update show max score
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r594:ad5ce58ac280 - - 4 files changed: 69 inserted, 17 deleted
new file 100644 |
@@ -1,433 +1,442 | |||
|
1 | 1 | class ReportController < ApplicationController |
|
2 | 2 | |
|
3 | 3 | before_filter :admin_authorization, only: [:login_stat,:submission_stat, :stuck, :cheat_report, :cheat_scruntinize] |
|
4 | 4 | |
|
5 | 5 | before_filter(only: [:problem_hof]) { |c| |
|
6 | 6 | return false unless authenticate |
|
7 | 7 | |
|
8 | 8 | if GraderConfiguration["right.user_view_submission"] |
|
9 | 9 | return true; |
|
10 | 10 | end |
|
11 | 11 | |
|
12 | 12 | admin_authorization |
|
13 | 13 | } |
|
14 | 14 | |
|
15 | + def max_score | |
|
16 | + end | |
|
17 | + | |
|
15 | 18 | def show_max_score |
|
19 | + #process parameters | |
|
20 | + #problems | |
|
21 | + @problems = [] | |
|
22 | + params[:problem_id].each do |id| | |
|
23 | + next unless id.strip != "" | |
|
24 | + @problems << Problem.find(id.to_i) | |
|
16 | 25 | end |
|
17 | 26 | |
|
18 | - def get_max_score | |
|
19 | - #process list of problems | |
|
20 | - | |
|
21 | - #process submission range | |
|
22 | - if params[:commit] == 'download csv' | |
|
23 | - @problems = Problem.all | |
|
27 | + #users | |
|
28 | + @users = if params[:user] == "all" then | |
|
29 | + User.find(:all, :include => [:contests, :contest_stat]) | |
|
24 | 30 | else |
|
25 | - @problems = Problem.find_available_problems | |
|
31 | + User.includes(:contests).includes(:contest_stat).where(enabled: true) | |
|
26 | 32 | end |
|
27 | - @users = User.find(:all, :include => [:contests, :contest_stat]) | |
|
33 | + | |
|
34 | + #set up range from param | |
|
35 | + since_id = params.fetch(:min_id, 0).to_i | |
|
36 | + until_id = params.fetch(:max_id, 0).to_i | |
|
37 | + | |
|
38 | + #get data | |
|
28 | 39 | @scorearray = Array.new |
|
29 | - #set up range from param | |
|
30 | - since_id = params.fetch(:since_id, 0).to_i | |
|
31 | - until_id = params.fetch(:until_id, 0).to_i | |
|
32 | 40 | @users.each do |u| |
|
33 | 41 | ustat = Array.new |
|
34 | 42 | ustat[0] = u |
|
35 | 43 | @problems.each do |p| |
|
36 | 44 | max_points = 0 |
|
37 | 45 | Submission.find_in_range_by_user_and_problem(u.id,p.id,since_id,until_id).each do |sub| |
|
38 | 46 | max_points = sub.points if sub and sub.points and (sub.points > max_points) |
|
39 | 47 | end |
|
40 | 48 | ustat << [(max_points.to_f*100/p.full_score).round, (max_points>=p.full_score)] |
|
41 | 49 | end |
|
42 | 50 | @scorearray << ustat |
|
43 | 51 | end |
|
44 | 52 | |
|
45 | 53 | if params[:commit] == 'download csv' then |
|
46 | 54 | csv = gen_csv_from_scorearray(@scorearray,@problems) |
|
47 | 55 | send_data csv, filename: 'max_score.csv' |
|
48 | 56 | else |
|
49 | - render template: 'user_admin/user_stat' | |
|
57 | + #render template: 'user_admin/user_stat' | |
|
58 | + render 'max_score' | |
|
50 | 59 | end |
|
51 | 60 | |
|
52 | 61 | end |
|
53 | 62 | |
|
54 | 63 | def score |
|
55 | 64 | if params[:commit] == 'download csv' |
|
56 | 65 | @problems = Problem.all |
|
57 | 66 | else |
|
58 | 67 | @problems = Problem.find_available_problems |
|
59 | 68 | end |
|
60 | 69 | @users = User.includes(:contests, :contest_stat).where(enabled: true) #find(:all, :include => [:contests, :contest_stat]).where(enabled: true) |
|
61 | 70 | @scorearray = Array.new |
|
62 | 71 | @users.each do |u| |
|
63 | 72 | ustat = Array.new |
|
64 | 73 | ustat[0] = u |
|
65 | 74 | @problems.each do |p| |
|
66 | 75 | sub = Submission.find_last_by_user_and_problem(u.id,p.id) |
|
67 | 76 | if (sub!=nil) and (sub.points!=nil) and p and p.full_score |
|
68 | 77 | ustat << [(sub.points.to_f*100/p.full_score).round, (sub.points>=p.full_score)] |
|
69 | 78 | else |
|
70 | 79 | ustat << [0,false] |
|
71 | 80 | end |
|
72 | 81 | end |
|
73 | 82 | @scorearray << ustat |
|
74 | 83 | end |
|
75 | 84 | if params[:commit] == 'download csv' then |
|
76 | 85 | csv = gen_csv_from_scorearray(@scorearray,@problems) |
|
77 | 86 | send_data csv, filename: 'last_score.csv' |
|
78 | 87 | else |
|
79 | 88 | render template: 'user_admin/user_stat' |
|
80 | 89 | end |
|
81 | 90 | |
|
82 | 91 | end |
|
83 | 92 | |
|
84 | 93 | def login_stat |
|
85 | 94 | @logins = Array.new |
|
86 | 95 | |
|
87 | 96 | date_and_time = '%Y-%m-%d %H:%M' |
|
88 | 97 | begin |
|
89 | 98 | md = params[:since_datetime].match(/(\d+)-(\d+)-(\d+) (\d+):(\d+)/) |
|
90 | 99 | @since_time = Time.zone.local(md[1].to_i,md[2].to_i,md[3].to_i,md[4].to_i,md[5].to_i) |
|
91 | 100 | rescue |
|
92 | 101 | @since_time = DateTime.new(1000,1,1) |
|
93 | 102 | end |
|
94 | 103 | begin |
|
95 | 104 | md = params[:until_datetime].match(/(\d+)-(\d+)-(\d+) (\d+):(\d+)/) |
|
96 | 105 | @until_time = Time.zone.local(md[1].to_i,md[2].to_i,md[3].to_i,md[4].to_i,md[5].to_i) |
|
97 | 106 | rescue |
|
98 | 107 | @until_time = DateTime.new(3000,1,1) |
|
99 | 108 | end |
|
100 | 109 | |
|
101 | 110 | User.all.each do |user| |
|
102 | 111 | @logins << { id: user.id, |
|
103 | 112 | login: user.login, |
|
104 | 113 | full_name: user.full_name, |
|
105 | 114 | count: Login.where("user_id = ? AND created_at >= ? AND created_at <= ?", |
|
106 | 115 | user.id,@since_time,@until_time) |
|
107 | 116 | .count(:id), |
|
108 | 117 | min: Login.where("user_id = ? AND created_at >= ? AND created_at <= ?", |
|
109 | 118 | user.id,@since_time,@until_time) |
|
110 | 119 | .minimum(:created_at), |
|
111 | 120 | max: Login.where("user_id = ? AND created_at >= ? AND created_at <= ?", |
|
112 | 121 | user.id,@since_time,@until_time) |
|
113 | 122 | .maximum(:created_at), |
|
114 | 123 | ip: Login.where("user_id = ? AND created_at >= ? AND created_at <= ?", |
|
115 | 124 | user.id,@since_time,@until_time) |
|
116 | 125 | .select(:ip_address).uniq |
|
117 | 126 | |
|
118 | 127 | } |
|
119 | 128 | end |
|
120 | 129 | end |
|
121 | 130 | |
|
122 | 131 | def submission_stat |
|
123 | 132 | |
|
124 | 133 | date_and_time = '%Y-%m-%d %H:%M' |
|
125 | 134 | begin |
|
126 | 135 | @since_time = DateTime.strptime(params[:since_datetime],date_and_time) |
|
127 | 136 | rescue |
|
128 | 137 | @since_time = DateTime.new(1000,1,1) |
|
129 | 138 | end |
|
130 | 139 | begin |
|
131 | 140 | @until_time = DateTime.strptime(params[:until_datetime],date_and_time) |
|
132 | 141 | rescue |
|
133 | 142 | @until_time = DateTime.new(3000,1,1) |
|
134 | 143 | end |
|
135 | 144 | |
|
136 | 145 | @submissions = {} |
|
137 | 146 | |
|
138 | 147 | User.find_each do |user| |
|
139 | 148 | @submissions[user.id] = { login: user.login, full_name: user.full_name, count: 0, sub: { } } |
|
140 | 149 | end |
|
141 | 150 | |
|
142 | 151 | Submission.where("submitted_at >= ? AND submitted_at <= ?",@since_time,@until_time).find_each do |s| |
|
143 | 152 | if @submissions[s.user_id] |
|
144 | 153 | if not @submissions[s.user_id][:sub].has_key?(s.problem_id) |
|
145 | 154 | a = Problem.find_by_id(s.problem_id) |
|
146 | 155 | @submissions[s.user_id][:sub][s.problem_id] = |
|
147 | 156 | { prob_name: (a ? a.full_name : '(NULL)'), |
|
148 | 157 | sub_ids: [s.id] } |
|
149 | 158 | else |
|
150 | 159 | @submissions[s.user_id][:sub][s.problem_id][:sub_ids] << s.id |
|
151 | 160 | end |
|
152 | 161 | @submissions[s.user_id][:count] += 1 |
|
153 | 162 | end |
|
154 | 163 | end |
|
155 | 164 | end |
|
156 | 165 | |
|
157 | 166 | def problem_hof |
|
158 | 167 | # gen problem list |
|
159 | 168 | @user = User.find(session[:user_id]) |
|
160 | 169 | @problems = @user.available_problems |
|
161 | 170 | |
|
162 | 171 | # get selected problems or the default |
|
163 | 172 | if params[:id] |
|
164 | 173 | begin |
|
165 | 174 | @problem = Problem.available.find(params[:id]) |
|
166 | 175 | rescue |
|
167 | 176 | redirect_to action: :problem_hof |
|
168 | 177 | flash[:notice] = 'Error: submissions for that problem are not viewable.' |
|
169 | 178 | return |
|
170 | 179 | end |
|
171 | 180 | end |
|
172 | 181 | |
|
173 | 182 | return unless @problem |
|
174 | 183 | |
|
175 | 184 | @by_lang = {} #aggregrate by language |
|
176 | 185 | |
|
177 | 186 | range =65 |
|
178 | 187 | @histogram = { data: Array.new(range,0), summary: {} } |
|
179 | 188 | @summary = {count: 0, solve: 0, attempt: 0} |
|
180 | 189 | user = Hash.new(0) |
|
181 | 190 | Submission.where(problem_id: @problem.id).find_each do |sub| |
|
182 | 191 | #histogram |
|
183 | 192 | d = (DateTime.now.in_time_zone - sub.submitted_at) / 24 / 60 / 60 |
|
184 | 193 | @histogram[:data][d.to_i] += 1 if d < range |
|
185 | 194 | |
|
186 | 195 | next unless sub.points |
|
187 | 196 | @summary[:count] += 1 |
|
188 | 197 | user[sub.user_id] = [user[sub.user_id], (sub.points >= @problem.full_score) ? 1 : 0].max |
|
189 | 198 | |
|
190 | 199 | lang = Language.find_by_id(sub.language_id) |
|
191 | 200 | next unless lang |
|
192 | 201 | next unless sub.points >= @problem.full_score |
|
193 | 202 | |
|
194 | 203 | #initialize |
|
195 | 204 | unless @by_lang.has_key?(lang.pretty_name) |
|
196 | 205 | @by_lang[lang.pretty_name] = { |
|
197 | 206 | runtime: { avail: false, value: 2**30-1 }, |
|
198 | 207 | memory: { avail: false, value: 2**30-1 }, |
|
199 | 208 | length: { avail: false, value: 2**30-1 }, |
|
200 | 209 | first: { avail: false, value: DateTime.new(3000,1,1) } |
|
201 | 210 | } |
|
202 | 211 | end |
|
203 | 212 | |
|
204 | 213 | if sub.max_runtime and sub.max_runtime < @by_lang[lang.pretty_name][:runtime][:value] |
|
205 | 214 | @by_lang[lang.pretty_name][:runtime] = { avail: true, user_id: sub.user_id, value: sub.max_runtime, sub_id: sub.id } |
|
206 | 215 | end |
|
207 | 216 | |
|
208 | 217 | if sub.peak_memory and sub.peak_memory < @by_lang[lang.pretty_name][:memory][:value] |
|
209 | 218 | @by_lang[lang.pretty_name][:memory] = { avail: true, user_id: sub.user_id, value: sub.peak_memory, sub_id: sub.id } |
|
210 | 219 | end |
|
211 | 220 | |
|
212 | 221 | if sub.submitted_at and sub.submitted_at < @by_lang[lang.pretty_name][:first][:value] and |
|
213 | 222 | !sub.user.admin? |
|
214 | 223 | @by_lang[lang.pretty_name][:first] = { avail: true, user_id: sub.user_id, value: sub.submitted_at, sub_id: sub.id } |
|
215 | 224 | end |
|
216 | 225 | |
|
217 | 226 | if @by_lang[lang.pretty_name][:length][:value] > sub.effective_code_length |
|
218 | 227 | @by_lang[lang.pretty_name][:length] = { avail: true, user_id: sub.user_id, value: sub.effective_code_length, sub_id: sub.id } |
|
219 | 228 | end |
|
220 | 229 | end |
|
221 | 230 | |
|
222 | 231 | #process user_id |
|
223 | 232 | @by_lang.each do |lang,prop| |
|
224 | 233 | prop.each do |k,v| |
|
225 | 234 | v[:user] = User.exists?(v[:user_id]) ? User.find(v[:user_id]).full_name : "(NULL)" |
|
226 | 235 | end |
|
227 | 236 | end |
|
228 | 237 | |
|
229 | 238 | #sum into best |
|
230 | 239 | if @by_lang and @by_lang.first |
|
231 | 240 | @best = @by_lang.first[1].clone |
|
232 | 241 | @by_lang.each do |lang,prop| |
|
233 | 242 | if @best[:runtime][:value] >= prop[:runtime][:value] |
|
234 | 243 | @best[:runtime] = prop[:runtime] |
|
235 | 244 | @best[:runtime][:lang] = lang |
|
236 | 245 | end |
|
237 | 246 | if @best[:memory][:value] >= prop[:memory][:value] |
|
238 | 247 | @best[:memory] = prop[:memory] |
|
239 | 248 | @best[:memory][:lang] = lang |
|
240 | 249 | end |
|
241 | 250 | if @best[:length][:value] >= prop[:length][:value] |
|
242 | 251 | @best[:length] = prop[:length] |
|
243 | 252 | @best[:length][:lang] = lang |
|
244 | 253 | end |
|
245 | 254 | if @best[:first][:value] >= prop[:first][:value] |
|
246 | 255 | @best[:first] = prop[:first] |
|
247 | 256 | @best[:first][:lang] = lang |
|
248 | 257 | end |
|
249 | 258 | end |
|
250 | 259 | end |
|
251 | 260 | |
|
252 | 261 | @histogram[:summary][:max] = [@histogram[:data].max,1].max |
|
253 | 262 | @summary[:attempt] = user.count |
|
254 | 263 | user.each_value { |v| @summary[:solve] += 1 if v == 1 } |
|
255 | 264 | end |
|
256 | 265 | |
|
257 | 266 | def stuck #report struggling user,problem |
|
258 | 267 | # init |
|
259 | 268 | user,problem = nil |
|
260 | 269 | solve = true |
|
261 | 270 | tries = 0 |
|
262 | 271 | @struggle = Array.new |
|
263 | 272 | record = {} |
|
264 | 273 | Submission.includes(:problem,:user).order(:problem_id,:user_id).find_each do |sub| |
|
265 | 274 | next unless sub.problem and sub.user |
|
266 | 275 | if user != sub.user_id or problem != sub.problem_id |
|
267 | 276 | @struggle << { user: record[:user], problem: record[:problem], tries: tries } unless solve |
|
268 | 277 | record = {user: sub.user, problem: sub.problem} |
|
269 | 278 | user,problem = sub.user_id, sub.problem_id |
|
270 | 279 | solve = false |
|
271 | 280 | tries = 0 |
|
272 | 281 | end |
|
273 | 282 | if sub.points >= sub.problem.full_score |
|
274 | 283 | solve = true |
|
275 | 284 | else |
|
276 | 285 | tries += 1 |
|
277 | 286 | end |
|
278 | 287 | end |
|
279 | 288 | @struggle.sort!{|a,b| b[:tries] <=> a[:tries] } |
|
280 | 289 | @struggle = @struggle[0..50] |
|
281 | 290 | end |
|
282 | 291 | |
|
283 | 292 | |
|
284 | 293 | def multiple_login |
|
285 | 294 | #user with multiple IP |
|
286 | 295 | raw = Submission.joins(:user).joins(:problem).where("problems.available != 0").group("login,ip_address").order(:login) |
|
287 | 296 | last,count = 0,0 |
|
288 | 297 | first = 0 |
|
289 | 298 | @users = [] |
|
290 | 299 | raw.each do |r| |
|
291 | 300 | if last != r.user.login |
|
292 | 301 | count = 1 |
|
293 | 302 | last = r.user.login |
|
294 | 303 | first = r |
|
295 | 304 | else |
|
296 | 305 | @users << first if count == 1 |
|
297 | 306 | @users << r |
|
298 | 307 | count += 1 |
|
299 | 308 | end |
|
300 | 309 | end |
|
301 | 310 | |
|
302 | 311 | #IP with multiple user |
|
303 | 312 | raw = Submission.joins(:user).joins(:problem).where("problems.available != 0").group("login,ip_address").order(:ip_address) |
|
304 | 313 | last,count = 0,0 |
|
305 | 314 | first = 0 |
|
306 | 315 | @ip = [] |
|
307 | 316 | raw.each do |r| |
|
308 | 317 | if last != r.ip_address |
|
309 | 318 | count = 1 |
|
310 | 319 | last = r.ip_address |
|
311 | 320 | first = r |
|
312 | 321 | else |
|
313 | 322 | @ip << first if count == 1 |
|
314 | 323 | @ip << r |
|
315 | 324 | count += 1 |
|
316 | 325 | end |
|
317 | 326 | end |
|
318 | 327 | end |
|
319 | 328 | |
|
320 | 329 | def cheat_report |
|
321 | 330 | date_and_time = '%Y-%m-%d %H:%M' |
|
322 | 331 | begin |
|
323 | 332 | md = params[:since_datetime].match(/(\d+)-(\d+)-(\d+) (\d+):(\d+)/) |
|
324 | 333 | @since_time = Time.zone.local(md[1].to_i,md[2].to_i,md[3].to_i,md[4].to_i,md[5].to_i) |
|
325 | 334 | rescue |
|
326 | 335 | @since_time = Time.zone.now.ago( 90.minutes) |
|
327 | 336 | end |
|
328 | 337 | begin |
|
329 | 338 | md = params[:until_datetime].match(/(\d+)-(\d+)-(\d+) (\d+):(\d+)/) |
|
330 | 339 | @until_time = Time.zone.local(md[1].to_i,md[2].to_i,md[3].to_i,md[4].to_i,md[5].to_i) |
|
331 | 340 | rescue |
|
332 | 341 | @until_time = Time.zone.now |
|
333 | 342 | end |
|
334 | 343 | |
|
335 | 344 | #multi login |
|
336 | 345 | @ml = Login.joins(:user).where("logins.created_at >= ? and logins.created_at <= ?",@since_time,@until_time).select('users.login,count(distinct ip_address) as count,users.full_name').group("users.id").having("count > 1") |
|
337 | 346 | |
|
338 | 347 | st = <<-SQL |
|
339 | 348 | SELECT l2.* |
|
340 | 349 | FROM logins l2 INNER JOIN |
|
341 | 350 | (SELECT u.id,COUNT(DISTINCT ip_address) as count,u.login,u.full_name |
|
342 | 351 | FROM logins l |
|
343 | 352 | INNER JOIN users u ON l.user_id = u.id |
|
344 | 353 | WHERE l.created_at >= '#{@since_time.in_time_zone("UTC")}' and l.created_at <= '#{@until_time.in_time_zone("UTC")}' |
|
345 | 354 | GROUP BY u.id |
|
346 | 355 | HAVING count > 1 |
|
347 | 356 | ) ml ON l2.user_id = ml.id |
|
348 | 357 | WHERE l2.created_at >= '#{@since_time.in_time_zone("UTC")}' and l2.created_at <= '#{@until_time.in_time_zone("UTC")}' |
|
349 | 358 | UNION |
|
350 | 359 | SELECT l2.* |
|
351 | 360 | FROM logins l2 INNER JOIN |
|
352 | 361 | (SELECT l.ip_address,COUNT(DISTINCT u.id) as count |
|
353 | 362 | FROM logins l |
|
354 | 363 | INNER JOIN users u ON l.user_id = u.id |
|
355 | 364 | WHERE l.created_at >= '#{@since_time.in_time_zone("UTC")}' and l.created_at <= '#{@until_time.in_time_zone("UTC")}' |
|
356 | 365 | GROUP BY l.ip_address |
|
357 | 366 | HAVING count > 1 |
|
358 | 367 | ) ml on ml.ip_address = l2.ip_address |
|
359 | 368 | INNER JOIN users u ON l2.user_id = u.id |
|
360 | 369 | WHERE l2.created_at >= '#{@since_time.in_time_zone("UTC")}' and l2.created_at <= '#{@until_time.in_time_zone("UTC")}' |
|
361 | 370 | ORDER BY ip_address,created_at |
|
362 | 371 | SQL |
|
363 | 372 | @mld = Login.find_by_sql(st) |
|
364 | 373 | |
|
365 | 374 | st = <<-SQL |
|
366 | 375 | SELECT s.id,s.user_id,s.ip_address,s.submitted_at,s.problem_id |
|
367 | 376 | FROM submissions s INNER JOIN |
|
368 | 377 | (SELECT u.id,COUNT(DISTINCT ip_address) as count,u.login,u.full_name |
|
369 | 378 | FROM logins l |
|
370 | 379 | INNER JOIN users u ON l.user_id = u.id |
|
371 | 380 | WHERE l.created_at >= ? and l.created_at <= ? |
|
372 | 381 | GROUP BY u.id |
|
373 | 382 | HAVING count > 1 |
|
374 | 383 | ) ml ON s.user_id = ml.id |
|
375 | 384 | WHERE s.submitted_at >= ? and s.submitted_at <= ? |
|
376 | 385 | UNION |
|
377 | 386 | SELECT s.id,s.user_id,s.ip_address,s.submitted_at,s.problem_id |
|
378 | 387 | FROM submissions s INNER JOIN |
|
379 | 388 | (SELECT l.ip_address,COUNT(DISTINCT u.id) as count |
|
380 | 389 | FROM logins l |
|
381 | 390 | INNER JOIN users u ON l.user_id = u.id |
|
382 | 391 | WHERE l.created_at >= ? and l.created_at <= ? |
|
383 | 392 | GROUP BY l.ip_address |
|
384 | 393 | HAVING count > 1 |
|
385 | 394 | ) ml on ml.ip_address = s.ip_address |
|
386 | 395 | WHERE s.submitted_at >= ? and s.submitted_at <= ? |
|
387 | 396 | ORDER BY ip_address,submitted_at |
|
388 | 397 | SQL |
|
389 | 398 | @subs = Submission.joins(:problem).find_by_sql([st,@since_time,@until_time, |
|
390 | 399 | @since_time,@until_time, |
|
391 | 400 | @since_time,@until_time, |
|
392 | 401 | @since_time,@until_time]) |
|
393 | 402 | |
|
394 | 403 | end |
|
395 | 404 | |
|
396 | 405 | def cheat_scruntinize |
|
397 | 406 | #convert date & time |
|
398 | 407 | date_and_time = '%Y-%m-%d %H:%M' |
|
399 | 408 | begin |
|
400 | 409 | md = params[:since_datetime].match(/(\d+)-(\d+)-(\d+) (\d+):(\d+)/) |
|
401 | 410 | @since_time = Time.zone.local(md[1].to_i,md[2].to_i,md[3].to_i,md[4].to_i,md[5].to_i) |
|
402 | 411 | rescue |
|
403 | 412 | @since_time = Time.zone.now.ago( 90.minutes) |
|
404 | 413 | end |
|
405 | 414 | begin |
|
406 | 415 | md = params[:until_datetime].match(/(\d+)-(\d+)-(\d+) (\d+):(\d+)/) |
|
407 | 416 | @until_time = Time.zone.local(md[1].to_i,md[2].to_i,md[3].to_i,md[4].to_i,md[5].to_i) |
|
408 | 417 | rescue |
|
409 | 418 | @until_time = Time.zone.now |
|
410 | 419 | end |
|
411 | 420 | |
|
412 | 421 | #convert sid |
|
413 | 422 | @sid = params[:SID].split(/[,\s]/) if params[:SID] |
|
414 | 423 | unless @sid and @sid.size > 0 |
|
415 | 424 | return |
|
416 | 425 | redirect_to actoin: :cheat_scruntinize |
|
417 | 426 | flash[:notice] = 'Please enter at least 1 student id' |
|
418 | 427 | end |
|
419 | 428 | mark = Array.new(@sid.size,'?') |
|
420 | 429 | condition = "(u.login = " + mark.join(' OR u.login = ') + ')' |
|
421 | 430 | |
|
422 | 431 | @st = <<-SQL |
|
423 | 432 | SELECT l.created_at as submitted_at ,-1 as id,u.login,u.full_name,l.ip_address,"" as problem_id,"" as points,l.user_id |
|
424 | 433 | FROM logins l INNER JOIN users u on l.user_id = u.id |
|
425 | 434 | WHERE l.created_at >= ? AND l.created_at <= ? AND #{condition} |
|
426 | 435 | UNION |
|
427 | 436 | SELECT s.submitted_at,s.id,u.login,u.full_name,s.ip_address,s.problem_id,s.points,s.user_id |
|
428 | 437 | FROM submissions s INNER JOIN users u ON s.user_id = u.id |
|
429 | 438 | WHERE s.submitted_at >= ? AND s.submitted_at <= ? AND #{condition} |
|
430 | 439 | ORDER BY submitted_at |
|
431 | 440 | SQL |
|
432 | 441 | |
|
433 | 442 | p = [@st,@since_time,@until_time] + @sid + [@since_time,@until_time] + @sid |
@@ -1,43 +1,85 | |||
|
1 | 1 | %h1 Maximum score |
|
2 | 2 | |
|
3 | - = form_tag report_max_score_path | |
|
3 | + = form_tag report_show_max_score_path | |
|
4 | 4 | .row |
|
5 | 5 | .col-md-4 |
|
6 | 6 | .panel.panel-primary |
|
7 | 7 | .panel-heading |
|
8 | 8 | Problems |
|
9 | 9 | .panel-body |
|
10 | - = label_tag :problems, "Problems" | |
|
11 | - = select 'problems', 'problem_id', [[(t 'main.specified_in_header'),'-1']] + Problem.all.collect {|p| ["[#{p.name}] #{p.full_name}", p.id]}, {:selected => '-1'}, { class: 'select2 form-control' } | |
|
10 | + %p | |
|
11 | + Select problem(s) that we wish to know the score. | |
|
12 | + = label_tag :problem_id, "Problems" | |
|
13 | + = select_tag 'problem_id[]', | |
|
14 | + options_for_select(Problem.all.collect {|p| ["[#{p.name}] #{p.full_name}", p.id]}), | |
|
15 | + { class: 'select2 form-control', multiple: "true" } | |
|
12 | 16 | .col-md-4 |
|
13 | 17 | .panel.panel-primary |
|
14 | 18 | .panel-heading |
|
15 | 19 | Submission range |
|
16 | 20 | .panel-body |
|
21 | + %p | |
|
22 | + Input minimum and maximum range of submission ID that should be included. A blank value for min and max means -1 and infinity, respectively. | |
|
17 | 23 | .form-group |
|
18 |
- = label_tag :from, " |
|
|
24 | + = label_tag :from, "Min" | |
|
19 | 25 | = text_field_tag 'from_id', nil, class: "form-control" |
|
20 | 26 | .form-group |
|
21 |
- = label_tag :from, " |
|
|
27 | + = label_tag :from, "Max" | |
|
22 | 28 | = text_field_tag 'to_id', nil, class: "form-control" |
|
23 | 29 | .col-md-4 |
|
24 | 30 | .panel.panel-primary |
|
25 | 31 | .panel-heading |
|
26 | 32 | Users |
|
27 | 33 | .panel-body |
|
28 | 34 | .radio |
|
29 | 35 | %label |
|
30 | 36 | = radio_button_tag 'users', 'all', true |
|
31 | 37 | All users |
|
32 | 38 | .radio |
|
33 | 39 | %label |
|
34 | 40 | = radio_button_tag 'users', 'enabled' |
|
35 | 41 | Only enabled users |
|
36 | 42 | .row |
|
37 | 43 | .col-md-12 |
|
38 | 44 | = button_tag 'Show', class: "btn btn-primary btn-large" |
|
39 | 45 | = button_tag 'Download CSV', class: "btn btn-primary btn-large" |
|
46 | + | |
|
47 | + - if @scorearray | |
|
48 | + %h2 Result | |
|
49 | + %table.table.sortable.table-striped.table-bordered.table-condensed | |
|
50 | + %thead | |
|
51 | + %tr | |
|
52 | + %th Login | |
|
53 | + %th Name | |
|
54 | + %th Activated? | |
|
55 | + %th Logged_in | |
|
56 | + %th Contest(s) | |
|
57 | + %th Remark | |
|
58 | + - @problems.each do |p| | |
|
59 | + %th.text-right= p.name | |
|
60 | + %th.text-right Total | |
|
61 | + %th.text-right Passed | |
|
62 | + %tbody | |
|
63 | + - @scorearray.each do |sc| | |
|
64 | + %tr | |
|
65 | + - total,num_passed = 0,0 | |
|
66 | + - sc.each_index do |i| | |
|
67 | + - if i == 0 | |
|
68 | + %td= link_to sc[i].login, controller: 'users', action: 'profile', id: sc[i] | |
|
69 | + %td= sc[i].full_name | |
|
70 | + %td= sc[i].activated | |
|
71 | + %td= sc[i].try(:contest_stat).try(:started_at) ? 'yes' : 'no' | |
|
72 | + %td= sc[i].contests.collect {|c| c.name}.join(', ') | |
|
73 | + %td= sc[i].remark | |
|
74 | + - else | |
|
75 | + %td.text-right= sc[i][0] | |
|
76 | + - total += sc[i][0] | |
|
77 | + - num_passed += 1 if sc[i][1] | |
|
78 | + %td.text-right= total | |
|
79 | + %td.text-right= num_passed | |
|
80 | + :javascript | |
|
81 | + $.bootstrapSortable(true,'reversed') | |
|
40 | 82 | /.col-md-4.col-md-offset-1 |
|
41 | 83 | / = button_tag 'Show', class: "btn btn-primary btn-block" |
|
42 | 84 | /.col-md-4.col-md-offset-2 |
|
43 | 85 | / = button_tag 'Download CSV', class: "btn btn-primary btn-block" |
@@ -1,67 +1,68 | |||
|
1 | 1 | CafeGrader::Application.routes.draw do |
|
2 | 2 | get "sources/direct_edit" |
|
3 | 3 | |
|
4 | 4 | root :to => 'main#login' |
|
5 | 5 | |
|
6 | 6 | resources :contests |
|
7 | 7 | |
|
8 | 8 | resources :sites |
|
9 | 9 | |
|
10 | 10 | resources :announcements do |
|
11 | 11 | member do |
|
12 | 12 | get 'toggle','toggle_front' |
|
13 | 13 | end |
|
14 | 14 | end |
|
15 | 15 | |
|
16 | 16 | resources :problems do |
|
17 | 17 | member do |
|
18 | 18 | get 'toggle' |
|
19 | 19 | get 'toggle_test' |
|
20 | 20 | end |
|
21 | 21 | collection do |
|
22 | 22 | get 'turn_all_off' |
|
23 | 23 | get 'turn_all_on' |
|
24 | 24 | get 'import' |
|
25 | 25 | get 'manage' |
|
26 | 26 | end |
|
27 | 27 | end |
|
28 | 28 | |
|
29 | 29 | resources :grader_configuration, controller: 'configurations' |
|
30 | 30 | |
|
31 | 31 | resources :users do |
|
32 | 32 | member do |
|
33 | 33 | get 'toggle_activate', 'toggle_enable' |
|
34 | 34 | end |
|
35 | 35 | end |
|
36 | 36 | |
|
37 | 37 | #source code edit |
|
38 | 38 | get 'sources/direct_edit/:pid', to: 'sources#direct_edit', as: 'direct_edit' |
|
39 | 39 | get 'sources/direct_edit_submission/:sid', to: 'sources#direct_edit_submission', as: 'direct_edit_submission' |
|
40 | 40 | get 'sources/get_latest_submission_status/:uid/:pid', to: 'sources#get_latest_submission_status', as: 'get_latest_submission_status' |
|
41 | 41 | |
|
42 | 42 | |
|
43 | 43 | match 'tasks/view/:file.:ext' => 'tasks#view' |
|
44 | 44 | match 'tasks/download/:id/:file.:ext' => 'tasks#download' |
|
45 | 45 | match 'heartbeat/:id/edit' => 'heartbeat#edit' |
|
46 | 46 | |
|
47 | 47 | #main |
|
48 | 48 | get "main/list" |
|
49 | 49 | get 'main/submission(/:id)', to: 'main#submission', as: 'main_submission' |
|
50 | 50 | |
|
51 | 51 | #report |
|
52 | 52 | get 'report/problem_hof(/:id)', to: 'report#problem_hof', as: 'report_problem_hof' |
|
53 | 53 | get "report/login" |
|
54 | 54 | get 'report/max_score', to: 'report#max_score', as: 'report_max_score' |
|
55 | + post 'report/show_max_score', to: 'report#show_max_score', as: 'report_show_max_score' | |
|
55 | 56 | |
|
56 | 57 | #grader |
|
57 | 58 | get 'graders/list', to: 'graders#list', as: 'grader_list' |
|
58 | 59 | |
|
59 | 60 | |
|
60 | 61 | match 'heartbeat/:id/edit' => 'heartbeat#edit' |
|
61 | 62 | |
|
62 | 63 | # See how all your routes lay out with "rake routes" |
|
63 | 64 | |
|
64 | 65 | # This is a legacy wild controller route that's not recommended for RESTful applications. |
|
65 | 66 | # Note: This route will make all actions in every controller accessible via GET requests. |
|
66 | 67 | match ':controller(/:action(/:id))(.:format)' |
|
67 | 68 | end |
You need to be logged in to leave comments.
Login now