Description:
- DRY score table
- add report to check maximum score of selected problem
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r601:ff006e008326 - - 6 files changed: 46 inserted, 41 deleted
@@ -0,0 +1,34 | |||||
|
|
1 | + %table.table.sortable.table-striped.table-bordered.table-condensed | ||
|
|
2 | + %thead | ||
|
|
3 | + %tr | ||
|
|
4 | + %th Login | ||
|
|
5 | + %th Name | ||
|
|
6 | + %th Activated? | ||
|
|
7 | + %th Logged_in | ||
|
|
8 | + %th Contest(s) | ||
|
|
9 | + %th Remark | ||
|
|
10 | + - @problems.each do |p| | ||
|
|
11 | + %th.text-right= p.name | ||
|
|
12 | + %th.text-right Total | ||
|
|
13 | + %th.text-right Passed | ||
|
|
14 | + %tbody | ||
|
|
15 | + - @scorearray.each do |sc| | ||
|
|
16 | + %tr | ||
|
|
17 | + - total,num_passed = 0,0 | ||
|
|
18 | + - sc.each_index do |i| | ||
|
|
19 | + - if i == 0 | ||
|
|
20 | + %td= link_to sc[i].login, controller: 'users', action: 'profile', id: sc[i] | ||
|
|
21 | + %td= sc[i].full_name | ||
|
|
22 | + %td= sc[i].activated | ||
|
|
23 | + %td= sc[i].try(:contest_stat).try(:started_at) ? 'yes' : 'no' | ||
|
|
24 | + %td= sc[i].contests.collect {|c| c.name}.join(', ') | ||
|
|
25 | + %td= sc[i].remark | ||
|
|
26 | + - else | ||
|
|
27 | + %td.text-right= sc[i][0] | ||
|
|
28 | + - total += sc[i][0] | ||
|
|
29 | + - num_passed += 1 if sc[i][1] | ||
|
|
30 | + %td.text-right= total | ||
|
|
31 | + %td.text-right= num_passed | ||
|
|
32 | + | ||
|
|
33 | + :javascript | ||
|
|
34 | + $.bootstrapSortable(true,'reversed') |
@@ -1,5 +1,7 | |||||
|
1 | class ReportController < ApplicationController |
|
1 | class ReportController < ApplicationController |
|
2 |
|
2 | ||
|
|
3 | + before_filter :authenticate | ||
|
|
4 | + | ||
|
3 | before_filter :admin_authorization, only: [:login_stat,:submission_stat, :stuck, :cheat_report, :cheat_scruntinize, :show_max_score] |
|
5 | before_filter :admin_authorization, only: [:login_stat,:submission_stat, :stuck, :cheat_report, :cheat_scruntinize, :show_max_score] |
|
4 |
|
6 | ||
|
5 | before_filter(only: [:problem_hof]) { |c| |
|
7 | before_filter(only: [:problem_hof]) { |c| |
@@ -18,7 +20,7 | |||||
|
18 | def current_score |
|
20 | def current_score |
|
19 | @problems = Problem.find_available_problems |
|
21 | @problems = Problem.find_available_problems |
|
20 | @users = User.includes(:contests).includes(:contest_stat).where(enabled: true) |
|
22 | @users = User.includes(:contests).includes(:contest_stat).where(enabled: true) |
|
21 |
- @scorearray = calculate_max_score(problems, users,0,0, |
|
23 | + @scorearray = calculate_max_score(@problems, @users,0,0,true) |
|
22 |
|
24 | ||
|
23 | #rencer accordingly |
|
25 | #rencer accordingly |
|
24 | if params[:commit] == 'download csv' then |
|
26 | if params[:commit] == 'download csv' then |
@@ -36,7 +38,8 | |||||
|
36 | @problems = [] |
|
38 | @problems = [] |
|
37 | params[:problem_id].each do |id| |
|
39 | params[:problem_id].each do |id| |
|
38 | next unless id.strip != "" |
|
40 | next unless id.strip != "" |
|
39 |
- |
|
41 | + pid = Problem.find_by_id(id.to_i) |
|
|
42 | + @problems << pid if pid | ||
|
40 | end |
|
43 | end |
|
41 |
|
44 | ||
|
42 | #users |
|
45 | #users |
@@ -51,7 +54,7 | |||||
|
51 | until_id = params.fetch(:max_id, 0).to_i |
|
54 | until_id = params.fetch(:max_id, 0).to_i |
|
52 |
|
55 | ||
|
53 | #calculate the routine |
|
56 | #calculate the routine |
|
54 | - @scorearray = calculate_max_score(problems, users,since_id,until_id) |
|
57 | + @scorearray = calculate_max_score(@problems, @users,since_id,until_id) |
|
55 |
|
58 | ||
|
56 | #rencer accordingly |
|
59 | #rencer accordingly |
|
57 | if params[:commit] == 'download csv' then |
|
60 | if params[:commit] == 'download csv' then |
@@ -52,7 +52,7 | |||||
|
52 | Report |
|
52 | Report |
|
53 | %span.caret |
|
53 | %span.caret |
|
54 | %ul.dropdown-menu |
|
54 | %ul.dropdown-menu |
|
55 |
- = add_menu( 'Results', ' |
|
55 | + = add_menu( 'Results', 'report', 'current_score') |
|
56 | = add_menu( 'Report', 'report', 'multiple_login') |
|
56 | = add_menu( 'Report', 'report', 'multiple_login') |
|
57 | - if (ungraded = Submission.where('graded_at is null').where('submitted_at < ?', 1.minutes.ago).count) > 0 |
|
57 | - if (ungraded = Submission.where('graded_at is null').where('submitted_at < ?', 1.minutes.ago).count) > 0 |
|
58 | =link_to "#{ungraded} backlogs!", |
|
58 | =link_to "#{ungraded} backlogs!", |
@@ -46,40 +46,4 | |||||
|
46 |
|
46 | ||
|
47 | - if @scorearray |
|
47 | - if @scorearray |
|
48 | %h2 Result |
|
48 | %h2 Result |
|
49 | - %table.table.sortable.table-striped.table-bordered.table-condensed |
|
49 | + =render "score_table" |
|
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') |
|
||
|
82 | - /.col-md-4.col-md-offset-1 |
|
||
|
83 | - / = button_tag 'Show', class: "btn btn-primary btn-block" |
|
||
|
84 | - /.col-md-4.col-md-offset-2 |
|
||
|
85 | - / = button_tag 'Download CSV', class: "btn btn-primary btn-block" |
|
@@ -51,6 +51,7 | |||||
|
51 | get 'main/submission(/:id)', to: 'main#submission', as: 'main_submission' |
|
51 | get 'main/submission(/:id)', to: 'main#submission', as: 'main_submission' |
|
52 |
|
52 | ||
|
53 | #report |
|
53 | #report |
|
|
54 | + get 'report/current_score', to: 'report#current_score', as: 'report_current_score' | ||
|
54 | get 'report/problem_hof(/:id)', to: 'report#problem_hof', as: 'report_problem_hof' |
|
55 | get 'report/problem_hof(/:id)', to: 'report#problem_hof', as: 'report_problem_hof' |
|
55 | get "report/login" |
|
56 | get "report/login" |
|
56 | get 'report/max_score', to: 'report#max_score', as: 'report_max_score' |
|
57 | get 'report/max_score', to: 'report#max_score', as: 'report_max_score' |
You need to be logged in to leave comments.
Login now