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 | 121 | redirect_to :action => 'show', :id => @user |
|
122 | 122 | else |
|
123 | 123 | render :action => 'edit' |
|
124 | 124 | end |
|
125 | 125 | end |
|
126 | 126 | |
|
127 | 127 | def destroy |
|
128 | 128 | User.find(params[:id]).destroy |
|
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 | - if (sub!=nil) and (sub.points!=nil) | |
|
145 | + if (sub!=nil) and (sub.points!=nil) and p and p.full_score | |
|
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 | 153 | if params[:commit] == 'download csv' then |
|
154 | 154 | csv = gen_csv_from_scorearray(@scorearray,@problems) |
|
155 | 155 | send_data csv, filename: 'last_score.csv' |
|
156 | 156 | else |
|
157 | 157 | render template: 'user_admin/user_stat' |
|
158 | 158 | end |
|
159 | 159 | end |
|
160 | 160 | |
|
161 | 161 | def user_stat_max |
|
162 | 162 | if params[:commit] == 'download csv' |
|
163 | 163 | @problems = Problem.all |
|
164 | 164 | else |
|
165 | 165 | @problems = Problem.find_available_problems |
|
166 | 166 | end |
|
167 | 167 | @users = User.find(:all, :include => [:contests, :contest_stat]) |
|
168 | 168 | @scorearray = Array.new |
|
169 | 169 | #set up range from param |
You need to be logged in to leave comments.
Login now