Description:
add submission report
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
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 = '% |
|
5 | + date_and_time = '%Y-%m-%d %H:%M' |
|
7 | - since_time = strptime(params[:since_datetime],date_and_time) |
|
6 | + begin |
|
8 |
- |
|
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 |
|
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'} |
|
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 |
@@ -8,25 +8,14 | |||||
|
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 |
@@ -36,9 +25,9 | |||||
|
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 |
@@ -170,12 +170,15 | |||||
|
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| |
You need to be logged in to leave comments.
Login now