Description:
add language
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r697:99e65e2a6124 - - 2 files changed: 3 inserted, 1 deleted
@@ -156,25 +156,25 | |||||
|
156 | problem.available = true |
|
156 | problem.available = true |
|
157 | problem.save |
|
157 | problem.save |
|
158 | end |
|
158 | end |
|
159 | redirect_to action: :index |
|
159 | redirect_to action: :index |
|
160 | end |
|
160 | end |
|
161 |
|
161 | ||
|
162 | def stat |
|
162 | def stat |
|
163 | @problem = Problem.find(params[:id]) |
|
163 | @problem = Problem.find(params[:id]) |
|
164 | unless @problem.available or session[:admin] |
|
164 | unless @problem.available or session[:admin] |
|
165 | redirect_to :controller => 'main', :action => 'list' |
|
165 | redirect_to :controller => 'main', :action => 'list' |
|
166 | return |
|
166 | return |
|
167 | end |
|
167 | end |
|
168 | - @submissions = Submission.includes(:user).where(problem_id: params[:id]).order(:user_id,:id) |
|
168 | + @submissions = Submission.includes(:user).includes(:language).where(problem_id: params[:id]).order(:user_id,:id) |
|
169 |
|
169 | ||
|
170 | #stat summary |
|
170 | #stat summary |
|
171 | range =65 |
|
171 | range =65 |
|
172 | @histogram = { data: Array.new(range,0), summary: {} } |
|
172 | @histogram = { data: Array.new(range,0), summary: {} } |
|
173 | user = Hash.new(0) |
|
173 | user = Hash.new(0) |
|
174 | @submissions.find_each do |sub| |
|
174 | @submissions.find_each do |sub| |
|
175 | d = (DateTime.now.in_time_zone - sub.submitted_at) / 24 / 60 / 60 |
|
175 | d = (DateTime.now.in_time_zone - sub.submitted_at) / 24 / 60 / 60 |
|
176 | @histogram[:data][d.to_i] += 1 if d < range |
|
176 | @histogram[:data][d.to_i] += 1 if d < range |
|
177 | user[sub.user_id] = [user[sub.user_id], ((sub.try(:points) || 0) >= @problem.full_score) ? 1 : 0].max |
|
177 | user[sub.user_id] = [user[sub.user_id], ((sub.try(:points) || 0) >= @problem.full_score) ? 1 : 0].max |
|
178 | end |
|
178 | end |
|
179 | @histogram[:summary][:max] = [@histogram[:data].max,1].max |
|
179 | @histogram[:summary][:max] = [@histogram[:data].max,1].max |
|
180 |
|
180 |
@@ -23,35 +23,37 | |||||
|
23 | %h2 Submissions Count |
|
23 | %h2 Submissions Count |
|
24 | = render partial: 'application/bar_graph', locals: { histogram: @histogram } |
|
24 | = render partial: 'application/bar_graph', locals: { histogram: @histogram } |
|
25 |
|
25 | ||
|
26 | %h2 Submissions |
|
26 | %h2 Submissions |
|
27 | - if @submissions and @submissions.count > 0 |
|
27 | - if @submissions and @submissions.count > 0 |
|
28 | %table#main_table.table.table-condensed.table-striped |
|
28 | %table#main_table.table.table-condensed.table-striped |
|
29 | %thead |
|
29 | %thead |
|
30 | %tr |
|
30 | %tr |
|
31 | %th ID |
|
31 | %th ID |
|
32 | %th Login |
|
32 | %th Login |
|
33 | %th Name |
|
33 | %th Name |
|
34 | %th Submitted_at |
|
34 | %th Submitted_at |
|
|
35 | + %th language | ||
|
35 | %th Points |
|
36 | %th Points |
|
36 | %th comment |
|
37 | %th comment |
|
37 | %th IP |
|
38 | %th IP |
|
38 | %tbody |
|
39 | %tbody |
|
39 | - row_odd,curr = true,'' |
|
40 | - row_odd,curr = true,'' |
|
40 | - @submissions.each do |sub| |
|
41 | - @submissions.each do |sub| |
|
41 | - next unless sub.user |
|
42 | - next unless sub.user |
|
42 | - row_odd,curr = !row_odd, sub.user if curr != sub.user |
|
43 | - row_odd,curr = !row_odd, sub.user if curr != sub.user |
|
43 | %tr |
|
44 | %tr |
|
44 | %td= link_to sub.id, submission_path(sub) |
|
45 | %td= link_to sub.id, submission_path(sub) |
|
45 | %td= link_to sub.user.login, stat_user_path(sub.user) |
|
46 | %td= link_to sub.user.login, stat_user_path(sub.user) |
|
46 | %td= sub.user.full_name |
|
47 | %td= sub.user.full_name |
|
47 | %td{data: {order: sub.submitted_at}}= time_ago_in_words(sub.submitted_at) + " ago" |
|
48 | %td{data: {order: sub.submitted_at}}= time_ago_in_words(sub.submitted_at) + " ago" |
|
|
49 | + %td= sub.language.name | ||
|
48 | %td= sub.points |
|
50 | %td= sub.points |
|
49 | %td.fix-width= sub.grader_comment |
|
51 | %td.fix-width= sub.grader_comment |
|
50 | %td= sub.ip_address |
|
52 | %td= sub.ip_address |
|
51 | - else |
|
53 | - else |
|
52 | No submission |
|
54 | No submission |
|
53 |
|
55 | ||
|
54 | :javascript |
|
56 | :javascript |
|
55 | $("#main_table").DataTable({ |
|
57 | $("#main_table").DataTable({ |
|
56 | paging: false |
|
58 | paging: false |
|
57 | }); |
|
59 | }); |
You need to be logged in to leave comments.
Login now