Description:
add cheat detail
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r507:5af12f2a9a30 - - 2 files changed: 52 inserted, 20 deleted

@@ -1,9 +1,10
1 class ReportController < ApplicationController
1 class ReportController < ApplicationController
2
2
3 - before_filter :admin_authorization, only: [:login_stat,:submission_stat, :stuck]
3 + before_filter :admin_authorization, only: [:login_stat,:submission_stat, :stuck, :cheat_report, :cheat_scruntinize]
4 +
4 before_filter(only: [:problem_hof]) { |c|
5 before_filter(only: [:problem_hof]) { |c|
5 return false unless authenticate
6 return false unless authenticate
6
7
7 if GraderConfiguration["right.user_view_submission"]
8 if GraderConfiguration["right.user_view_submission"]
8 return true;
9 return true;
9 end
10 end
@@ -255,19 +256,19
255 def cheat_report
256 def cheat_report
256 date_and_time = '%Y-%m-%d %H:%M'
257 date_and_time = '%Y-%m-%d %H:%M'
257 begin
258 begin
258 md = params[:since_datetime].match(/(\d+)-(\d+)-(\d+) (\d+):(\d+)/)
259 md = params[:since_datetime].match(/(\d+)-(\d+)-(\d+) (\d+):(\d+)/)
259 @since_time = Time.zone.local(md[1].to_i,md[2].to_i,md[3].to_i,md[4].to_i,md[5].to_i)
260 @since_time = Time.zone.local(md[1].to_i,md[2].to_i,md[3].to_i,md[4].to_i,md[5].to_i)
260 rescue
261 rescue
261 - @since_time = Time.zone.now
262 + @since_time = Time.zone.now.ago( 90.minutes)
262 end
263 end
263 begin
264 begin
264 md = params[:until_datetime].match(/(\d+)-(\d+)-(\d+) (\d+):(\d+)/)
265 md = params[:until_datetime].match(/(\d+)-(\d+)-(\d+) (\d+):(\d+)/)
265 @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)
266 @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)
266 rescue
267 rescue
267 - @until_time = Time.zone.now.ago( 90.minutes)
268 + @until_time = Time.zone.now
268 end
269 end
269
270
270 #multi login
271 #multi login
271 @ml = Login.joins(:user).where("logins.created_at >= ? and logins.created_at <= ?",@since_time,@until_time).select('users.login,count(distinct ip_address) as count,users.full_name').group("users.id").having("count > 1")
272 @ml = Login.joins(:user).where("logins.created_at >= ? and logins.created_at <= ?",@since_time,@until_time).select('users.login,count(distinct ip_address) as count,users.full_name').group("users.id").having("count > 1")
272
273
273 st = <<-SQL
274 st = <<-SQL
@@ -323,26 +324,56
323 SQL
324 SQL
324 @subs = Submission.joins(:problem).find_by_sql([st,@since_time,@until_time,
325 @subs = Submission.joins(:problem).find_by_sql([st,@since_time,@until_time,
325 @since_time,@until_time,
326 @since_time,@until_time,
326 @since_time,@until_time,
327 @since_time,@until_time,
327 @since_time,@until_time])
328 @since_time,@until_time])
328
329
329 - # st =
330 + end
330 - # " INNER JOIN" +
331 +
331 - # "(SELECT u.id,l.ip_address,COUNT(DISTINCT ip_address) as count " +
332 + def cheat_scruntinize
332 - # " FROM logins l INNER JOIN users u ON l.user_id = u.id "+
333 + #convert date & time
333 - # " WHERE l.created_at >= '#{@since_time.in_time_zone("UTC")}' and l.created_at <= '#{@until_time.in_time_zone("UTC")}' " +
334 + date_and_time = '%Y-%m-%d %H:%M'
334 - # " GROUP BY u.id" +
335 + begin
335 - # " HAVING count > 1) ml "
336 + md = params[:since_datetime].match(/(\d+)-(\d+)-(\d+) (\d+):(\d+)/)
336 - # #ml detail
337 + @since_time = Time.zone.local(md[1].to_i,md[2].to_i,md[3].to_i,md[4].to_i,md[5].to_i)
337 - # @mld = Login.joins(st + "ON logins.user_id = ml.id").
338 + rescue
338 - # where("logins.created_at >= ? and logins.created_at <= ?",@since_time,@until_time).
339 + @since_time = Time.zone.now.ago( 90.minutes)
339 - # order("ip_address")
340 + end
340 - #
341 + begin
341 - # #submissions
342 + md = params[:until_datetime].match(/(\d+)-(\d+)-(\d+) (\d+):(\d+)/)
342 - # @subs = Submission.joins(:problem).joins(st + "ON submissions.user_id = ml.id").
343 + @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)
343 - # where("submissions.submitted_at >= ? and submissions.submitted_at <= ?",@since_time,@until_time).
344 + rescue
344 - # order("submissions.ip_address")
345 + @until_time = Time.zone.now
346 + end
347 +
348 + #convert sid
349 + @sid = params[:SID].split(/[,\s]/) if params[:SID]
350 + unless @sid and @sid.size > 0
351 + return
352 + redirect_to actoin: :cheat_scruntinize
353 + flash[:notice] = 'Please enter at least 1 student id'
354 + end
355 + mark = Array.new(@sid.size,'?')
356 + condition = "(u.login = " + mark.join(' OR u.login = ') + ')'
357 +
358 + @st = <<-SQL
359 + SELECT l.created_at as submitted_at ,-1 as id,u.login,u.full_name,l.ip_address,"" as problem_id,"" as points,l.user_id
360 + FROM logins l INNER JOIN users u on l.user_id = u.id
361 + WHERE l.created_at >= ? AND l.created_at <= ? AND #{condition}
362 + UNION
363 + SELECT s.submitted_at,s.id,u.login,u.full_name,s.ip_address,s.problem_id,s.points,s.user_id
364 + FROM submissions s INNER JOIN users u ON s.user_id = u.id
365 + WHERE s.submitted_at >= ? AND s.submitted_at <= ? AND #{condition}
366 + ORDER BY submitted_at
367 + SQL
368 +
369 + p = [@st,@since_time,@until_time] + @sid + [@since_time,@until_time] + @sid
370 + @logs = Submission.joins(:problem).find_by_sql(p)
371 +
372 +
373 +
374 +
375 +
345 end
376 end
346
377
347
378
348 end
379 end
@@ -1,8 +1,9
1
1
2 .task-menu
2 .task-menu
3 Reports
3 Reports
4 %br/
4 %br/
5 = link_to '[Hall of Fame]', :action => 'problem_hof'
5 = link_to '[Hall of Fame]', :action => 'problem_hof'
6 = link_to '[Struggle]', :action => 'stuck'
6 = link_to '[Struggle]', :action => 'stuck'
7 - = link_to '[Login]', :action => 'login_stat'
7 + = link_to '[Cheat Detection]', :action => 'cheat_report'
8 + = link_to '[Cheat Detail]', :action => 'cheat_scruntinize'
8 = link_to '[Multiple Login]', :action => 'multiple_login'
9 = link_to '[Multiple Login]', :action => 'multiple_login'
You need to be logged in to leave comments. Login now