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

r413:889d5737bb5f - - 6 files changed: 118 inserted, 23 deleted

@@ -0,0 +1,6
1 +
2 + .task-menu
3 + Reports
4 + %br/
5 + = link_to '[Submission]', :action => 'submission_stat'
6 + = link_to '[Login]', :action => 'login_stat'
@@ -0,0 +1,41
1 + - content_for :header do
2 + = javascript_include_tag 'new'
3 +
4 + %script{:type=>"text/javascript"}
5 + $(function () {
6 + $('#since_datetime').datetimepicker({ showButtonPanel: true, dateFormat: "yy-mm-dd", controlType: "slider"} );
7 + $('#until_datetime').datetimepicker({ showButtonPanel: true, dateFormat: "yy-mm-dd", controlType: "slider"} );
8 + });
9 +
10 +
11 + %h1 Login status
12 +
13 +
14 +
15 +
16 + =render partial: 'report_menu'
17 + =render partial: 'date_range', locals: {param_text: 'Submission date range:', title: 'Query submission stat in the range' }
18 +
19 + %table.info
20 + %thead
21 + %tr.info-head
22 + %th login
23 + %th full name
24 + %th total submissions
25 + %th submissions
26 + %tbody
27 + - @submissions.each do |user_id,data|
28 + %tr{class: cycle('info-even','info-odd')}
29 + %td= data[:login]
30 + %td= data[:full_name]
31 + %td= data[:count]
32 + %td
33 + - data[:sub].each do |prob_id,sub_data|
34 + = "#{sub_data[:prob_name]}: ["
35 + - st = []
36 + - sub_data[:sub_ids].each do |id|
37 + - st << link_to(id, controller: 'graders' , action: 'submission', id: id)
38 + = raw st.join ', '
39 + = ']'
40 + %br/
41 +
@@ -1,18 +1,70
1 1 class ReportController < ApplicationController
2 2 def login_stat
3 3 @logins = Array.new
4 - login = Login.all
5 4
6 - date_and_time = '%y-%m-%d %H:%M'
7 - since_time = strptime(params[:since_datetime],date_and_time)
8 - until_time = strptime(params[:until_datetime],date_and_time)
5 + date_and_time = '%Y-%m-%d %H:%M'
6 + begin
7 + @since_time = DateTime.strptime(params[:since_datetime],date_and_time)
8 + rescue
9 + @since_time = DateTime.new(1000,1,1)
10 + end
11 + begin
12 + @until_time = DateTime.strptime(params[:until_datetime],date_and_time)
13 + rescue
14 + @until_time = DateTime.new(3000,1,1)
15 + end
9 16
10 17 User.all.each do |user|
11 18 @logins << { login: user.login,
12 19 full_name: user.full_name,
13 - count: Login.where(user_id: user.id).count(:id),
14 - min: Login.where(user_id: user.id).maximum(:created_at),
15 - max: Login.where(user_id: user.id).minimum(:created_at) }
20 + count: Login.where("user_id = ? AND created_at >= ? AND created_at <= ?",
21 + user.id,@since_time,@until_time)
22 + .count(:id),
23 + min: Login.where("user_id = ? AND created_at >= ? AND created_at <= ?",
24 + user.id,@since_time,@until_time)
25 + .minimum(:created_at),
26 + max: Login.where("user_id = ? AND created_at >= ? AND created_at <= ?",
27 + user.id,@since_time,@until_time)
28 + .maximum(:created_at)
29 + }
30 + end
31 + end
32 +
33 + def submission_stat
34 +
35 + date_and_time = '%Y-%m-%d %H:%M'
36 + begin
37 + @since_time = DateTime.strptime(params[:since_datetime],date_and_time)
38 + rescue
39 + @since_time = DateTime.new(1000,1,1)
40 + end
41 + begin
42 + @until_time = DateTime.strptime(params[:until_datetime],date_and_time)
43 + rescue
44 + @until_time = DateTime.new(3000,1,1)
45 + end
46 +
47 + @submissions = {}
48 +
49 + User.find_each do |user|
50 + @submissions[user.id] = { login: user.login, full_name: user.full_name, count: 0, sub: { } }
51 + end
52 +
53 + Submission.where("submitted_at >= ? AND submitted_at <= ?",@since_time,@until_time).find_each do |s|
54 + if not @submissions[s.user_id][:sub].has_key?(s.problem_id)
55 + a = nil
56 + begin
57 + a = Problem.find(s.problem_id)
58 + rescue
59 + a = nil
60 + end
61 + @submissions[s.user_id][:sub][s.problem_id] =
62 + { prob_name: (a ? a.full_name : '(NULL)'),
63 + sub_ids: [s.id] }
64 + else
65 + @submissions[s.user_id][:sub][s.problem_id][:sub_ids] << s.id
66 + end
67 + @submissions[s.user_id][:count] += 1
16 68 end
17 69 end
18 70 end
@@ -3,7 +3,7
3 3 .submitbox
4 4 %table
5 5 %tr
6 - %td{colspan: 6, style: 'font-weight: bold'} Query maximum score in submission range
6 + %td{colspan: 6, style: 'font-weight: bold'}= title
7 7 %tr
8 8 %td{style: 'width: 120px; font-weight: bold'}= param_text
9 9 %td{align: 'right'} since:
@@ -15,5 +15,9
15 15 %tr
16 16 %td
17 17 %td
18 + %td Blank mean no condition
19 + %tr
20 + %td
21 + %td
18 22 %td= submit_tag 'query'
19 23
@@ -11,19 +11,8
11 11 %h1 Login status
12 12
13 13
14 -
15 - .task-menu
16 - Reports
17 - %br/
18 - = link_to '[Submission]', :action => 'submit_stat'
19 - = link_to '[Login]', :action => 'login_stat'
20 -
21 -
22 - =render partial: 'date_range', locals: {param_text: 'Submission range:' }
23 -
24 - hahaha
25 -
26 - =params[:since_datetime]
14 + =render partial: 'report_menu'
15 + =render partial: 'date_range', locals: {param_text: 'Login date range:', title: 'Query login stat in the range' }
27 16
28 17 %table.info
29 18 %thead
@@ -39,6 +28,6
39 28 %td= l[:login]
40 29 %td= l[:full_name]
41 30 %td= l[:count]
42 - %td= l[:min]
43 - %td= l[:max]
31 + %td= l[:min] ? l[:min].in_time_zone.strftime('%Y-%m-%d %H:%M') : ''
32 + %td= l[:max] ? l[:max].in_time_zone.strftime('%Y-%m-%d %H:%M') : ''
44 33
@@ -173,6 +173,9
173 173 t.text "grader_comment"
174 174 t.integer "number"
175 175 t.string "source_filename"
176 + t.float "max_runtime"
177 + t.integer "peak_memory"
178 + t.integer "effective_code_length"
176 179 end
177 180
178 181 add_index "submissions", ["user_id", "problem_id", "number"], :name => "index_submissions_on_user_id_and_problem_id_and_number", :unique => true
You need to be logged in to leave comments. Login now