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 class ReportController < ApplicationController
1 class ReportController < ApplicationController
2 def login_stat
2 def login_stat
3 @logins = Array.new
3 @logins = Array.new
4 - login = Login.all
5
4
6 - date_and_time = '%y-%m-%d %H:%M'
5 + date_and_time = '%Y-%m-%d %H:%M'
7 - since_time = strptime(params[:since_datetime],date_and_time)
6 + begin
8 - until_time = strptime(params[:until_datetime],date_and_time)
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 User.all.each do |user|
17 User.all.each do |user|
11 @logins << { login: user.login,
18 @logins << { login: user.login,
12 full_name: user.full_name,
19 full_name: user.full_name,
13 - count: Login.where(user_id: user.id).count(:id),
20 + count: Login.where("user_id = ? AND created_at >= ? AND created_at <= ?",
14 - min: Login.where(user_id: user.id).maximum(:created_at),
21 + user.id,@since_time,@until_time)
15 - max: Login.where(user_id: user.id).minimum(:created_at) }
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 end
68 end
17 end
69 end
18 end
70 end
@@ -1,19 +1,23
1
1
2 = form_tag({session: :url }) do
2 = form_tag({session: :url }) do
3 .submitbox
3 .submitbox
4 %table
4 %table
5 %tr
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 %tr
7 %tr
8 %td{style: 'width: 120px; font-weight: bold'}= param_text
8 %td{style: 'width: 120px; font-weight: bold'}= param_text
9 %td{align: 'right'} since:
9 %td{align: 'right'} since:
10 %td= text_field_tag 'since_datetime'
10 %td= text_field_tag 'since_datetime'
11 %tr
11 %tr
12 %td
12 %td
13 %td{align: 'right'} until:
13 %td{align: 'right'} until:
14 %td= text_field_tag 'until_datetime'
14 %td= text_field_tag 'until_datetime'
15 %tr
15 %tr
16 %td
16 %td
17 %td
17 %td
18 + %td Blank mean no condition
19 + %tr
20 + %td
21 + %td
18 %td= submit_tag 'query'
22 %td= submit_tag 'query'
19
23
@@ -2,43 +2,32
2 = javascript_include_tag 'new'
2 = javascript_include_tag 'new'
3
3
4 %script{:type=>"text/javascript"}
4 %script{:type=>"text/javascript"}
5 $(function () {
5 $(function () {
6 $('#since_datetime').datetimepicker({ showButtonPanel: true, dateFormat: "yy-mm-dd", controlType: "slider"} );
6 $('#since_datetime').datetimepicker({ showButtonPanel: true, dateFormat: "yy-mm-dd", controlType: "slider"} );
7 $('#until_datetime').datetimepicker({ showButtonPanel: true, dateFormat: "yy-mm-dd", controlType: "slider"} );
7 $('#until_datetime').datetimepicker({ showButtonPanel: true, dateFormat: "yy-mm-dd", controlType: "slider"} );
8 });
8 });
9
9
10
10
11 %h1 Login status
11 %h1 Login status
12
12
13
13
14 -
14 + =render partial: 'report_menu'
15 - .task-menu
15 + =render partial: 'date_range', locals: {param_text: 'Login date range:', title: 'Query login stat in the range' }
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]
27
16
28 %table.info
17 %table.info
29 %thead
18 %thead
30 %tr.info-head
19 %tr.info-head
31 %th login
20 %th login
32 %th full name
21 %th full name
33 %th login count
22 %th login count
34 %th earliest
23 %th earliest
35 %th latest
24 %th latest
36 %tbody
25 %tbody
37 - @logins.each do |l|
26 - @logins.each do |l|
38 %tr{class: cycle('info-even','info-odd')}
27 %tr{class: cycle('info-even','info-odd')}
39 %td= l[:login]
28 %td= l[:login]
40 %td= l[:full_name]
29 %td= l[:full_name]
41 %td= l[:count]
30 %td= l[:count]
42 - %td= l[:min]
31 + %td= l[:min] ? l[:min].in_time_zone.strftime('%Y-%m-%d %H:%M') : ''
43 - %td= l[:max]
32 + %td= l[:max] ? l[:max].in_time_zone.strftime('%Y-%m-%d %H:%M') : ''
44
33
@@ -164,24 +164,27
164 t.integer "problem_id"
164 t.integer "problem_id"
165 t.integer "language_id"
165 t.integer "language_id"
166 t.text "source"
166 t.text "source"
167 t.binary "binary"
167 t.binary "binary"
168 t.datetime "submitted_at"
168 t.datetime "submitted_at"
169 t.datetime "compiled_at"
169 t.datetime "compiled_at"
170 t.text "compiler_message"
170 t.text "compiler_message"
171 t.datetime "graded_at"
171 t.datetime "graded_at"
172 t.integer "points"
172 t.integer "points"
173 t.text "grader_comment"
173 t.text "grader_comment"
174 t.integer "number"
174 t.integer "number"
175 t.string "source_filename"
175 t.string "source_filename"
176 + t.float "max_runtime"
177 + t.integer "peak_memory"
178 + t.integer "effective_code_length"
176 end
179 end
177
180
178 add_index "submissions", ["user_id", "problem_id", "number"], :name => "index_submissions_on_user_id_and_problem_id_and_number", :unique => true
181 add_index "submissions", ["user_id", "problem_id", "number"], :name => "index_submissions_on_user_id_and_problem_id_and_number", :unique => true
179 add_index "submissions", ["user_id", "problem_id"], :name => "index_submissions_on_user_id_and_problem_id"
182 add_index "submissions", ["user_id", "problem_id"], :name => "index_submissions_on_user_id_and_problem_id"
180
183
181 create_table "tasks", :force => true do |t|
184 create_table "tasks", :force => true do |t|
182 t.integer "submission_id"
185 t.integer "submission_id"
183 t.datetime "created_at"
186 t.datetime "created_at"
184 t.integer "status"
187 t.integer "status"
185 t.datetime "updated_at"
188 t.datetime "updated_at"
186 end
189 end
187
190
You need to be logged in to leave comments. Login now