Description:
merge check multiple login from master (which grafts from java-bm)
Commit status:
[Not Reviewed]
References:
merge algo
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r502:b0abb7bd35dd - - 6 files changed: 84 inserted, 1 deleted

@@ -0,0 +1,37
1 + - content_for :header do
2 + = stylesheet_link_tag 'tablesorter-theme.cafe'
3 + = javascript_include_tag 'local_jquery'
4 +
5 + %h1 Login status
6 +
7 + =render partial: 'report_menu'
8 +
9 + Checking for all submissions with the currently available problem
10 +
11 + %h2 Users with Multiple IP
12 + %table.tablesorter-cafe#my_table
13 + %thead
14 + %tr
15 + %th login
16 + %th full name
17 + %th IP
18 + %tbody
19 + - @users.each do |l|
20 + %tr{class: cycle('info-even','info-odd')}
21 + %td= link_to l.user.login, controller: 'users', action: 'profile', id: l[:id]
22 + %td= l.user.full_name
23 + %td= l[:ip_address]
24 +
25 + %h2 IP with multiple users
26 + %table.tablesorter-cafe#my_table
27 + %thead
28 + %tr
29 + %th IP
30 + %th login
31 + %th full name
32 + %tbody
33 + - @ip.each do |l|
34 + %tr{class: cycle('info-even','info-odd')}
35 + %td= l[:ip_address]
36 + %td= link_to l.user.login, controller: 'users', action: 'profile', id: l[:id]
37 + %td= l.user.full_name
@@ -26,193 +26,230
26 26 @until_time = Time.zone.local(md[1].to_i,md[2].to_i,md[3].to_i,md[4].to_i,md[5].to_i)
27 27 rescue
28 28 @until_time = DateTime.new(3000,1,1)
29 29 end
30 30
31 31 User.all.each do |user|
32 32 @logins << { id: user.id,
33 33 login: user.login,
34 34 full_name: user.full_name,
35 35 count: Login.where("user_id = ? AND created_at >= ? AND created_at <= ?",
36 36 user.id,@since_time,@until_time)
37 37 .count(:id),
38 38 min: Login.where("user_id = ? AND created_at >= ? AND created_at <= ?",
39 39 user.id,@since_time,@until_time)
40 40 .minimum(:created_at),
41 41 max: Login.where("user_id = ? AND created_at >= ? AND created_at <= ?",
42 42 user.id,@since_time,@until_time)
43 43 .maximum(:created_at),
44 44 ip: Login.where("user_id = ? AND created_at >= ? AND created_at <= ?",
45 45 user.id,@since_time,@until_time)
46 46 .select(:ip_address).uniq
47 47
48 48 }
49 49 end
50 50 end
51 51
52 52 def submission_stat
53 53
54 54 date_and_time = '%Y-%m-%d %H:%M'
55 55 begin
56 56 @since_time = DateTime.strptime(params[:since_datetime],date_and_time)
57 57 rescue
58 58 @since_time = DateTime.new(1000,1,1)
59 59 end
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 108 return unless @problem
109 109
110 110 @by_lang = {} #aggregrate by language
111 111
112 112 range =65
113 113 @histogram = { data: Array.new(range,0), summary: {} }
114 114 @summary = {count: 0, solve: 0, attempt: 0}
115 115 user = Hash.new(0)
116 116 Submission.where(problem_id: @problem.id).find_each do |sub|
117 117 #histogram
118 118 d = (DateTime.now.in_time_zone - sub.submitted_at) / 24 / 60 / 60
119 119 @histogram[:data][d.to_i] += 1 if d < range
120 120
121 121 next unless sub.points
122 122 @summary[:count] += 1
123 123 user[sub.user_id] = [user[sub.user_id], (sub.points >= @problem.full_score) ? 1 : 0].max
124 124
125 125 lang = Language.find_by_id(sub.language_id)
126 126 next unless lang
127 127 next unless sub.points >= @problem.full_score
128 128
129 129 #initialize
130 130 unless @by_lang.has_key?(lang.pretty_name)
131 131 @by_lang[lang.pretty_name] = {
132 132 runtime: { avail: false, value: 2**30-1 },
133 133 memory: { avail: false, value: 2**30-1 },
134 134 length: { avail: false, value: 2**30-1 },
135 135 first: { avail: false, value: DateTime.new(3000,1,1) }
136 136 }
137 137 end
138 138
139 139 if sub.max_runtime and sub.max_runtime < @by_lang[lang.pretty_name][:runtime][:value]
140 140 @by_lang[lang.pretty_name][:runtime] = { avail: true, user_id: sub.user_id, value: sub.max_runtime, sub_id: sub.id }
141 141 end
142 142
143 143 if sub.peak_memory and sub.peak_memory < @by_lang[lang.pretty_name][:memory][:value]
144 144 @by_lang[lang.pretty_name][:memory] = { avail: true, user_id: sub.user_id, value: sub.peak_memory, sub_id: sub.id }
145 145 end
146 146
147 147 if sub.submitted_at and sub.submitted_at < @by_lang[lang.pretty_name][:first][:value] and
148 148 !sub.user.admin?
149 149 @by_lang[lang.pretty_name][:first] = { avail: true, user_id: sub.user_id, value: sub.submitted_at, sub_id: sub.id }
150 150 end
151 151
152 152 if @by_lang[lang.pretty_name][:length][:value] > sub.effective_code_length
153 153 @by_lang[lang.pretty_name][:length] = { avail: true, user_id: sub.user_id, value: sub.effective_code_length, sub_id: sub.id }
154 154 end
155 155 end
156 156
157 157 #process user_id
158 158 @by_lang.each do |lang,prop|
159 159 prop.each do |k,v|
160 160 v[:user] = User.exists?(v[:user_id]) ? User.find(v[:user_id]).full_name : "(NULL)"
161 161 end
162 162 end
163 163
164 164 #sum into best
165 165 if @by_lang and @by_lang.first
166 166 @best = @by_lang.first[1].clone
167 167 @by_lang.each do |lang,prop|
168 168 if @best[:runtime][:value] >= prop[:runtime][:value]
169 169 @best[:runtime] = prop[:runtime]
170 170 @best[:runtime][:lang] = lang
171 171 end
172 172 if @best[:memory][:value] >= prop[:memory][:value]
173 173 @best[:memory] = prop[:memory]
174 174 @best[:memory][:lang] = lang
175 175 end
176 176 if @best[:length][:value] >= prop[:length][:value]
177 177 @best[:length] = prop[:length]
178 178 @best[:length][:lang] = lang
179 179 end
180 180 if @best[:first][:value] >= prop[:first][:value]
181 181 @best[:first] = prop[:first]
182 182 @best[:first][:lang] = lang
183 183 end
184 184 end
185 185 end
186 186
187 187 @histogram[:summary][:max] = [@histogram[:data].max,1].max
188 188 @summary[:attempt] = user.count
189 189 user.each_value { |v| @summary[:solve] += 1 if v == 1 }
190 190 end
191 191
192 192 def stuck #report struggling user,problem
193 193 # init
194 194 user,problem = nil
195 195 solve = true
196 196 tries = 0
197 197 @struggle = Array.new
198 198 record = {}
199 199 Submission.includes(:problem,:user).order(:problem_id,:user_id).find_each do |sub|
200 200 next unless sub.problem and sub.user
201 201 if user != sub.user_id or problem != sub.problem_id
202 202 @struggle << { user: record[:user], problem: record[:problem], tries: tries } unless solve
203 203 record = {user: sub.user, problem: sub.problem}
204 204 user,problem = sub.user_id, sub.problem_id
205 205 solve = false
206 206 tries = 0
207 207 end
208 208 if sub.points >= sub.problem.full_score
209 209 solve = true
210 210 else
211 211 tries += 1
212 212 end
213 213 end
214 214 @struggle.sort!{|a,b| b[:tries] <=> a[:tries] }
215 215 @struggle = @struggle[0..50]
216 216 end
217 217
218 +
219 + def multiple_login
220 + #user with multiple IP
221 + raw = Submission.joins(:user).joins(:problem).where("problems.available != 0").group("login,ip_address").order(:login)
222 + last,count = 0,0
223 + first = 0
224 + @users = []
225 + raw.each do |r|
226 + if last != r.user.login
227 + count = 1
228 + last = r.user.login
229 + first = r
230 + else
231 + @users << first if count == 1
232 + @users << r
233 + count += 1
218 234 end
235 + end
236 +
237 + #IP with multiple user
238 + raw = Submission.joins(:user).joins(:problem).where("problems.available != 0").group("login,ip_address").order(:ip_address)
239 + last,count = 0,0
240 + first = 0
241 + @ip = []
242 + raw.each do |r|
243 + if last != r.ip_address
244 + count = 1
245 + last = r.ip_address
246 + first = r
247 + else
248 + @ip << first if count == 1
249 + @ip << r
250 + count += 1
251 + end
252 + end
253 + end
254 +
255 + end
@@ -1,344 +1,350
1 1 require 'csv'
2 2
3 3 class UserAdminController < ApplicationController
4 4
5 5 include MailHelperMethods
6 6
7 7 before_filter :admin_authorization
8 8
9 9 # GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html)
10 10 verify :method => :post, :only => [ :destroy,
11 11 :create, :create_from_list,
12 12 :update,
13 13 :manage_contest,
14 14 :bulk_mail
15 15 ],
16 16 :redirect_to => { :action => :list }
17 17
18 18 def index
19 19 list
20 20 render :action => 'list'
21 21 end
22 22
23 23 def list
24 24 @user_count = User.count
25 25 if params[:page] == 'all'
26 26 @users = User.all
27 27 @paginated = false
28 28 else
29 29 @users = User.paginate :page => params[:page]
30 30 @paginated = true
31 31 end
32 32 @hidden_columns = ['hashed_password', 'salt', 'created_at', 'updated_at']
33 33 @contests = Contest.enabled
34 34 end
35 35
36 36 def active
37 37 sessions = ActiveRecord::SessionStore::Session.find(:all, :conditions => ["updated_at >= ?", 60.minutes.ago])
38 38 @users = []
39 39 sessions.each do |session|
40 40 if session.data[:user_id]
41 41 @users << User.find(session.data[:user_id])
42 42 end
43 43 end
44 44 end
45 45
46 46 def show
47 47 @user = User.find(params[:id])
48 48 end
49 49
50 50 def new
51 51 @user = User.new
52 52 end
53 53
54 54 def create
55 55 @user = User.new(params[:user])
56 56 @user.activated = true
57 57 if @user.save
58 58 flash[:notice] = 'User was successfully created.'
59 59 redirect_to :action => 'list'
60 60 else
61 61 render :action => 'new'
62 62 end
63 63 end
64 64
65 65 def create_from_list
66 66 lines = params[:user_list]
67 67
68 68 note = []
69 69
70 70 lines.split("\n").each do |line|
71 71 items = line.chomp.split(',')
72 72 if items.length>=2
73 73 login = items[0]
74 74 full_name = items[1]
75 75
76 76 added_random_password = false
77 77 if items.length>=3
78 78 password = items[2].chomp(" ")
79 79 user_alias = (items.length>=4) ? items[3] : login
80 80 else
81 81 password = random_password
82 82 user_alias = (items.length>=4) ? items[3] : login
83 83 added_random_password = true
84 84 end
85 85
86 86 user = User.find_by_login(login)
87 87 if (user)
88 88 user.full_name = full_name
89 89 user.password = password
90 90 else
91 91 user = User.new({:login => login,
92 92 :full_name => full_name,
93 93 :password => password,
94 94 :password_confirmation => password,
95 95 :alias => user_alias})
96 96 end
97 97 user.activated = true
98 98 user.save
99 99
100 100 if added_random_password
101 101 note << "'#{login}' (+)"
102 102 else
103 103 note << login
104 104 end
105 105 end
106 106 end
107 107 flash[:notice] = 'User(s) ' + note.join(', ') +
108 108 ' were successfully created. ' +
109 109 '( (+) - created with random passwords.)'
110 110 redirect_to :action => 'list'
111 111 end
112 112
113 113 def edit
114 114 @user = User.find(params[:id])
115 115 end
116 116
117 117 def update
118 118 @user = User.find(params[:id])
119 119 if @user.update_attributes(params[:user])
120 120 flash[:notice] = 'User was successfully updated.'
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 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
177 183 end
178 184
179 185 if params[:commit] == 'download csv' then
180 186 csv = gen_csv_from_scorearray(@scorearray,@problems)
181 187 send_data csv, filename: 'max_score.csv'
182 188 else
183 189 render template: 'user_admin/user_stat'
184 190 end
185 191 end
186 192
187 193 def import
188 194 if params[:file]==''
189 195 flash[:notice] = 'Error importing no file'
190 196 redirect_to :action => 'list' and return
191 197 end
192 198 import_from_file(params[:file])
193 199 end
194 200
195 201 def random_all_passwords
196 202 users = User.find(:all)
197 203 @prefix = params[:prefix] || ''
198 204 @non_admin_users = User.find_non_admin_with_prefix(@prefix)
199 205 @changed = false
200 206 if request.request_method == 'POST'
201 207 @non_admin_users.each do |user|
202 208 password = random_password
203 209 user.password = password
204 210 user.password_confirmation = password
205 211 user.save
206 212 end
207 213 @changed = true
208 214 end
209 215 end
210 216
211 217 # contest management
212 218
213 219 def contests
214 220 @contest, @users = find_contest_and_user_from_contest_id(params[:id])
215 221 @contests = Contest.enabled
216 222 end
217 223
218 224 def assign_from_list
219 225 contest_id = params[:users_contest_id]
220 226 org_contest, users = find_contest_and_user_from_contest_id(contest_id)
221 227 contest = Contest.find(params[:new_contest][:id])
222 228 if !contest
223 229 flash[:notice] = 'Error: no contest'
224 230 redirect_to :action => 'contests', :id =>contest_id
225 231 end
226 232
227 233 note = []
228 234 users.each do |u|
229 235 u.contests = [contest]
230 236 note << u.login
231 237 end
232 238 flash[:notice] = 'User(s) ' + note.join(', ') +
233 239 " were successfully reassigned to #{contest.title}."
234 240 redirect_to :action => 'contests', :id =>contest.id
235 241 end
236 242
237 243 def add_to_contest
238 244 user = User.find(params[:id])
239 245 contest = Contest.find(params[:contest_id])
240 246 if user and contest
241 247 user.contests << contest
242 248 end
243 249 redirect_to :action => 'list'
244 250 end
245 251
246 252 def remove_from_contest
247 253 user = User.find(params[:id])
248 254 contest = Contest.find(params[:contest_id])
249 255 if user and contest
250 256 user.contests.delete(contest)
251 257 end
252 258 redirect_to :action => 'list'
253 259 end
254 260
255 261 def contest_management
256 262 end
257 263
258 264 def manage_contest
259 265 contest = Contest.find(params[:contest][:id])
260 266 if !contest
261 267 flash[:notice] = 'You did not choose the contest.'
262 268 redirect_to :action => 'contest_management' and return
263 269 end
264 270
265 271 operation = params[:operation]
266 272
267 273 if not ['add','remove','assign'].include? operation
268 274 flash[:notice] = 'You did not choose the operation to perform.'
269 275 redirect_to :action => 'contest_management' and return
270 276 end
271 277
272 278 lines = params[:login_list]
273 279 if !lines or lines.blank?
274 280 flash[:notice] = 'You entered an empty list.'
275 281 redirect_to :action => 'contest_management' and return
276 282 end
277 283
278 284 note = []
279 285 users = []
280 286 lines.split("\n").each do |line|
281 287 user = User.find_by_login(line.chomp)
282 288 if user
283 289 if operation=='add'
284 290 if ! user.contests.include? contest
285 291 user.contests << contest
286 292 end
287 293 elsif operation=='remove'
288 294 user.contests.delete(contest)
289 295 else
290 296 user.contests = [contest]
291 297 end
292 298
293 299 if params[:reset_timer]
294 300 user.contest_stat.forced_logout = true
295 301 user.contest_stat.reset_timer_and_save
296 302 end
297 303
298 304 if params[:notification_emails]
299 305 send_contest_update_notification_email(user, contest)
300 306 end
301 307
302 308 note << user.login
303 309 users << user
304 310 end
305 311 end
306 312
307 313 if params[:reset_timer]
308 314 logout_users(users)
309 315 end
310 316
311 317 flash[:notice] = 'User(s) ' + note.join(', ') +
312 318 ' were successfully modified. '
313 319 redirect_to :action => 'contest_management'
314 320 end
315 321
316 322 # admin management
317 323
318 324 def admin
319 325 @admins = User.find(:all).find_all {|user| user.admin? }
320 326 end
321 327
322 328 def grant_admin
323 329 login = params[:login]
324 330 user = User.find_by_login(login)
325 331 if user!=nil
326 332 admin_role = Role.find_by_name('admin')
327 333 user.roles << admin_role
328 334 else
329 335 flash[:notice] = 'Unknown user'
330 336 end
331 337 flash[:notice] = 'User added as admins'
332 338 redirect_to :action => 'admin'
333 339 end
334 340
335 341 def revoke_admin
336 342 user = User.find(params[:id])
337 343 if user==nil
338 344 flash[:notice] = 'Unknown user'
339 345 redirect_to :action => 'admin' and return
340 346 elsif user.login == 'root'
341 347 flash[:notice] = 'You cannot revoke admisnistrator permission from root.'
342 348 redirect_to :action => 'admin' and return
343 349 end
344 350
@@ -1,138 +1,138
1 1 # Methods added to this helper will be available to all templates in the application.
2 2 module ApplicationHelper
3 3
4 4 def user_header
5 5 menu_items = ''
6 6 user = User.find(session[:user_id])
7 7
8 8 if (user!=nil) and (session[:admin])
9 9 # admin menu
10 10 menu_items << "<b>Administrative task:</b> "
11 11 append_to menu_items, '[Announcements]', 'announcements', 'index'
12 12 append_to menu_items, '[Msg console]', 'messages', 'console'
13 13 append_to menu_items, '[Problems]', 'problems', 'index'
14 14 append_to menu_items, '[Users]', 'user_admin', 'index'
15 15 append_to menu_items, '[Results]', 'user_admin', 'user_stat'
16 - append_to menu_items, '[Report]', 'report', 'login_stat'
16 + append_to menu_items, '[Report]', 'report', 'multiple_login'
17 17 append_to menu_items, '[Graders]', 'graders', 'list'
18 18 append_to menu_items, '[Contests]', 'contest_management', 'index'
19 19 append_to menu_items, '[Sites]', 'sites', 'index'
20 20 append_to menu_items, '[System config]', 'configurations', 'index'
21 21 menu_items << "<br/>"
22 22 end
23 23
24 24 # main page
25 25 append_to menu_items, "[#{I18n.t 'menu.main'}]", 'main', 'list'
26 26 append_to menu_items, "[#{I18n.t 'menu.messages'}]", 'messages', 'list'
27 27
28 28 if (user!=nil) and (GraderConfiguration.show_tasks_to?(user))
29 29 append_to menu_items, "[#{I18n.t 'menu.tasks'}]", 'tasks', 'list'
30 30 append_to menu_items, "[#{I18n.t 'menu.submissions'}]", 'main', 'submission'
31 31 append_to menu_items, "[#{I18n.t 'menu.test'}]", 'test', 'index'
32 32 end
33 33
34 34 if GraderConfiguration['right.user_hall_of_fame']
35 35 append_to menu_items, "[#{I18n.t 'menu.hall_of_fame'}]", 'report', 'problem_hof'
36 36 end
37 37 append_to menu_items, "[#{I18n.t 'menu.help'}]", 'main', 'help'
38 38
39 39 if GraderConfiguration['system.user_setting_enabled']
40 40 append_to menu_items, "[#{I18n.t 'menu.settings'}]", 'users', 'index'
41 41 end
42 42 append_to menu_items, "[#{I18n.t 'menu.log_out'}]", 'main', 'login'
43 43
44 44 menu_items.html_safe
45 45 end
46 46
47 47 def append_to(option,label, controller, action)
48 48 option << ' ' if option!=''
49 49 option << link_to_unless_current(label,
50 50 :controller => controller,
51 51 :action => action)
52 52 end
53 53
54 54 def format_short_time(time)
55 55 now = Time.now.gmtime
56 56 st = ''
57 57 if (time.yday != now.yday) or
58 58 (time.year != now.year)
59 59 st = time.strftime("%x ")
60 60 end
61 61 st + time.strftime("%X")
62 62 end
63 63
64 64 def format_short_duration(duration)
65 65 return '' if duration==nil
66 66 d = duration.to_f
67 67 return Time.at(d).gmtime.strftime("%X")
68 68 end
69 69
70 70 def read_textfile(fname,max_size=2048)
71 71 begin
72 72 File.open(fname).read(max_size)
73 73 rescue
74 74 nil
75 75 end
76 76 end
77 77
78 78 def user_title_bar(user)
79 79 header = ''
80 80 time_left = ''
81 81
82 82 #
83 83 # if the contest is over
84 84 if GraderConfiguration.time_limit_mode?
85 85 if user.contest_finished?
86 86 header = <<CONTEST_OVER
87 87 <tr><td colspan="2" align="center">
88 88 <span class="contest-over-msg">THE CONTEST IS OVER</span>
89 89 </td></tr>
90 90 CONTEST_OVER
91 91 end
92 92 if !user.contest_started?
93 93 time_left = "&nbsp;&nbsp;" + (t 'title_bar.contest_not_started')
94 94 else
95 95 time_left = "&nbsp;&nbsp;" + (t 'title_bar.remaining_time') +
96 96 " #{format_short_duration(user.contest_time_left)}"
97 97 end
98 98 end
99 99
100 100 #
101 101 # if the contest is in the anaysis mode
102 102 if GraderConfiguration.analysis_mode?
103 103 header = <<ANALYSISMODE
104 104 <tr><td colspan="2" align="center">
105 105 <span class="contest-over-msg">ANALYSIS MODE</span>
106 106 </td></tr>
107 107 ANALYSISMODE
108 108 end
109 109
110 110 contest_name = GraderConfiguration['contest.name']
111 111
112 112 #
113 113 # build real title bar
114 114 result = <<TITLEBAR
115 115 <div class="title">
116 116 <table>
117 117 #{header}
118 118 <tr>
119 119 <td class="left-col">
120 120 #{user.full_name}<br/>
121 121 #{t 'title_bar.current_time'} #{format_short_time(Time.zone.now)}
122 122 #{time_left}
123 123 <br/>
124 124 </td>
125 125 <td class="right-col">#{contest_name}</td>
126 126 </tr>
127 127 </table>
128 128 </div>
129 129 TITLEBAR
130 130 result.html_safe
131 131 end
132 132
133 133 def markdown(text)
134 134 markdown = RDiscount.new(text)
135 135 markdown.to_html.html_safe
136 136 end
137 137
138 138 end
@@ -1,51 +1,53
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 9
10 10 %table.info
11 11 %thead
12 12 %tr.info-head
13 13 %th Stat
14 14 %th Value
15 15 %tbody
16 16 %tr{class: cycle('info-even','info-odd')}
17 17 %td Submissions
18 18 %td= @submissions.count
19 19 %tr{class: cycle('info-even','info-odd')}
20 20 %td Solved/Attempted User
21 21 %td #{@summary[:solve]}/#{@summary[:attempt]} (#{(@summary[:solve]*100.0/@summary[:attempt]).round(1)}%)
22 22
23 23 %h2 Submissions Count
24 24 = render partial: 'application/bar_graph', locals: { histogram: @histogram }
25 25
26 26 %h2 Submissions
27 27 - if @submissions and @submissions.count > 0
28 28 %table.info#main_table
29 29 %thead
30 30 %tr.info-head
31 31 %th ID
32 32 %th Login
33 33 %th Name
34 34 %th Submitted_at
35 35 %th Points
36 36 %th comment
37 + %th IP
37 38 %tbody
38 39 - row_odd,curr = true,''
39 40 - @submissions.each do |sub|
40 41 - next unless sub.user
41 42 - row_odd,curr = !row_odd, sub.user if curr != sub.user
42 43 %tr{class: row_odd ? "info-odd" : "info-even"}
43 44 %td= link_to sub.id, controller: 'graders', action: 'submission', id: sub.id
44 45 %td= link_to sub.user.login, controller: :users, action: :profile, id: sub.user.id
45 46 %td= sub.user.full_name
46 47 %td= time_ago_in_words(sub.submitted_at) + " ago"
47 48 %td= sub.points
48 49 %td.fix-width= sub.grader_comment
50 + %td= sub.ip_address
49 51 - else
50 52 No submission
51 53
@@ -1,7 +1,8
1 1
2 2 .task-menu
3 3 Reports
4 4 %br/
5 5 = link_to '[Hall of Fame]', :action => 'problem_hof'
6 6 = link_to '[Struggle]', :action => 'stuck'
7 7 = link_to '[Login]', :action => 'login_stat'
8 + = link_to '[Multiple Login]', :action => 'multiple_login'
You need to be logged in to leave comments. Login now