Description:
add more problem stat
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r457:c81651eecbbd - - 7 files changed: 144 inserted, 43 deleted
@@ -0,0 +1,44 | |||
|
1 | + - param = {} unless param | |
|
2 | + - graph_height = param[:graph_height] || 100 | |
|
3 | + - bar_width = param[:bar_width] || 14 | |
|
4 | + - graph_width = (bar_width * histogram[:data].count) + 20 | |
|
5 | + :css | |
|
6 | + .hist_bar { | |
|
7 | + width: #{bar_width-1}px; | |
|
8 | + position: absolute; | |
|
9 | + background-color: lightblue; | |
|
10 | + } | |
|
11 | + .hist_fill { | |
|
12 | + width: #{bar_width-1}px; | |
|
13 | + position: absolute; | |
|
14 | + background-color: #eee; | |
|
15 | + } | |
|
16 | + .hist_text { | |
|
17 | + position: absolute; | |
|
18 | + font-size:5px; | |
|
19 | + } | |
|
20 | + | |
|
21 | + %div{style: "position: relative; width: #{graph_width}px; height: 150px; background-color:#fff;" } | |
|
22 | + //draw background | |
|
23 | + - histogram[:data].each_index do |i| | |
|
24 | + - height = histogram[:data][i] * graph_height / histogram[:summary][:max] | |
|
25 | + - top = graph_height - height | |
|
26 | + - left = graph_width - (i+1)*bar_width | |
|
27 | + %div.hist_fill{style: "top: 0px; height: #{graph_height - height}px; left: #{left}px;" } | |
|
28 | + // draw horizontal line | |
|
29 | + - line = 3 | |
|
30 | + - line.times do |i| | |
|
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;"} | |
|
33 | + %div.hist_text{style: "position:absolute;left: 0px;top:#{top-6}px"} | |
|
34 | + =((i+0.5) * histogram[:summary][:max] / line).to_i | |
|
35 | + // draw the actual bar and text | |
|
36 | + - @histogram[:data].each_index do |i| | |
|
37 | + - height = histogram[:data][i] * graph_height / histogram[:summary][:max] | |
|
38 | + - top = graph_height - height | |
|
39 | + - left = graph_width - (i+1)*bar_width | |
|
40 | + %div.hist_bar{style: "top: #{top}px; height: #{height}px; left: #{left}px; dae: #{histogram[:data][i]}" } | |
|
41 | + - if i % 7 == 1 | |
|
42 | + %div.hist_text{style: "top:#{graph_height + 5}px;left: #{left}px;"} #{(Time.zone.today - i.day).strftime('%-d')} | |
|
43 | + - if (Time.now.in_time_zone - i.day).day == 15 | |
|
44 | + %div.hist_text{style: "top:#{graph_height + 15}px;left: #{left}px;"} #{(Time.zone.today - i.day).strftime('%b')} |
@@ -105,101 +105,116 | |||
|
105 | 105 | out_filename = "#{out_dirname}/#{@problem.name}.pdf" |
|
106 | 106 | if FileTest.exists? out_filename |
|
107 | 107 | File.delete out_filename |
|
108 | 108 | end |
|
109 | 109 | |
|
110 | 110 | File.open(out_filename,"wb") do |file| |
|
111 | 111 | file.write(params[:file].read) |
|
112 | 112 | end |
|
113 | 113 | @problem.description_filename = "#{@problem.name}.pdf" |
|
114 | 114 | @problem.save |
|
115 | 115 | end |
|
116 | 116 | redirect_to :action => 'show', :id => @problem |
|
117 | 117 | else |
|
118 | 118 | render :action => 'edit' |
|
119 | 119 | end |
|
120 | 120 | end |
|
121 | 121 | |
|
122 | 122 | def destroy |
|
123 | 123 | Problem.find(params[:id]).destroy |
|
124 | 124 | redirect_to :action => 'list' |
|
125 | 125 | end |
|
126 | 126 | |
|
127 | 127 | def toggle |
|
128 | 128 | @problem = Problem.find(params[:id]) |
|
129 | 129 | @problem.available = !(@problem.available) |
|
130 | 130 | @problem.save |
|
131 | 131 | end |
|
132 | 132 | |
|
133 | 133 | def turn_all_off |
|
134 | 134 | Problem.find(:all, |
|
135 | 135 | :conditions => "available = 1").each do |problem| |
|
136 | 136 | problem.available = false |
|
137 | 137 | problem.save |
|
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 | - else | |
|
155 | + return | |
|
156 | + end | |
|
156 | 157 |
|
|
158 | + | |
|
159 | + #stat summary | |
|
160 | + range =65 | |
|
161 | + @histogram = { data: Array.new(range,0), summary: {} } | |
|
162 | + @histogram[:data] = Array.new(range,0) | |
|
163 | + user = Hash.new(0) | |
|
164 | + @submissions.find_each do |sub| | |
|
165 | + d = (DateTime.now.in_time_zone - sub.submitted_at) / 24 / 60 / 60 | |
|
166 | + @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 | |
|
157 | 168 | end |
|
169 | + @histogram[:summary][:max] = [@histogram[:data].max,1].max | |
|
170 | + | |
|
171 | + @summary = { attempt: user.count, solve: 0 } | |
|
172 | + user.each_value { |v| @summary[:solve] += 1 if v == 1 } | |
|
158 | 173 | end |
|
159 | 174 | |
|
160 | 175 | def manage |
|
161 | 176 | @problems = Problem.find(:all, :order => 'date_added DESC') |
|
162 | 177 | end |
|
163 | 178 | |
|
164 | 179 | def do_manage |
|
165 | 180 | if params.has_key? 'change_date_added' |
|
166 | 181 | change_date_added |
|
167 | 182 | elsif params.has_key? 'add_to_contest' |
|
168 | 183 | add_to_contest |
|
169 | 184 | elsif params.has_key? 'enable_problem' |
|
170 | 185 | set_available(true) |
|
171 | 186 | elsif params.has_key? 'disable_problem' |
|
172 | 187 | set_available(false) |
|
173 | 188 | end |
|
174 | 189 | redirect_to :action => 'manage' |
|
175 | 190 | end |
|
176 | 191 | |
|
177 | 192 | def import |
|
178 | 193 | @allow_test_pair_import = allow_test_pair_import? |
|
179 | 194 | end |
|
180 | 195 | |
|
181 | 196 | def do_import |
|
182 | 197 | old_problem = Problem.find_by_name(params[:name]) |
|
183 | 198 | if !allow_test_pair_import? and params.has_key? :import_to_db |
|
184 | 199 | params.delete :import_to_db |
|
185 | 200 | end |
|
186 | 201 | @problem, import_log = Problem.create_from_import_form_params(params, |
|
187 | 202 | old_problem) |
|
188 | 203 | |
|
189 | 204 | if !@problem.errors.empty? |
|
190 | 205 | render :action => 'import' and return |
|
191 | 206 | end |
|
192 | 207 | |
|
193 | 208 | if old_problem!=nil |
|
194 | 209 | flash[:notice] = "The test data has been replaced for problem #{@problem.name}" |
|
195 | 210 | end |
|
196 | 211 | @log = import_log |
|
197 | 212 | end |
|
198 | 213 | |
|
199 | 214 | def remove_contest |
|
200 | 215 | problem = Problem.find(params[:id]) |
|
201 | 216 | contest = Contest.find(params[:contest_id]) |
|
202 | 217 | if problem!=nil and contest!=nil |
|
203 | 218 | problem.contests.delete(contest) |
|
204 | 219 | end |
|
205 | 220 | redirect_to :action => 'manage' |
@@ -212,49 +227,52 | |||
|
212 | 227 | if defined? ALLOW_TEST_PAIR_IMPORT |
|
213 | 228 | return ALLOW_TEST_PAIR_IMPORT |
|
214 | 229 | else |
|
215 | 230 | return false |
|
216 | 231 | end |
|
217 | 232 | end |
|
218 | 233 | |
|
219 | 234 | def change_date_added |
|
220 | 235 | problems = get_problems_from_params |
|
221 | 236 | year = params[:date_added][:year].to_i |
|
222 | 237 | month = params[:date_added][:month].to_i |
|
223 | 238 | day = params[:date_added][:day].to_i |
|
224 | 239 | date = Date.new(year,month,day) |
|
225 | 240 | problems.each do |p| |
|
226 | 241 | p.date_added = date |
|
227 | 242 | p.save |
|
228 | 243 | end |
|
229 | 244 | end |
|
230 | 245 | |
|
231 | 246 | def add_to_contest |
|
232 | 247 | problems = get_problems_from_params |
|
233 | 248 | contest = Contest.find(params[:contest][:id]) |
|
234 | 249 | if contest!=nil and contest.enabled |
|
235 | 250 | problems.each do |p| |
|
236 | 251 | p.contests << contest |
|
237 | 252 | end |
|
238 | 253 | end |
|
239 | 254 | end |
|
240 | 255 | |
|
241 | 256 | def set_available(avail) |
|
242 | 257 | problems = get_problems_from_params |
|
243 | 258 | problems.each do |p| |
|
244 | 259 | p.available = avail |
|
245 | 260 | p.save |
|
246 | 261 | end |
|
247 | 262 | end |
|
248 | 263 | |
|
249 | 264 | def get_problems_from_params |
|
250 | 265 | problems = [] |
|
251 | 266 | params.keys.each do |k| |
|
252 | 267 | if k.index('prob-')==0 |
|
253 | 268 | name, id, order = k.split('-') |
|
254 | 269 | problems << Problem.find(id) |
|
255 | 270 | end |
|
256 | 271 | end |
|
257 | 272 | problems |
|
258 | 273 | end |
|
259 | 274 | |
|
275 | + def get_problems_stat | |
|
260 | 276 | end |
|
277 | + | |
|
278 | + end |
@@ -60,136 +60,133 | |||
|
60 | 60 | begin |
|
61 | 61 | @until_time = DateTime.strptime(params[:until_datetime],date_and_time) |
|
62 | 62 | rescue |
|
63 | 63 | @until_time = DateTime.new(3000,1,1) |
|
64 | 64 | end |
|
65 | 65 | |
|
66 | 66 | @submissions = {} |
|
67 | 67 | |
|
68 | 68 | User.find_each do |user| |
|
69 | 69 | @submissions[user.id] = { login: user.login, full_name: user.full_name, count: 0, sub: { } } |
|
70 | 70 | end |
|
71 | 71 | |
|
72 | 72 | Submission.where("submitted_at >= ? AND submitted_at <= ?",@since_time,@until_time).find_each do |s| |
|
73 | 73 | if @submissions[s.user_id] |
|
74 | 74 | if not @submissions[s.user_id][:sub].has_key?(s.problem_id) |
|
75 | 75 | a = nil |
|
76 | 76 | begin |
|
77 | 77 | a = Problem.find(s.problem_id) |
|
78 | 78 | rescue |
|
79 | 79 | a = nil |
|
80 | 80 | end |
|
81 | 81 | @submissions[s.user_id][:sub][s.problem_id] = |
|
82 | 82 | { prob_name: (a ? a.full_name : '(NULL)'), |
|
83 | 83 | sub_ids: [s.id] } |
|
84 | 84 | else |
|
85 | 85 | @submissions[s.user_id][:sub][s.problem_id][:sub_ids] << s.id |
|
86 | 86 | end |
|
87 | 87 | @submissions[s.user_id][:count] += 1 |
|
88 | 88 | end |
|
89 | 89 | end |
|
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 |
- |
|
|
109 | - #aggregrate by language | |
|
110 | - @by_lang = {} | |
|
108 | + return unless @problem | |
|
109 | + | |
|
110 | + @by_lang = {} #aggregrate by language | |
|
111 | + | |
|
112 | + range =65 | |
|
113 | + @histogram = { data: Array.new(range,0), summary: {} } | |
|
114 | + @histogram[:data] = Array.new(range,0) | |
|
115 | + @summary = {count: 0, solve: 0, attempt: 0} | |
|
116 | + user = Hash.new(0) | |
|
111 | 117 |
|
|
118 | + #histogram | |
|
119 | + d = (DateTime.now.in_time_zone - sub.submitted_at) / 24 / 60 / 60 | |
|
120 | + @histogram[:data][d.to_i] += 1 if d < range | |
|
121 | + | |
|
122 | + @summary[:count] += 1 | |
|
123 | + user[sub.user_id] = [user[sub.user_id], (sub.points >= @problem.full_score) ? 1 : 0].max | |
|
124 | + | |
|
112 | 125 |
|
|
113 | 126 |
|
|
114 | 127 |
|
|
115 | 128 | |
|
116 | 129 |
|
|
117 | 130 |
|
|
118 | 131 |
|
|
119 | 132 |
|
|
120 | 133 |
|
|
121 | 134 |
|
|
122 | 135 |
|
|
123 | 136 |
|
|
124 | 137 |
|
|
125 | 138 | |
|
126 | 139 |
|
|
127 | - @by_lang[lang.pretty_name][:runtime] = { | |
|
128 | - avail: true, | |
|
129 | - user_id: sub.user_id, | |
|
130 | - value: sub.max_runtime, | |
|
131 | - sub_id: sub.id | |
|
132 | - } | |
|
140 | + @by_lang[lang.pretty_name][:runtime] = { avail: true, user_id: sub.user_id, value: sub.max_runtime, sub_id: sub.id } | |
|
133 | 141 |
|
|
134 | 142 | |
|
135 | 143 |
|
|
136 | - @by_lang[lang.pretty_name][:memory] = { | |
|
137 | - avail: true, | |
|
138 | - user_id: sub.user_id, | |
|
139 | - value: sub.peak_memory, | |
|
140 | - sub_id: sub.id | |
|
141 | - } | |
|
144 | + @by_lang[lang.pretty_name][:memory] = { avail: true, user_id: sub.user_id, value: sub.peak_memory, sub_id: sub.id } | |
|
142 | 145 |
|
|
143 | 146 | |
|
144 | 147 |
|
|
145 | 148 |
|
|
146 | - @by_lang[lang.pretty_name][:first] = { | |
|
147 | - avail: true, | |
|
148 | - user_id: sub.user_id, | |
|
149 | - value: sub.submitted_at, | |
|
150 | - sub_id: sub.id | |
|
151 | - } | |
|
149 | + @by_lang[lang.pretty_name][:first] = { avail: true, user_id: sub.user_id, value: sub.submitted_at, sub_id: sub.id } | |
|
152 | 150 |
|
|
153 | 151 | |
|
154 | 152 |
|
|
155 | - @by_lang[lang.pretty_name][:length] = { | |
|
156 | - avail: true, | |
|
157 | - user_id: sub.user_id, | |
|
158 | - value: sub.effective_code_length, | |
|
159 | - sub_id: sub.id | |
|
160 | - } | |
|
153 | + @by_lang[lang.pretty_name][:length] = { avail: true, user_id: sub.user_id, value: sub.effective_code_length, sub_id: sub.id } | |
|
161 | 154 |
|
|
162 | 155 |
|
|
163 | 156 | |
|
164 | 157 |
|
|
165 | 158 |
|
|
166 | 159 |
|
|
167 | 160 |
|
|
168 | 161 |
|
|
169 | 162 |
|
|
170 | 163 | |
|
171 | 164 |
|
|
172 | 165 |
|
|
173 | 166 |
|
|
174 | 167 |
|
|
175 | 168 |
|
|
176 | 169 |
|
|
177 | 170 |
|
|
178 | 171 |
|
|
179 | 172 |
|
|
180 | 173 |
|
|
181 | 174 |
|
|
182 | 175 |
|
|
183 | 176 |
|
|
184 | 177 |
|
|
185 | 178 |
|
|
186 | 179 |
|
|
187 | 180 |
|
|
188 | 181 |
|
|
189 | 182 |
|
|
190 | 183 |
|
|
191 | 184 |
|
|
192 | 185 |
|
|
193 | - end | |
|
186 | + | |
|
187 | + @histogram[:summary][:max] = [@histogram[:data].max,1].max | |
|
188 | + @summary[:attempt] = user.count | |
|
189 | + user.each_value { |v| @summary[:solve] += 1 if v == 1 } | |
|
194 | 190 | end |
|
191 | + | |
|
195 | 192 | end |
@@ -10,96 +10,103 | |||
|
10 | 10 | |
|
11 | 11 | scope :available, :conditions => {:available => true} |
|
12 | 12 | |
|
13 | 13 | DEFAULT_TIME_LIMIT = 1 |
|
14 | 14 | DEFAULT_MEMORY_LIMIT = 32 |
|
15 | 15 | |
|
16 | 16 | def self.find_available_problems |
|
17 | 17 | Problem.available.all(:order => "date_added DESC, name ASC") |
|
18 | 18 | end |
|
19 | 19 | |
|
20 | 20 | def self.create_from_import_form_params(params, old_problem=nil) |
|
21 | 21 | org_problem = old_problem || Problem.new |
|
22 | 22 | import_params, problem = Problem.extract_params_and_check(params, |
|
23 | 23 | org_problem) |
|
24 | 24 | |
|
25 | 25 | if !problem.errors.empty? |
|
26 | 26 | return problem, 'Error importing' |
|
27 | 27 | end |
|
28 | 28 | |
|
29 | 29 | problem.full_score = 100 |
|
30 | 30 | problem.date_added = Time.new |
|
31 | 31 | problem.test_allowed = true |
|
32 | 32 | problem.output_only = false |
|
33 | 33 | problem.available = false |
|
34 | 34 | |
|
35 | 35 | if not problem.save |
|
36 | 36 | return problem, 'Error importing' |
|
37 | 37 | end |
|
38 | 38 | |
|
39 | 39 | import_to_db = params.has_key? :import_to_db |
|
40 | 40 | |
|
41 | 41 | importer = TestdataImporter.new(problem) |
|
42 | 42 | |
|
43 | 43 | if not importer.import_from_file(import_params[:file], |
|
44 | 44 | import_params[:time_limit], |
|
45 | 45 | import_params[:memory_limit], |
|
46 | 46 | import_params[:checker_name], |
|
47 | 47 | import_to_db) |
|
48 | 48 | problem.errors.add_to_base('Import error.') |
|
49 | 49 | end |
|
50 | 50 | |
|
51 | 51 | return problem, importer.log_msg |
|
52 | 52 | end |
|
53 | 53 | |
|
54 | 54 | def self.download_file_basedir |
|
55 | 55 | return "#{Rails.root}/data/tasks" |
|
56 | 56 | end |
|
57 | 57 | |
|
58 | + def get_submission_stat | |
|
59 | + result = Hash.new | |
|
60 | + #total number of submission | |
|
61 | + result[:total_sub] = Submission.where(problem_id: self.id).count | |
|
62 | + result[:attempted_user] = Submission.where(problem_id: self.id).group_by(:user_id) | |
|
63 | + end | |
|
64 | + | |
|
58 | 65 | protected |
|
59 | 66 | |
|
60 | 67 | def self.to_i_or_default(st, default) |
|
61 | 68 | if st!='' |
|
62 | 69 | result = st.to_i |
|
63 | 70 | end |
|
64 | 71 | result ||= default |
|
65 | 72 | end |
|
66 | 73 | |
|
67 | 74 | def self.to_f_or_default(st, default) |
|
68 | 75 | if st!='' |
|
69 | 76 | result = st.to_f |
|
70 | 77 | end |
|
71 | 78 | result ||= default |
|
72 | 79 | end |
|
73 | 80 | |
|
74 | 81 | def self.extract_params_and_check(params, problem) |
|
75 | 82 | time_limit = Problem.to_f_or_default(params[:time_limit], |
|
76 | 83 | DEFAULT_TIME_LIMIT) |
|
77 | 84 | memory_limit = Problem.to_i_or_default(params[:memory_limit], |
|
78 | 85 | DEFAULT_MEMORY_LIMIT) |
|
79 | 86 | |
|
80 | 87 | if time_limit<=0 or time_limit >60 |
|
81 | 88 | problem.errors.add_to_base('Time limit out of range.') |
|
82 | 89 | end |
|
83 | 90 | |
|
84 | 91 | if memory_limit==0 and params[:memory_limit]!='0' |
|
85 | 92 | problem.errors.add_to_base('Memory limit format errors.') |
|
86 | 93 | elsif memory_limit<=0 or memory_limit >512 |
|
87 | 94 | problem.errors.add_to_base('Memory limit out of range.') |
|
88 | 95 | end |
|
89 | 96 | |
|
90 | 97 | if params[:file]==nil or params[:file]=='' |
|
91 | 98 | problem.errors.add_to_base('No testdata file.') |
|
92 | 99 | end |
|
93 | 100 | |
|
94 | 101 | checker_name = 'text' |
|
95 | 102 | if ['text','float'].include? params[:checker] |
|
96 | 103 | checker_name = params[:checker] |
|
97 | 104 | end |
|
98 | 105 | |
|
99 | 106 | file = params[:file] |
|
100 | 107 | |
|
101 | 108 | if !problem.errors.empty? |
|
102 | 109 | return nil, problem |
|
103 | 110 | end |
|
104 | 111 | |
|
105 | 112 | problem.name = params[:name] |
@@ -1,34 +1,51 | |||
|
1 | 1 | :css |
|
2 | 2 | .fix-width { |
|
3 | 3 | font-family: "Consolas, Monaco, Droid Sans Mono,Mono, Monospace,Courier" |
|
4 | 4 | } |
|
5 | 5 | |
|
6 | 6 | %h1 Problem stat: #{@problem.name} |
|
7 | 7 | %h2 Overview |
|
8 | 8 | |
|
9 | + | |
|
10 | + %table.info | |
|
11 | + %thead | |
|
12 | + %tr.info-head | |
|
13 | + %th Stat | |
|
14 | + %th Value | |
|
15 | + %tbody | |
|
16 | + %tr{class: cycle('info-even','info-odd')} | |
|
17 | + %td Submissions | |
|
18 | + %td= @submissions.count | |
|
19 | + %tr{class: cycle('info-even','info-odd')} | |
|
20 | + %td Solved/Attempted User | |
|
21 | + %td #{@summary[:solve]}/#{@summary[:attempt]} (#{(@summary[:solve]*100.0/@summary[:attempt]).round(1)}%) | |
|
22 | + | |
|
23 | + %h2 Submissions Count | |
|
24 | + = render partial: 'application/bar_graph', locals: { histogram: @histogram } | |
|
25 | + | |
|
9 | 26 | %h2 Submissions |
|
10 | 27 | - if @submissions and @submissions.count > 0 |
|
11 | 28 | %table.info#main_table |
|
12 | 29 | %thead |
|
13 | 30 | %tr.info-head |
|
14 | 31 | %th ID |
|
15 | 32 | %th Login |
|
16 | 33 | %th Name |
|
17 | 34 | %th Submitted_at |
|
18 | 35 | %th Points |
|
19 | 36 | %th comment |
|
20 | 37 | %tbody |
|
21 | 38 | - row_odd,curr = true,'' |
|
22 | 39 | - @submissions.each do |sub| |
|
23 | 40 | - next unless sub.user |
|
24 | 41 | - row_odd,curr = !row_odd, sub.user if curr != sub.user |
|
25 | 42 | %tr{class: row_odd ? "info-odd" : "info-even"} |
|
26 | 43 | %td= link_to sub.id, controller: 'graders', action: 'submission', id: sub.id |
|
27 | 44 | %td= link_to sub.user.login, controller: :users, action: :profile, id: sub.user.id |
|
28 | 45 | %td= sub.user.full_name |
|
29 | 46 | %td= time_ago_in_words(sub.submitted_at) + " ago" |
|
30 | 47 | %td= sub.points |
|
31 | 48 | %td.fix-width= sub.grader_comment |
|
32 | 49 | - else |
|
33 | 50 | No submission |
|
34 | 51 |
@@ -1,79 +1,96 | |||
|
1 | 1 | :css |
|
2 | 2 | .hof_user { color: orangered; font-style: italic; } |
|
3 | 3 | .hof_language { color: green; font-style: italic; } |
|
4 | 4 | .hof_value { color: deeppink;font-style: italic; } |
|
5 | + .info_param { font-weight: bold;text-align: right; } | |
|
5 | 6 | |
|
6 |
- %h |
|
|
7 | + %h1 (#{Problem.find(params[:id]).name}) #{Problem.find(params[:id]).full_name} | |
|
7 | 8 | |
|
9 | + %h2 Problem Stat | |
|
10 | + %table.info | |
|
11 | + %thead | |
|
12 | + %tr.info-head | |
|
13 | + %th Stat | |
|
14 | + %th Value | |
|
15 | + %tbody | |
|
16 | + %tr{class: cycle('info-even','info-odd')} | |
|
17 | + %td.info_param Submissions | |
|
18 | + %td= @summary[:count] | |
|
19 | + %tr{class: cycle('info-even','info-odd')} | |
|
20 | + %td.info_param Solved/Attempted User | |
|
21 | + %td #{@summary[:solve]}/#{@summary[:attempt]} (#{(@summary[:solve]*100.0/@summary[:attempt]).round(1)}%) | |
|
8 | 22 | - if @best |
|
9 | - %b Best Runtime: | |
|
23 | + %tr{class: cycle('info-even','info-odd')} | |
|
24 | + %td.info_param Best Runtime | |
|
25 | + %td | |
|
10 | 26 | by #{link_to @best[:runtime][:user], controller:'users', action:'profile', id:@best[:memory][:user_id]} |
|
11 | 27 | using <span class="hof_language">#{@best[:runtime][:lang]}</span> |
|
12 | 28 | with <span class="hof_value">#{@best[:runtime][:value] * 1000} milliseconds</span> |
|
13 | 29 | at submission |
|
14 | 30 | = link_to("#" + @best[:runtime][:sub_id].to_s, controller: 'graders', action: 'submission', id:@best[:runtime][:sub_id]) |
|
15 | - %br/ | |
|
16 | 31 | |
|
17 | - %b Best Memory Usage: | |
|
32 | + %tr{class: cycle('info-even','info-odd')} | |
|
33 | + %td.info_param Best Memory Usage | |
|
34 | + %td | |
|
18 | 35 | by #{link_to @best[:memory][:user], controller:'users', action:'profile', id:@best[:memory][:user_id]} |
|
19 | 36 | using <span class="hof_language">#{@best[:memory][:lang]}</span> |
|
20 | 37 | with <span class="hof_value">#{number_with_delimiter(@best[:memory][:value])} kbytes </span> |
|
21 | 38 | at submission |
|
22 | 39 | = link_to("#" + @best[:memory][:sub_id].to_s, controller: 'graders' , action: 'submission', id:@best[:memory][:sub_id]) |
|
23 | - %br/ | |
|
24 | 40 | |
|
25 | - %b Shortest Code: | |
|
41 | + %tr{class: cycle('info-even','info-odd')} | |
|
42 | + %td.info_param Shortest Code | |
|
43 | + %td | |
|
26 | 44 | by #{link_to @best[:length][:user], controller:'users', action:'profile', id:@best[:length][:user_id]} |
|
27 | 45 | using <span class="hof_language">#{@best[:length][:lang]}</span> |
|
28 | 46 | with <span class="hof_value">#{@best[:length][:value]} bytes</span> |
|
29 | 47 | at submission |
|
30 | 48 | = link_to("#" + @best[:length][:sub_id].to_s, controller: 'graders' , action: 'submission', id: @best[:length][:sub_id]) |
|
31 | - %br/ | |
|
32 | 49 | |
|
33 | - %b First solver: | |
|
50 | + %tr{class: cycle('info-even','info-odd')} | |
|
51 | + %td.info_param First solver | |
|
52 | + %td | |
|
34 | 53 | #{link_to @best[:first][:user], controller:'users', action:'profile', id:@best[:first][:user_id]} is the first solver |
|
35 | 54 | using <span class="hof_language">#{@best[:first][:lang]}</span> |
|
36 | 55 | on <span class="hof_value">#{@best[:first][:value]}</span> |
|
37 | 56 | at submission |
|
38 | 57 | = link_to("#" + @best[:first][:sub_id].to_s, controller: 'graders' , action: 'submission', id: @best[:first][:sub_id]) |
|
39 | - %br/ | |
|
40 | 58 | |
|
41 | 59 | |
|
42 | 60 |
|
|
43 | 61 |
|
|
44 | 62 |
|
|
45 | 63 | |
|
64 | + - if @best | |
|
46 | 65 | %h2 By language |
|
47 | 66 | |
|
48 | 67 | %table.info |
|
49 | 68 | %thead |
|
50 | 69 | %tr.info-head |
|
51 | 70 | %th Language |
|
52 | 71 | %th Best runtime (ms) |
|
53 | 72 | %th Best memory (kbytes) |
|
54 | 73 | %th Shortest Code (bytes) |
|
55 | 74 | %th First solver |
|
56 | 75 | %tbody |
|
57 | 76 | - @by_lang.each do |lang,value| |
|
58 | 77 | %tr{class: cycle('info-even','info-odd')} |
|
59 | 78 | %td= lang |
|
60 | 79 | %td |
|
61 | 80 | = link_to value[:runtime][:user], controller: 'users', action: 'profile', id: value[:runtime][:user_id] |
|
62 | 81 | = "(#{(value[:runtime][:value] * 1000).to_i} @" |
|
63 | 82 | = "#{link_to("#" + value[:runtime][:sub_id].to_s, controller: 'graders' , action: 'submission', id: value[:runtime][:sub_id])} )".html_safe |
|
64 | 83 | %td |
|
65 | 84 | = link_to value[:memory][:user], controller: 'users', action: 'profile', id: value[:memory][:user_id] |
|
66 | 85 | = "(#{number_with_delimiter(value[:memory][:value])} @" |
|
67 | 86 | = "#{link_to("#" + value[:memory][:sub_id].to_s, controller: 'graders' , action: 'submission', id: value[:memory][:sub_id])} )".html_safe |
|
68 | 87 | %td |
|
69 | 88 | = link_to value[:length][:user], controller: 'users', action: 'profile', id: value[:length][:user_id] |
|
70 | 89 | = "(#{value[:length][:value]} @" |
|
71 | 90 | = "#{link_to("#" + value[:length][:sub_id].to_s, controller: 'graders' , action: 'submission', id: value[:length][:sub_id])} )".html_safe |
|
72 | 91 | %td |
|
73 | 92 | - if value[:first][:user] != '(NULL)' #TODO: i know... this is wrong... |
|
74 | 93 | = link_to value[:first][:user], controller: 'users', action: 'profile', id: value[:first][:user_id] |
|
75 | 94 | = "(#{value[:first][:value]} @" |
|
76 | 95 | = "#{link_to("#" + value[:first][:sub_id].to_s, controller: 'graders' , action: 'submission', id: value[:first][:sub_id])} )".html_safe |
|
77 | 96 | |
|
78 | - - else | |
|
79 | - %h3 No submissions |
@@ -1,22 +1,23 | |||
|
1 | 1 | |
|
2 | 2 | /- if params[:id] |
|
3 | 3 | / %h1 Tasks Hall of Fame |
|
4 | 4 | / = link_to('[back to All-Time Hall of Fame]', action: 'problem_hof', id: nil ) |
|
5 | 5 | /- else |
|
6 | 6 | / %h1 All-Time Hall of Fame |
|
7 | 7 | |
|
8 | 8 | |
|
9 |
- %h1 |
|
|
9 | + %h1 Hall of Fame | |
|
10 | 10 | .task-menu |
|
11 | 11 | Tasks |
|
12 | 12 | %br/ |
|
13 | 13 | - @problems.each do |prob| |
|
14 | 14 | = link_to( "[#{prob.name}]", {id: prob.id}) |
|
15 | 15 | |
|
16 | 16 | - unless params[:id] |
|
17 | 17 | /=render partial: 'all_time_hof' |
|
18 | 18 | Please select a problem. |
|
19 | 19 | - else |
|
20 | 20 | =render partial: 'task_hof' |
|
21 | + %h2 Submission History | |
|
22 | + =render partial: 'application/bar_graph', locals: { histogram: @histogram } | |
|
21 | 23 | |
|
22 | - |
You need to be logged in to leave comments.
Login now