Description:
add more stat
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r458:df535657f72c - - 6 files changed: 76 inserted, 14 deleted

@@ -150,25 +150,24
150
150
151 def stat
151 def stat
152 @problem = Problem.find(params[:id])
152 @problem = Problem.find(params[:id])
153 unless @problem.available or session[:admin]
153 unless @problem.available or session[:admin]
154 redirect_to :controller => 'main', :action => 'list'
154 redirect_to :controller => 'main', :action => 'list'
155 return
155 return
156 end
156 end
157 @submissions = Submission.includes(:user).where(problem_id: params[:id]).order(:user_id,:id)
157 @submissions = Submission.includes(:user).where(problem_id: params[:id]).order(:user_id,:id)
158
158
159 #stat summary
159 #stat summary
160 range =65
160 range =65
161 @histogram = { data: Array.new(range,0), summary: {} }
161 @histogram = { data: Array.new(range,0), summary: {} }
162 - @histogram[:data] = Array.new(range,0)
163 user = Hash.new(0)
162 user = Hash.new(0)
164 @submissions.find_each do |sub|
163 @submissions.find_each do |sub|
165 d = (DateTime.now.in_time_zone - sub.submitted_at) / 24 / 60 / 60
164 d = (DateTime.now.in_time_zone - sub.submitted_at) / 24 / 60 / 60
166 @histogram[:data][d.to_i] += 1 if d < range
165 @histogram[:data][d.to_i] += 1 if d < range
167 user[sub.user_id] = [user[sub.user_id], (sub.points >= @problem.full_score) ? 1 : 0].max
166 user[sub.user_id] = [user[sub.user_id], (sub.points >= @problem.full_score) ? 1 : 0].max
168 end
167 end
169 @histogram[:summary][:max] = [@histogram[:data].max,1].max
168 @histogram[:summary][:max] = [@histogram[:data].max,1].max
170
169
171 @summary = { attempt: user.count, solve: 0 }
170 @summary = { attempt: user.count, solve: 0 }
172 user.each_value { |v| @summary[:solve] += 1 if v == 1 }
171 user.each_value { |v| @summary[:solve] += 1 if v == 1 }
173 end
172 end
174
173
@@ -102,25 +102,24
102 redirect_to action: :problem_hof
102 redirect_to action: :problem_hof
103 flash[:notice] = 'Error: submissions for that problem are not viewable.'
103 flash[:notice] = 'Error: submissions for that problem are not viewable.'
104 return
104 return
105 end
105 end
106 end
106 end
107
107
108 return unless @problem
108 return unless @problem
109
109
110 @by_lang = {} #aggregrate by language
110 @by_lang = {} #aggregrate by language
111
111
112 range =65
112 range =65
113 @histogram = { data: Array.new(range,0), summary: {} }
113 @histogram = { data: Array.new(range,0), summary: {} }
114 - @histogram[:data] = Array.new(range,0)
115 @summary = {count: 0, solve: 0, attempt: 0}
114 @summary = {count: 0, solve: 0, attempt: 0}
116 user = Hash.new(0)
115 user = Hash.new(0)
117 Submission.where(problem_id: @problem.id).find_each do |sub|
116 Submission.where(problem_id: @problem.id).find_each do |sub|
118 #histogram
117 #histogram
119 d = (DateTime.now.in_time_zone - sub.submitted_at) / 24 / 60 / 60
118 d = (DateTime.now.in_time_zone - sub.submitted_at) / 24 / 60 / 60
120 @histogram[:data][d.to_i] += 1 if d < range
119 @histogram[:data][d.to_i] += 1 if d < range
121
120
122 @summary[:count] += 1
121 @summary[:count] += 1
123 user[sub.user_id] = [user[sub.user_id], (sub.points >= @problem.full_score) ? 1 : 0].max
122 user[sub.user_id] = [user[sub.user_id], (sub.points >= @problem.full_score) ? 1 : 0].max
124
123
125 lang = Language.find_by_id(sub.language_id)
124 lang = Language.find_by_id(sub.language_id)
126 next unless lang
125 next unless lang
@@ -102,25 +102,43
102 user.save
102 user.save
103 send_new_password_email(user)
103 send_new_password_email(user)
104 flash[:notice] = 'New password has been mailed to you.'
104 flash[:notice] = 'New password has been mailed to you.'
105 end
105 end
106 else
106 else
107 flash[:notice] = I18n.t 'registration.password_retrieval.no_email'
107 flash[:notice] = I18n.t 'registration.password_retrieval.no_email'
108 end
108 end
109 redirect_to :action => 'forget'
109 redirect_to :action => 'forget'
110 end
110 end
111
111
112 def profile
112 def profile
113 @user = User.find(params[:id])
113 @user = User.find(params[:id])
114 - @submission = Submission.where(user_id: params[:id]).all
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 end
133 end
116
134
117 protected
135 protected
118
136
119 def verify_online_registration
137 def verify_online_registration
120 if !GraderConfiguration['system.online_registration']
138 if !GraderConfiguration['system.online_registration']
121 redirect_to :controller => 'main', :action => 'login'
139 redirect_to :controller => 'main', :action => 'login'
122 end
140 end
123 end
141 end
124
142
125 def send_confirmation_email(user)
143 def send_confirmation_email(user)
126 contest_name = GraderConfiguration['contest.name']
144 contest_name = GraderConfiguration['contest.name']
@@ -9,25 +9,25
9 background-color: lightblue;
9 background-color: lightblue;
10 }
10 }
11 .hist_fill {
11 .hist_fill {
12 width: #{bar_width-1}px;
12 width: #{bar_width-1}px;
13 position: absolute;
13 position: absolute;
14 background-color: #eee;
14 background-color: #eee;
15 }
15 }
16 .hist_text {
16 .hist_text {
17 position: absolute;
17 position: absolute;
18 font-size:5px;
18 font-size:5px;
19 }
19 }
20
20
21 - %div{style: "position: relative; width: #{graph_width}px; height: 150px; background-color:#fff;" }
21 + %div{style: "position: relative; width: #{graph_width}px; height: 125px; background-color:#fff;" }
22 //draw background
22 //draw background
23 - histogram[:data].each_index do |i|
23 - histogram[:data].each_index do |i|
24 - height = histogram[:data][i] * graph_height / histogram[:summary][:max]
24 - height = histogram[:data][i] * graph_height / histogram[:summary][:max]
25 - top = graph_height - height
25 - top = graph_height - height
26 - left = graph_width - (i+1)*bar_width
26 - left = graph_width - (i+1)*bar_width
27 %div.hist_fill{style: "top: 0px; height: #{graph_height - height}px; left: #{left}px;" }
27 %div.hist_fill{style: "top: 0px; height: #{graph_height - height}px; left: #{left}px;" }
28 // draw horizontal line
28 // draw horizontal line
29 - line = 3
29 - line = 3
30 - line.times do |i|
30 - line.times do |i|
31 - top = graph_height - graph_height * (i+0.5)/ line
31 - top = graph_height - graph_height * (i+0.5)/ line
32 %div{style: "position:absolute;width: #{graph_width-21}px;height: 1px;left: 20px;top:#{top}px;background-color: #333;"}
32 %div{style: "position:absolute;width: #{graph_width-21}px;height: 1px;left: 20px;top:#{top}px;background-color: #333;"}
33 %div.hist_text{style: "position:absolute;left: 0px;top:#{top-6}px"}
33 %div.hist_text{style: "position:absolute;left: 0px;top:#{top-6}px"}
@@ -1,17 +1,48
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 :css
13 :css
2 .hof_user { color: orangered; font-style: italic; }
14 .hof_user { color: orangered; font-style: italic; }
3 .hof_language { color: green; font-style: italic; }
15 .hof_language { color: green; font-style: italic; }
4 .hof_value { color: deeppink;font-style: italic; }
16 .hof_value { color: deeppink;font-style: italic; }
5 .info_param { font-weight: bold;text-align: right; }
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 %h1 (#{Problem.find(params[:id]).name}) #{Problem.find(params[:id]).full_name}
38 %h1 (#{Problem.find(params[:id]).name}) #{Problem.find(params[:id]).full_name}
8
39
9 %h2 Problem Stat
40 %h2 Problem Stat
10 %table.info
41 %table.info
11 %thead
42 %thead
12 %tr.info-head
43 %tr.info-head
13 %th Stat
44 %th Stat
14 %th Value
45 %th Value
15 %tbody
46 %tbody
16 %tr{class: cycle('info-even','info-odd')}
47 %tr{class: cycle('info-even','info-odd')}
17 %td.info_param Submissions
48 %td.info_param Submissions
@@ -21,25 +52,31
21 %td #{@summary[:solve]}/#{@summary[:attempt]} (#{(@summary[:solve]*100.0/@summary[:attempt]).round(1)}%)
52 %td #{@summary[:solve]}/#{@summary[:attempt]} (#{(@summary[:solve]*100.0/@summary[:attempt]).round(1)}%)
22 - if @best
53 - if @best
23 %tr{class: cycle('info-even','info-odd')}
54 %tr{class: cycle('info-even','info-odd')}
24 %td.info_param Best Runtime
55 %td.info_param Best Runtime
25 %td
56 %td
26 by #{link_to @best[:runtime][:user], controller:'users', action:'profile', id:@best[:memory][:user_id]}
57 by #{link_to @best[:runtime][:user], controller:'users', action:'profile', id:@best[:memory][:user_id]}
27 using <span class="hof_language">#{@best[:runtime][:lang]}</span>
58 using <span class="hof_language">#{@best[:runtime][:lang]}</span>
28 with <span class="hof_value">#{@best[:runtime][:value] * 1000} milliseconds</span>
59 with <span class="hof_value">#{@best[:runtime][:value] * 1000} milliseconds</span>
29 at submission
60 at submission
30 = link_to("#" + @best[:runtime][:sub_id].to_s, controller: 'graders', action: 'submission', id:@best[:runtime][:sub_id])
61 = link_to("#" + @best[:runtime][:sub_id].to_s, controller: 'graders', action: 'submission', id:@best[:runtime][:sub_id])
31
62
32 %tr{class: cycle('info-even','info-odd')}
63 %tr{class: cycle('info-even','info-odd')}
33 - %td.info_param Best Memory Usage
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 %td
71 %td
35 by #{link_to @best[:memory][:user], controller:'users', action:'profile', id:@best[:memory][:user_id]}
72 by #{link_to @best[:memory][:user], controller:'users', action:'profile', id:@best[:memory][:user_id]}
36 using <span class="hof_language">#{@best[:memory][:lang]}</span>
73 using <span class="hof_language">#{@best[:memory][:lang]}</span>
37 with <span class="hof_value">#{number_with_delimiter(@best[:memory][:value])} kbytes </span>
74 with <span class="hof_value">#{number_with_delimiter(@best[:memory][:value])} kbytes </span>
38 at submission
75 at submission
39 = link_to("#" + @best[:memory][:sub_id].to_s, controller: 'graders' , action: 'submission', id:@best[:memory][:sub_id])
76 = link_to("#" + @best[:memory][:sub_id].to_s, controller: 'graders' , action: 'submission', id:@best[:memory][:sub_id])
40
77
41 %tr{class: cycle('info-even','info-odd')}
78 %tr{class: cycle('info-even','info-odd')}
42 %td.info_param Shortest Code
79 %td.info_param Shortest Code
43 %td
80 %td
44 by #{link_to @best[:length][:user], controller:'users', action:'profile', id:@best[:length][:user_id]}
81 by #{link_to @best[:length][:user], controller:'users', action:'profile', id:@best[:length][:user_id]}
45 using <span class="hof_language">#{@best[:length][:lang]}</span>
82 using <span class="hof_language">#{@best[:length][:lang]}</span>
@@ -47,29 +84,24
47 at submission
84 at submission
48 = link_to("#" + @best[:length][:sub_id].to_s, controller: 'graders' , action: 'submission', id: @best[:length][:sub_id])
85 = link_to("#" + @best[:length][:sub_id].to_s, controller: 'graders' , action: 'submission', id: @best[:length][:sub_id])
49
86
50 %tr{class: cycle('info-even','info-odd')}
87 %tr{class: cycle('info-even','info-odd')}
51 %td.info_param First solver
88 %td.info_param First solver
52 %td
89 %td
53 #{link_to @best[:first][:user], controller:'users', action:'profile', id:@best[:first][:user_id]} is the first solver
90 #{link_to @best[:first][:user], controller:'users', action:'profile', id:@best[:first][:user_id]} is the first solver
54 using <span class="hof_language">#{@best[:first][:lang]}</span>
91 using <span class="hof_language">#{@best[:first][:lang]}</span>
55 on <span class="hof_value">#{@best[:first][:value]}</span>
92 on <span class="hof_value">#{@best[:first][:value]}</span>
56 at submission
93 at submission
57 = link_to("#" + @best[:first][:sub_id].to_s, controller: 'graders' , action: 'submission', id: @best[:first][:sub_id])
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 - if @best
96 - if @best
65 %h2 By language
97 %h2 By language
66
98
67 %table.info
99 %table.info
68 %thead
100 %thead
69 %tr.info-head
101 %tr.info-head
70 %th Language
102 %th Language
71 %th Best runtime (ms)
103 %th Best runtime (ms)
72 %th Best memory (kbytes)
104 %th Best memory (kbytes)
73 %th Shortest Code (bytes)
105 %th Shortest Code (bytes)
74 %th First solver
106 %th First solver
75 %tbody
107 %tbody
@@ -1,35 +1,49
1 - content_for :header do
1 - content_for :header do
2 = javascript_include_tag 'local_jquery'
2 = javascript_include_tag 'local_jquery'
3
3
4 - %script{:type=>"text/javascript"}
4 + :javascript
5 $(function () {
5 $(function () {
6 $('#submission_table').tablesorter({widgets: ['zebra']});
6 $('#submission_table').tablesorter({widgets: ['zebra']});
7 });
7 });
8
8
9 :css
9 :css
10 .fix-width {
10 .fix-width {
11 font-family: Droid Sans Mono,Consolas, monospace, mono, Courier New, Courier;
11 font-family: Droid Sans Mono,Consolas, monospace, mono, Courier New, Courier;
12 }
12 }
13
13
14 - %h1= @user.full_name + ' Profile'
14 + %h1= @user.full_name
15
15
16 - %h2 Basic info
17 <b>Login:</b> #{@user.login} <br/>
16 <b>Login:</b> #{@user.login} <br/>
18 <b>Full name:</b> #{@user.full_name} <br />
17 <b>Full name:</b> #{@user.full_name} <br />
19
18
20
19
21 %h2 Problem Stat
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 %table.tablesorter-cafe#submission_table
39 %table.tablesorter-cafe#submission_table
26 %thead
40 %thead
27 %tr
41 %tr
28 %th ID
42 %th ID
29 %th Problem code
43 %th Problem code
30 %th Problem full name
44 %th Problem full name
31 %th Language
45 %th Language
32 %th Submitted at
46 %th Submitted at
33 %th Result
47 %th Result
34 %th Score
48 %th Score
35 - if session[:admin]
49 - if session[:admin]
You need to be logged in to leave comments. Login now