Description:
- DRY score table - add report to check maximum score of selected problem
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

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')
@@ -0,0 +1,3
1 + %h1 Current Score
2 +
3 + = render "score_table"
@@ -1,66 +1,69
1 1 class ReportController < ApplicationController
2 2
3 + before_filter :authenticate
4 +
3 5 before_filter :admin_authorization, only: [:login_stat,:submission_stat, :stuck, :cheat_report, :cheat_scruntinize, :show_max_score]
4 6
5 7 before_filter(only: [:problem_hof]) { |c|
6 8 return false unless authenticate
7 9
8 10 if GraderConfiguration["right.user_view_submission"]
9 11 return true;
10 12 end
11 13
12 14 admin_authorization
13 15 }
14 16
15 17 def max_score
16 18 end
17 19
18 20 def current_score
19 21 @problems = Problem.find_available_problems
20 22 @users = User.includes(:contests).includes(:contest_stat).where(enabled: true)
21 - @scorearray = calculate_max_score(problems, users,0,0,{max: true})
23 + @scorearray = calculate_max_score(@problems, @users,0,0,true)
22 24
23 25 #rencer accordingly
24 26 if params[:commit] == 'download csv' then
25 27 csv = gen_csv_from_scorearray(@scorearray,@problems)
26 28 send_data csv, filename: 'max_score.csv'
27 29 else
28 30 #render template: 'user_admin/user_stat'
29 31 render 'current_score'
30 32 end
31 33 end
32 34
33 35 def show_max_score
34 36 #process parameters
35 37 #problems
36 38 @problems = []
37 39 params[:problem_id].each do |id|
38 40 next unless id.strip != ""
39 - @problems << Problem.find(id.to_i)
41 + pid = Problem.find_by_id(id.to_i)
42 + @problems << pid if pid
40 43 end
41 44
42 45 #users
43 46 @users = if params[:user] == "all" then
44 47 User.find(:all, :include => [:contests, :contest_stat])
45 48 else
46 49 User.includes(:contests).includes(:contest_stat).where(enabled: true)
47 50 end
48 51
49 52 #set up range from param
50 53 since_id = params.fetch(:min_id, 0).to_i
51 54 until_id = params.fetch(:max_id, 0).to_i
52 55
53 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 59 #rencer accordingly
57 60 if params[:commit] == 'download csv' then
58 61 csv = gen_csv_from_scorearray(@scorearray,@problems)
59 62 send_data csv, filename: 'max_score.csv'
60 63 else
61 64 #render template: 'user_admin/user_stat'
62 65 render 'max_score'
63 66 end
64 67
65 68 end
66 69
@@ -43,25 +43,25
43 43 = add_menu( 'Graders', 'graders', 'list')
44 44 = add_menu( 'Message ', 'messages', 'console')
45 45 %li.divider{role: 'separator'}
46 46 = add_menu( 'System config', 'configurations', 'index')
47 47 %li.divider{role: 'separator'}
48 48 = add_menu( 'Sites', 'sites', 'index')
49 49 = add_menu( 'Contests', 'contest_management', 'index')
50 50 %li.dropdown
51 51 %a.dropdown-toggle{href: '#', data: {toggle:'dropdown'}, aria: {haspopup:"true", expanded:"false"}, role: "button"}
52 52 Report
53 53 %span.caret
54 54 %ul.dropdown-menu
55 - = add_menu( 'Results', 'user_admin', 'user_stat')
55 + = add_menu( 'Results', 'report', 'current_score')
56 56 = add_menu( 'Report', 'report', 'multiple_login')
57 57 - if (ungraded = Submission.where('graded_at is null').where('submitted_at < ?', 1.minutes.ago).count) > 0
58 58 =link_to "#{ungraded} backlogs!",
59 59 grader_list_path,
60 60 class: 'navbar-btn btn btn-default btn-warning', data: {toggle: 'tooltip'},title: 'Number of ungraded submission'
61 61
62 62 %ul.nav.navbar-nav.navbar-right
63 63 = add_menu("#{content_tag(:span,'',class: 'glyphicon glyphicon-question-sign')}".html_safe, 'main', 'help')
64 64 = add_menu("#{content_tag(:span,'',class: 'glyphicon glyphicon-comment')}".html_safe, 'messages', 'list', {title: I18n.t('menu.messages'), data: {toggle: 'tooltip'}})
65 65 - if GraderConfiguration['system.user_setting_enabled']
66 66 = add_menu("#{content_tag(:span,'',class: 'glyphicon glyphicon-cog')}".html_safe, 'users', 'index', {title: I18n.t('menu.settings'), data: {toggle: 'tooltip'}})
67 67 = 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'}})
@@ -37,49 +37,13
37 37 All users
38 38 .radio
39 39 %label
40 40 = radio_button_tag 'users', 'enabled'
41 41 Only enabled users
42 42 .row
43 43 .col-md-12
44 44 = button_tag 'Show', class: "btn btn-primary btn-large"
45 45 = button_tag 'Download CSV', class: "btn btn-primary btn-large"
46 46
47 47 - if @scorearray
48 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')
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"
49 + =render "score_table"
@@ -42,24 +42,25
42 42 end
43 43 end
44 44
45 45 match 'tasks/view/:file.:ext' => 'tasks#view'
46 46 match 'tasks/download/:id/:file.:ext' => 'tasks#download'
47 47 match 'heartbeat/:id/edit' => 'heartbeat#edit'
48 48
49 49 #main
50 50 get "main/list"
51 51 get 'main/submission(/:id)', to: 'main#submission', as: 'main_submission'
52 52
53 53 #report
54 + get 'report/current_score', to: 'report#current_score', as: 'report_current_score'
54 55 get 'report/problem_hof(/:id)', to: 'report#problem_hof', as: 'report_problem_hof'
55 56 get "report/login"
56 57 get 'report/max_score', to: 'report#max_score', as: 'report_max_score'
57 58 post 'report/show_max_score', to: 'report#show_max_score', as: 'report_show_max_score'
58 59
59 60 #grader
60 61 get 'graders/list', to: 'graders#list', as: 'grader_list'
61 62
62 63
63 64 match 'heartbeat/:id/edit' => 'heartbeat#edit'
64 65
65 66 # See how all your routes lay out with "rake routes"
You need to be logged in to leave comments. Login now