Description:
add more stat
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r458:df535657f72c - - 6 files changed: 77 inserted, 15 deleted
@@ -138,49 +138,48 | |||
|
138 | 138 | end |
|
139 | 139 | redirect_to :action => 'list' |
|
140 | 140 | end |
|
141 | 141 | |
|
142 | 142 | def turn_all_on |
|
143 | 143 | Problem.find(:all, |
|
144 | 144 | :conditions => "available = 0").each do |problem| |
|
145 | 145 | problem.available = true |
|
146 | 146 | problem.save |
|
147 | 147 | end |
|
148 | 148 | redirect_to :action => 'list' |
|
149 | 149 | end |
|
150 | 150 | |
|
151 | 151 | def stat |
|
152 | 152 | @problem = Problem.find(params[:id]) |
|
153 | 153 | unless @problem.available or session[:admin] |
|
154 | 154 | redirect_to :controller => 'main', :action => 'list' |
|
155 | 155 | return |
|
156 | 156 | end |
|
157 | 157 | @submissions = Submission.includes(:user).where(problem_id: params[:id]).order(:user_id,:id) |
|
158 | 158 | |
|
159 | 159 | #stat summary |
|
160 | 160 | range =65 |
|
161 | 161 | @histogram = { data: Array.new(range,0), summary: {} } |
|
162 | - @histogram[:data] = Array.new(range,0) | |
|
163 | 162 | user = Hash.new(0) |
|
164 | 163 | @submissions.find_each do |sub| |
|
165 | 164 | d = (DateTime.now.in_time_zone - sub.submitted_at) / 24 / 60 / 60 |
|
166 | 165 | @histogram[:data][d.to_i] += 1 if d < range |
|
167 | 166 | user[sub.user_id] = [user[sub.user_id], (sub.points >= @problem.full_score) ? 1 : 0].max |
|
168 | 167 | end |
|
169 | 168 | @histogram[:summary][:max] = [@histogram[:data].max,1].max |
|
170 | 169 | |
|
171 | 170 | @summary = { attempt: user.count, solve: 0 } |
|
172 | 171 | user.each_value { |v| @summary[:solve] += 1 if v == 1 } |
|
173 | 172 | end |
|
174 | 173 | |
|
175 | 174 | def manage |
|
176 | 175 | @problems = Problem.find(:all, :order => 'date_added DESC') |
|
177 | 176 | end |
|
178 | 177 | |
|
179 | 178 | def do_manage |
|
180 | 179 | if params.has_key? 'change_date_added' |
|
181 | 180 | change_date_added |
|
182 | 181 | elsif params.has_key? 'add_to_contest' |
|
183 | 182 | add_to_contest |
|
184 | 183 | elsif params.has_key? 'enable_problem' |
|
185 | 184 | set_available(true) |
|
186 | 185 | elsif params.has_key? 'disable_problem' |
@@ -90,49 +90,48 | |||
|
90 | 90 | end |
|
91 | 91 | |
|
92 | 92 | def problem_hof |
|
93 | 93 | # gen problem list |
|
94 | 94 | @user = User.find(session[:user_id]) |
|
95 | 95 | @problems = @user.available_problems |
|
96 | 96 | |
|
97 | 97 | # get selected problems or the default |
|
98 | 98 | if params[:id] |
|
99 | 99 | begin |
|
100 | 100 | @problem = Problem.available.find(params[:id]) |
|
101 | 101 | rescue |
|
102 | 102 | redirect_to action: :problem_hof |
|
103 | 103 | flash[:notice] = 'Error: submissions for that problem are not viewable.' |
|
104 | 104 | return |
|
105 | 105 | end |
|
106 | 106 | end |
|
107 | 107 | |
|
108 | 108 | return unless @problem |
|
109 | 109 | |
|
110 | 110 | @by_lang = {} #aggregrate by language |
|
111 | 111 | |
|
112 | 112 | range =65 |
|
113 | 113 | @histogram = { data: Array.new(range,0), summary: {} } |
|
114 | - @histogram[:data] = Array.new(range,0) | |
|
115 | 114 | @summary = {count: 0, solve: 0, attempt: 0} |
|
116 | 115 | user = Hash.new(0) |
|
117 | 116 | Submission.where(problem_id: @problem.id).find_each do |sub| |
|
118 | 117 | #histogram |
|
119 | 118 | d = (DateTime.now.in_time_zone - sub.submitted_at) / 24 / 60 / 60 |
|
120 | 119 | @histogram[:data][d.to_i] += 1 if d < range |
|
121 | 120 | |
|
122 | 121 | @summary[:count] += 1 |
|
123 | 122 | user[sub.user_id] = [user[sub.user_id], (sub.points >= @problem.full_score) ? 1 : 0].max |
|
124 | 123 | |
|
125 | 124 | lang = Language.find_by_id(sub.language_id) |
|
126 | 125 | next unless lang |
|
127 | 126 | next unless sub.points >= @problem.full_score |
|
128 | 127 | |
|
129 | 128 | #initialize |
|
130 | 129 | unless @by_lang.has_key?(lang.pretty_name) |
|
131 | 130 | @by_lang[lang.pretty_name] = { |
|
132 | 131 | runtime: { avail: false, value: 2**30-1 }, |
|
133 | 132 | memory: { avail: false, value: 2**30-1 }, |
|
134 | 133 | length: { avail: false, value: 2**30-1 }, |
|
135 | 134 | first: { avail: false, value: DateTime.new(3000,1,1) } |
|
136 | 135 | } |
|
137 | 136 | end |
|
138 | 137 |
@@ -90,49 +90,67 | |||
|
90 | 90 | render :action => 'forget', :layout => 'empty' |
|
91 | 91 | end |
|
92 | 92 | |
|
93 | 93 | def retrieve_password |
|
94 | 94 | email = params[:email] |
|
95 | 95 | user = User.find_by_email(email) |
|
96 | 96 | if user |
|
97 | 97 | last_updated_time = user.updated_at || user.created_at || (Time.now.gmtime - 1.hour) |
|
98 | 98 | if last_updated_time > Time.now.gmtime - 5.minutes |
|
99 | 99 | flash[:notice] = 'The account has recently created or new password has recently been requested. Please wait for 5 minutes' |
|
100 | 100 | else |
|
101 | 101 | user.password = user.password_confirmation = User.random_password |
|
102 | 102 | user.save |
|
103 | 103 | send_new_password_email(user) |
|
104 | 104 | flash[:notice] = 'New password has been mailed to you.' |
|
105 | 105 | end |
|
106 | 106 | else |
|
107 | 107 | flash[:notice] = I18n.t 'registration.password_retrieval.no_email' |
|
108 | 108 | end |
|
109 | 109 | redirect_to :action => 'forget' |
|
110 | 110 | end |
|
111 | 111 | |
|
112 | 112 | def profile |
|
113 | 113 | @user = User.find(params[:id]) |
|
114 |
- @submission = Submission.where(user_id: params[:id]) |
|
|
114 | + @submission = Submission.includes(:problem).where(user_id: params[:id]) | |
|
115 | + | |
|
116 | + range = 120 | |
|
117 | + @histogram = { data: Array.new(range,0), summary: {} } | |
|
118 | + @summary = {count: 0, solve: 0, attempt: 0} | |
|
119 | + problem = Hash.new(0) | |
|
120 | + | |
|
121 | + @submission.find_each do |sub| | |
|
122 | + #histogram | |
|
123 | + d = (DateTime.now.in_time_zone - sub.submitted_at) / 24 / 60 / 60 | |
|
124 | + @histogram[:data][d.to_i] += 1 if d < range | |
|
125 | + | |
|
126 | + @summary[:count] += 1 | |
|
127 | + problem[sub.problem] = [problem[sub.problem], (sub.points >= sub.problem.full_score) ? 1 : 0].max | |
|
128 | + end | |
|
129 | + | |
|
130 | + @histogram[:summary][:max] = [@histogram[:data].max,1].max | |
|
131 | + @summary[:attempt] = problem.count | |
|
132 | + problem.each_value { |v| @summary[:solve] += 1 if v == 1 } | |
|
115 | 133 | end |
|
116 | 134 | |
|
117 | 135 | protected |
|
118 | 136 | |
|
119 | 137 | def verify_online_registration |
|
120 | 138 | if !GraderConfiguration['system.online_registration'] |
|
121 | 139 | redirect_to :controller => 'main', :action => 'login' |
|
122 | 140 | end |
|
123 | 141 | end |
|
124 | 142 | |
|
125 | 143 | def send_confirmation_email(user) |
|
126 | 144 | contest_name = GraderConfiguration['contest.name'] |
|
127 | 145 | activation_url = url_for(:action => 'confirm', |
|
128 | 146 | :login => user.login, |
|
129 | 147 | :activation => user.activation_key) |
|
130 | 148 | home_url = url_for(:controller => 'main', :action => 'index') |
|
131 | 149 | mail_subject = "[#{contest_name}] Confirmation" |
|
132 | 150 | mail_body = t('registration.email_body', { |
|
133 | 151 | :full_name => user.full_name, |
|
134 | 152 | :contest_name => contest_name, |
|
135 | 153 | :login => user.login, |
|
136 | 154 | :password => user.password, |
|
137 | 155 | :activation_url => activation_url, |
|
138 | 156 | :admin_email => admin_email |
@@ -1,44 +1,44 | |||
|
1 | 1 | - param = {} unless param |
|
2 | 2 | - graph_height = param[:graph_height] || 100 |
|
3 | 3 | - bar_width = param[:bar_width] || 14 |
|
4 | 4 | - graph_width = (bar_width * histogram[:data].count) + 20 |
|
5 | 5 | :css |
|
6 | 6 | .hist_bar { |
|
7 | 7 | width: #{bar_width-1}px; |
|
8 | 8 | position: absolute; |
|
9 | 9 | background-color: lightblue; |
|
10 | 10 | } |
|
11 | 11 | .hist_fill { |
|
12 | 12 | width: #{bar_width-1}px; |
|
13 | 13 | position: absolute; |
|
14 | 14 | background-color: #eee; |
|
15 | 15 | } |
|
16 | 16 | .hist_text { |
|
17 | 17 | position: absolute; |
|
18 | 18 | font-size:5px; |
|
19 | 19 | } |
|
20 | 20 | |
|
21 |
- %div{style: "position: relative; width: #{graph_width}px; height: 15 |
|
|
21 | + %div{style: "position: relative; width: #{graph_width}px; height: 125px; background-color:#fff;" } | |
|
22 | 22 | //draw background |
|
23 | 23 | - histogram[:data].each_index do |i| |
|
24 | 24 | - height = histogram[:data][i] * graph_height / histogram[:summary][:max] |
|
25 | 25 | - top = graph_height - height |
|
26 | 26 | - left = graph_width - (i+1)*bar_width |
|
27 | 27 | %div.hist_fill{style: "top: 0px; height: #{graph_height - height}px; left: #{left}px;" } |
|
28 | 28 | // draw horizontal line |
|
29 | 29 | - line = 3 |
|
30 | 30 | - line.times do |i| |
|
31 | 31 | - top = graph_height - graph_height * (i+0.5)/ line |
|
32 | 32 | %div{style: "position:absolute;width: #{graph_width-21}px;height: 1px;left: 20px;top:#{top}px;background-color: #333;"} |
|
33 | 33 | %div.hist_text{style: "position:absolute;left: 0px;top:#{top-6}px"} |
|
34 | 34 | =((i+0.5) * histogram[:summary][:max] / line).to_i |
|
35 | 35 | // draw the actual bar and text |
|
36 | 36 | - @histogram[:data].each_index do |i| |
|
37 | 37 | - height = histogram[:data][i] * graph_height / histogram[:summary][:max] |
|
38 | 38 | - top = graph_height - height |
|
39 | 39 | - left = graph_width - (i+1)*bar_width |
|
40 | 40 | %div.hist_bar{style: "top: #{top}px; height: #{height}px; left: #{left}px; dae: #{histogram[:data][i]}" } |
|
41 | 41 | - if i % 7 == 1 |
|
42 | 42 | %div.hist_text{style: "top:#{graph_height + 5}px;left: #{left}px;"} #{(Time.zone.today - i.day).strftime('%-d')} |
|
43 | 43 | - if (Time.now.in_time_zone - i.day).day == 15 |
|
44 | 44 | %div.hist_text{style: "top:#{graph_height + 15}px;left: #{left}px;"} #{(Time.zone.today - i.day).strftime('%b')} |
@@ -1,87 +1,119 | |||
|
1 | + - content_for :header do | |
|
2 | + = javascript_include_tag 'local_jquery' | |
|
3 | + | |
|
4 | + :javascript | |
|
5 | + $(document).ready( function() { | |
|
6 | + $("#mem_remark").hover( function() { | |
|
7 | + $("#mem_remark_box").show(); | |
|
8 | + }, function() { | |
|
9 | + $("#mem_remark_box").hide(); | |
|
10 | + }); | |
|
11 | + }); | |
|
12 | + alert("hahaha"); | |
|
1 | 13 | :css |
|
2 | 14 | .hof_user { color: orangered; font-style: italic; } |
|
3 | 15 | .hof_language { color: green; font-style: italic; } |
|
4 | 16 | .hof_value { color: deeppink;font-style: italic; } |
|
5 | 17 | .info_param { font-weight: bold;text-align: right; } |
|
18 | + .tooltip { | |
|
19 | + font-family: Verdana,sans-serif; | |
|
20 | + font-weight: normal; | |
|
21 | + text-align: left; | |
|
22 | + font-size: 1.0em; | |
|
23 | + color: black; | |
|
24 | + line-height: 1.1; | |
|
25 | + display: none; | |
|
26 | + min-width: 20em; | |
|
27 | + position: absolute; | |
|
28 | + left: 25px; | |
|
29 | + bottom: 5px; | |
|
30 | + border: 1px solid; | |
|
31 | + padding: 5px; | |
|
32 | + background-color: #FFF; | |
|
33 | + word-wrap: break-word; | |
|
34 | + z-index: 9999; | |
|
35 | + overflow: auto; | |
|
36 | + } | |
|
6 | 37 | |
|
7 | 38 | %h1 (#{Problem.find(params[:id]).name}) #{Problem.find(params[:id]).full_name} |
|
8 | 39 | |
|
9 | 40 | %h2 Problem Stat |
|
10 | 41 | %table.info |
|
11 | 42 | %thead |
|
12 | 43 | %tr.info-head |
|
13 | 44 | %th Stat |
|
14 | 45 | %th Value |
|
15 | 46 | %tbody |
|
16 | 47 | %tr{class: cycle('info-even','info-odd')} |
|
17 | 48 | %td.info_param Submissions |
|
18 | 49 | %td= @summary[:count] |
|
19 | 50 | %tr{class: cycle('info-even','info-odd')} |
|
20 | 51 | %td.info_param Solved/Attempted User |
|
21 | 52 | %td #{@summary[:solve]}/#{@summary[:attempt]} (#{(@summary[:solve]*100.0/@summary[:attempt]).round(1)}%) |
|
22 | 53 | - if @best |
|
23 | 54 | %tr{class: cycle('info-even','info-odd')} |
|
24 | 55 | %td.info_param Best Runtime |
|
25 | 56 | %td |
|
26 | 57 | by #{link_to @best[:runtime][:user], controller:'users', action:'profile', id:@best[:memory][:user_id]} |
|
27 | 58 | using <span class="hof_language">#{@best[:runtime][:lang]}</span> |
|
28 | 59 | with <span class="hof_value">#{@best[:runtime][:value] * 1000} milliseconds</span> |
|
29 | 60 | at submission |
|
30 | 61 | = link_to("#" + @best[:runtime][:sub_id].to_s, controller: 'graders', action: 'submission', id:@best[:runtime][:sub_id]) |
|
31 | 62 | |
|
32 | 63 | %tr{class: cycle('info-even','info-odd')} |
|
33 |
- %td.info_param |
|
|
64 | + %td.info_param | |
|
65 | + Best Memory Usage | |
|
66 | + %sup{ id: "mem_remark", style: "position:relative; color: blue;"} | |
|
67 | + [?] | |
|
68 | + %span.tooltip#mem_remark_box | |
|
69 | + This counts only for submission with 100% score. | |
|
70 | + Right now, java is excluded from memory usage competition. (Because it always uses 2GB memory...) | |
|
34 | 71 | %td |
|
35 | 72 | by #{link_to @best[:memory][:user], controller:'users', action:'profile', id:@best[:memory][:user_id]} |
|
36 | 73 | using <span class="hof_language">#{@best[:memory][:lang]}</span> |
|
37 | 74 | with <span class="hof_value">#{number_with_delimiter(@best[:memory][:value])} kbytes </span> |
|
38 | 75 | at submission |
|
39 | 76 | = link_to("#" + @best[:memory][:sub_id].to_s, controller: 'graders' , action: 'submission', id:@best[:memory][:sub_id]) |
|
40 | 77 | |
|
41 | 78 | %tr{class: cycle('info-even','info-odd')} |
|
42 | 79 | %td.info_param Shortest Code |
|
43 | 80 | %td |
|
44 | 81 | by #{link_to @best[:length][:user], controller:'users', action:'profile', id:@best[:length][:user_id]} |
|
45 | 82 | using <span class="hof_language">#{@best[:length][:lang]}</span> |
|
46 | 83 | with <span class="hof_value">#{@best[:length][:value]} bytes</span> |
|
47 | 84 | at submission |
|
48 | 85 | = link_to("#" + @best[:length][:sub_id].to_s, controller: 'graders' , action: 'submission', id: @best[:length][:sub_id]) |
|
49 | 86 | |
|
50 | 87 | %tr{class: cycle('info-even','info-odd')} |
|
51 | 88 | %td.info_param First solver |
|
52 | 89 | %td |
|
53 | 90 | #{link_to @best[:first][:user], controller:'users', action:'profile', id:@best[:first][:user_id]} is the first solver |
|
54 | 91 | using <span class="hof_language">#{@best[:first][:lang]}</span> |
|
55 | 92 | on <span class="hof_value">#{@best[:first][:value]}</span> |
|
56 | 93 | at submission |
|
57 | 94 | = link_to("#" + @best[:first][:sub_id].to_s, controller: 'graders' , action: 'submission', id: @best[:first][:sub_id]) |
|
58 | 95 | |
|
59 | - | |
|
60 | - %p | |
|
61 | - This counts only for submission with 100% score <br/> | |
|
62 | - Right now, java is excluded from memory usage competition. (Because it always uses 2GB memory...) | |
|
63 | - | |
|
64 | 96 | - if @best |
|
65 | 97 | %h2 By language |
|
66 | 98 | |
|
67 | 99 | %table.info |
|
68 | 100 | %thead |
|
69 | 101 | %tr.info-head |
|
70 | 102 | %th Language |
|
71 | 103 | %th Best runtime (ms) |
|
72 | 104 | %th Best memory (kbytes) |
|
73 | 105 | %th Shortest Code (bytes) |
|
74 | 106 | %th First solver |
|
75 | 107 | %tbody |
|
76 | 108 | - @by_lang.each do |lang,value| |
|
77 | 109 | %tr{class: cycle('info-even','info-odd')} |
|
78 | 110 | %td= lang |
|
79 | 111 | %td |
|
80 | 112 | = link_to value[:runtime][:user], controller: 'users', action: 'profile', id: value[:runtime][:user_id] |
|
81 | 113 | = "(#{(value[:runtime][:value] * 1000).to_i} @" |
|
82 | 114 | = "#{link_to("#" + value[:runtime][:sub_id].to_s, controller: 'graders' , action: 'submission', id: value[:runtime][:sub_id])} )".html_safe |
|
83 | 115 | %td |
|
84 | 116 | = link_to value[:memory][:user], controller: 'users', action: 'profile', id: value[:memory][:user_id] |
|
85 | 117 | = "(#{number_with_delimiter(value[:memory][:value])} @" |
|
86 | 118 | = "#{link_to("#" + value[:memory][:sub_id].to_s, controller: 'graders' , action: 'submission', id: value[:memory][:sub_id])} )".html_safe |
|
87 | 119 | %td |
@@ -1,47 +1,61 | |||
|
1 | 1 | - content_for :header do |
|
2 | 2 | = javascript_include_tag 'local_jquery' |
|
3 | 3 | |
|
4 | - %script{:type=>"text/javascript"} | |
|
4 | + :javascript | |
|
5 | 5 | $(function () { |
|
6 | - $('#submission_table').tablesorter({widgets: ['zebra']}); | |
|
6 | + $('#submission_table').tablesorter({widgets: ['zebra']}); | |
|
7 | 7 | }); |
|
8 | 8 | |
|
9 | 9 | :css |
|
10 | 10 | .fix-width { |
|
11 | 11 | font-family: Droid Sans Mono,Consolas, monospace, mono, Courier New, Courier; |
|
12 | 12 | } |
|
13 | 13 | |
|
14 |
- %h1= @user.full_name |
|
|
14 | + %h1= @user.full_name | |
|
15 | 15 | |
|
16 | - %h2 Basic info | |
|
17 | 16 | <b>Login:</b> #{@user.login} <br/> |
|
18 | 17 | <b>Full name:</b> #{@user.full_name} <br /> |
|
19 | 18 | |
|
20 | 19 | |
|
21 | 20 | %h2 Problem Stat |
|
21 | + %table.info | |
|
22 | + %thead | |
|
23 | + %tr.info-head | |
|
24 | + %th Stat | |
|
25 | + %th Value | |
|
26 | + %tbody | |
|
27 | + %tr{class: cycle('info-even','info-odd')} | |
|
28 | + %td.info_param Submissions | |
|
29 | + %td= @summary[:count] | |
|
30 | + %tr{class: cycle('info-even','info-odd')} | |
|
31 | + %td.info_param Solved/Attempted Problem | |
|
32 | + %td #{@summary[:solve]}/#{@summary[:attempt]} (#{(@summary[:solve]*100.0/@summary[:attempt]).round(1)}%) | |
|
22 | 33 | |
|
23 | - %h2 Submissions | |
|
34 | + %h2 Submission History | |
|
35 | + | |
|
36 | + =render partial: 'application/bar_graph', locals: {histogram: @histogram, param: {bar_width: 7}} | |
|
37 | + | |
|
24 | 38 | |
|
25 | 39 | %table.tablesorter-cafe#submission_table |
|
26 | 40 | %thead |
|
27 | 41 | %tr |
|
28 | 42 | %th ID |
|
29 | 43 | %th Problem code |
|
30 | 44 | %th Problem full name |
|
31 | 45 | %th Language |
|
32 | 46 | %th Submitted at |
|
33 | 47 | %th Result |
|
34 | 48 | %th Score |
|
35 | 49 | - if session[:admin] |
|
36 | 50 | %th IP |
|
37 | 51 | %tbody |
|
38 | 52 | - @submission.each do |s| |
|
39 | 53 | - next unless s.problem |
|
40 | 54 | %tr |
|
41 | 55 | %td= link_to "#{s.id}", controller: "graders", action: "submission", id: s.id |
|
42 | 56 | %td= s.problem.name |
|
43 | 57 | %td= s.problem.full_name |
|
44 | 58 | %td= s.language.pretty_name |
|
45 | 59 | %td #{s.submitted_at.strftime('%Y-%m-%d %H:%M')} (#{time_ago_in_words(s.submitted_at)} ago) |
|
46 | 60 | %td.fix-width= s.grader_comment |
|
47 | 61 | %td= (s.points*100)/s.problem.full_score |
You need to be logged in to leave comments.
Login now