Description:
add check for nil problem
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r527:662f5e0a87b8 - - 1 file changed: 1 inserted, 1 deleted
@@ -121,49 +121,49 | |||||
|
121 | redirect_to :action => 'show', :id => @user |
|
121 | redirect_to :action => 'show', :id => @user |
|
122 | else |
|
122 | else |
|
123 | render :action => 'edit' |
|
123 | render :action => 'edit' |
|
124 | end |
|
124 | end |
|
125 | end |
|
125 | end |
|
126 |
|
126 | ||
|
127 | def destroy |
|
127 | def destroy |
|
128 | User.find(params[:id]).destroy |
|
128 | User.find(params[:id]).destroy |
|
129 | redirect_to :action => 'list' |
|
129 | redirect_to :action => 'list' |
|
130 | end |
|
130 | end |
|
131 |
|
131 | ||
|
132 | def user_stat |
|
132 | def user_stat |
|
133 | if params[:commit] == 'download csv' |
|
133 | if params[:commit] == 'download csv' |
|
134 | @problems = Problem.all |
|
134 | @problems = Problem.all |
|
135 | else |
|
135 | else |
|
136 | @problems = Problem.find_available_problems |
|
136 | @problems = Problem.find_available_problems |
|
137 | end |
|
137 | end |
|
138 | @users = User.find(:all, :include => [:contests, :contest_stat]) |
|
138 | @users = User.find(:all, :include => [:contests, :contest_stat]) |
|
139 | @scorearray = Array.new |
|
139 | @scorearray = Array.new |
|
140 | @users.each do |u| |
|
140 | @users.each do |u| |
|
141 | ustat = Array.new |
|
141 | ustat = Array.new |
|
142 | ustat[0] = u |
|
142 | ustat[0] = u |
|
143 | @problems.each do |p| |
|
143 | @problems.each do |p| |
|
144 | sub = Submission.find_last_by_user_and_problem(u.id,p.id) |
|
144 | sub = Submission.find_last_by_user_and_problem(u.id,p.id) |
|
145 | - if (sub!=nil) and (sub.points!=nil) |
|
145 | + if (sub!=nil) and (sub.points!=nil) and p and p.full_score |
|
146 | ustat << [(sub.points.to_f*100/p.full_score).round, (sub.points>=p.full_score)] |
|
146 | ustat << [(sub.points.to_f*100/p.full_score).round, (sub.points>=p.full_score)] |
|
147 | else |
|
147 | else |
|
148 | ustat << [0,false] |
|
148 | ustat << [0,false] |
|
149 | end |
|
149 | end |
|
150 | end |
|
150 | end |
|
151 | @scorearray << ustat |
|
151 | @scorearray << ustat |
|
152 | end |
|
152 | end |
|
153 | if params[:commit] == 'download csv' then |
|
153 | if params[:commit] == 'download csv' then |
|
154 | csv = gen_csv_from_scorearray(@scorearray,@problems) |
|
154 | csv = gen_csv_from_scorearray(@scorearray,@problems) |
|
155 | send_data csv, filename: 'last_score.csv' |
|
155 | send_data csv, filename: 'last_score.csv' |
|
156 | else |
|
156 | else |
|
157 | render template: 'user_admin/user_stat' |
|
157 | render template: 'user_admin/user_stat' |
|
158 | end |
|
158 | end |
|
159 | end |
|
159 | end |
|
160 |
|
160 | ||
|
161 | def user_stat_max |
|
161 | def user_stat_max |
|
162 | if params[:commit] == 'download csv' |
|
162 | if params[:commit] == 'download csv' |
|
163 | @problems = Problem.all |
|
163 | @problems = Problem.all |
|
164 | else |
|
164 | else |
|
165 | @problems = Problem.find_available_problems |
|
165 | @problems = Problem.find_available_problems |
|
166 | end |
|
166 | end |
|
167 | @users = User.find(:all, :include => [:contests, :contest_stat]) |
|
167 | @users = User.find(:all, :include => [:contests, :contest_stat]) |
|
168 | @scorearray = Array.new |
|
168 | @scorearray = Array.new |
|
169 | #set up range from param |
|
169 | #set up range from param |
You need to be logged in to leave comments.
Login now