Description:
fix download score in user_stat not working
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r499:1da8597120e1 - - 1 file changed: 6 inserted, 0 deleted
@@ -129,48 +129,54 | |||
|
129 | 129 | redirect_to :action => 'list' |
|
130 | 130 | end |
|
131 | 131 | |
|
132 | 132 | def user_stat |
|
133 | 133 | if params[:commit] == 'download csv' |
|
134 | 134 | @problems = Problem.all |
|
135 | 135 | else |
|
136 | 136 | @problems = Problem.find_available_problems |
|
137 | 137 | end |
|
138 | 138 | @users = User.find(:all, :include => [:contests, :contest_stat]) |
|
139 | 139 | @scorearray = Array.new |
|
140 | 140 | @users.each do |u| |
|
141 | 141 | ustat = Array.new |
|
142 | 142 | ustat[0] = u |
|
143 | 143 | @problems.each do |p| |
|
144 | 144 | sub = Submission.find_last_by_user_and_problem(u.id,p.id) |
|
145 | 145 | if (sub!=nil) and (sub.points!=nil) |
|
146 | 146 | ustat << [(sub.points.to_f*100/p.full_score).round, (sub.points>=p.full_score)] |
|
147 | 147 | else |
|
148 | 148 | ustat << [0,false] |
|
149 | 149 | end |
|
150 | 150 | end |
|
151 | 151 | @scorearray << ustat |
|
152 | 152 | end |
|
153 | + if params[:commit] == 'download csv' then | |
|
154 | + csv = gen_csv_from_scorearray(@scorearray,@problems) | |
|
155 | + send_data csv, filename: 'last_score.csv' | |
|
156 | + else | |
|
157 | + render template: 'user_admin/user_stat' | |
|
158 | + end | |
|
153 | 159 | end |
|
154 | 160 | |
|
155 | 161 | def user_stat_max |
|
156 | 162 | if params[:commit] == 'download csv' |
|
157 | 163 | @problems = Problem.all |
|
158 | 164 | else |
|
159 | 165 | @problems = Problem.find_available_problems |
|
160 | 166 | end |
|
161 | 167 | @users = User.find(:all, :include => [:contests, :contest_stat]) |
|
162 | 168 | @scorearray = Array.new |
|
163 | 169 | #set up range from param |
|
164 | 170 | since_id = params.fetch(:since_id, 0).to_i |
|
165 | 171 | until_id = params.fetch(:until_id, 0).to_i |
|
166 | 172 | @users.each do |u| |
|
167 | 173 | ustat = Array.new |
|
168 | 174 | ustat[0] = u |
|
169 | 175 | @problems.each do |p| |
|
170 | 176 | max_points = 0 |
|
171 | 177 | Submission.find_in_range_by_user_and_problem(u.id,p.id,since_id,until_id).each do |sub| |
|
172 | 178 | max_points = sub.points if sub and sub.points and (sub.points > max_points) |
|
173 | 179 | end |
|
174 | 180 | ustat << [(max_points.to_f*100/p.full_score).round, (max_points>=p.full_score)] |
|
175 | 181 | end |
|
176 | 182 | @scorearray << ustat |
You need to be logged in to leave comments.
Login now