Description:
merge
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r515:25e5802e70aa - - 7 files changed: 89 inserted, 23 deleted
@@ -0,0 +1,17 | |||
|
1 | + %table.info | |
|
2 | + %thead | |
|
3 | + %tr.info-head | |
|
4 | + %th Problem | |
|
5 | + %th User | |
|
6 | + %th tries | |
|
7 | + %tbody | |
|
8 | + - @struggle.each do |s| | |
|
9 | + %tr | |
|
10 | + %td | |
|
11 | + = link_to "(#{s[:problem].name})", controller: :problems, action: :stat, id: s[:problem] | |
|
12 | + = s[:problem].full_name | |
|
13 | + %td | |
|
14 | + = link_to "(#{s[:user].login})", controller: :users, action: :profile, id: s[:user] | |
|
15 | + = s[:user].full_name | |
|
16 | + %td | |
|
17 | + = s[:tries] |
@@ -29,12 +29,13 | |||
|
29 | 29 | @terminated_processes = GraderProcess.find_terminated_graders |
|
30 | 30 | |
|
31 | 31 | @last_task = Task.find(:first, |
|
32 | 32 | :order => 'created_at DESC') |
|
33 | 33 | @last_test_request = TestRequest.find(:first, |
|
34 | 34 | :order => 'created_at DESC') |
|
35 | + @submission = Submission.order("id desc").limit(20) | |
|
35 | 36 | end |
|
36 | 37 | |
|
37 | 38 | def clear |
|
38 | 39 | grader_proc = GraderProcess.find(params[:id]) |
|
39 | 40 | grader_proc.destroy if grader_proc!=nil |
|
40 | 41 | redirect_to :action => 'list' |
@@ -60,13 +60,14 | |||
|
60 | 60 | |
|
61 | 61 | @submission = Submission.new |
|
62 | 62 | @submission.problem_id = params[:submission][:problem_id] |
|
63 | 63 | @submission.user = user |
|
64 | 64 | @submission.language_id = 0 |
|
65 | 65 | if (params['file']) and (params['file']!='') |
|
66 | - @submission.source = params['file'].read | |
|
66 | + @submission.source = File.open(params['file'].path,'r:UTF-8',&:read) | |
|
67 | + @submission.source.encode!('UTF-8','UTF-8',invalid: :replace, replace: '') | |
|
67 | 68 | @submission.source_filename = params['file'].original_filename |
|
68 | 69 | end |
|
69 | 70 | @submission.submitted_at = Time.new.gmtime |
|
70 | 71 | @submission.ip_address = request.remote_ip |
|
71 | 72 | |
|
72 | 73 | if GraderConfiguration.time_limit_mode? and user.contest_finished? |
@@ -185,7 +185,32 | |||
|
185 | 185 | |
|
186 | 186 | @histogram[:summary][:max] = [@histogram[:data].max,1].max |
|
187 | 187 | @summary[:attempt] = user.count |
|
188 | 188 | user.each_value { |v| @summary[:solve] += 1 if v == 1 } |
|
189 | 189 | end |
|
190 | 190 | |
|
191 | + def stuck #report struggling user,problem | |
|
192 | + # init | |
|
193 | + user,problem = nil | |
|
194 | + solve = true | |
|
195 | + tries = 0 | |
|
196 | + @struggle = Array.new | |
|
197 | + record = {} | |
|
198 | + Submission.includes(:problem,:user).order(:problem_id,:user_id).find_each do |sub| | |
|
199 | + if user != sub.user_id or problem != sub.problem_id | |
|
200 | + @struggle << { user: record[:user], problem: record[:problem], tries: tries } unless solve | |
|
201 | + record = {user: sub.user, problem: sub.problem} | |
|
202 | + user,problem = sub.user_id, sub.problem_id | |
|
203 | + solve = false | |
|
204 | + tries = 0 | |
|
205 | + end | |
|
206 | + if sub.points >= sub.problem.full_score | |
|
207 | + solve = true | |
|
208 | + else | |
|
209 | + tries += 1 | |
|
210 | + end | |
|
211 | + end | |
|
212 | + @struggle.sort!{|a,b| b[:tries] <=> a[:tries] } | |
|
213 | + @struggle = @struggle[0..50] | |
|
214 | + end | |
|
215 | + | |
|
191 | 216 | end |
@@ -121,12 +121,13 | |||
|
121 | 121 | @submission.find_each do |sub| |
|
122 | 122 | #histogram |
|
123 | 123 | d = (DateTime.now.in_time_zone - sub.submitted_at) / 24 / 60 / 60 |
|
124 | 124 | @histogram[:data][d.to_i] += 1 if d < range |
|
125 | 125 | |
|
126 | 126 | @summary[:count] += 1 |
|
127 | + next unless sub.problem | |
|
127 | 128 | problem[sub.problem] = [problem[sub.problem], (sub.points >= sub.problem.full_score) ? 1 : 0].max |
|
128 | 129 | end |
|
129 | 130 | |
|
130 | 131 | @histogram[:summary][:max] = [@histogram[:data].max,1].max |
|
131 | 132 | @summary[:attempt] = problem.count |
|
132 | 133 | problem.each_value { |v| @summary[:solve] += 1 if v == 1 } |
@@ -21,31 +21,52 | |||
|
21 | 21 | = submit_tag 'Stop all running graders' |
|
22 | 22 | .item |
|
23 | 23 | = form_for :clear, :url => {:action => 'clear_all'} do |f| |
|
24 | 24 | = submit_tag 'Clear all data' |
|
25 | 25 | %br{:style => 'clear:both'}/ |
|
26 | 26 | |
|
27 | - - if @last_task | |
|
28 |
- |
|
|
29 | - = link_to "#{@last_task.id}", :action => 'view', :id => @last_task.id, :type => 'Task' | |
|
27 | + %div{style: 'width:500px; float: left;'} | |
|
28 | + - if @last_task | |
|
29 | + Last task: | |
|
30 | + = link_to "#{@last_task.id}", :action => 'view', :id => @last_task.id, :type => 'Task' | |
|
31 | + | |
|
32 | + %br/ | |
|
33 | + | |
|
34 | + - if @last_test_request | |
|
35 | + Last test_request: | |
|
36 | + = link_to "#{@last_test_request.id}", :action => 'view', :id => @last_test_request.id, :type => 'TestRequest' | |
|
37 | + | |
|
38 | + %h2 Current graders | |
|
39 | + | |
|
40 | + = render :partial => 'grader_list', :locals => {:grader_list => @grader_processes} | |
|
41 | + | |
|
42 | + %h2 Stalled graders | |
|
43 | + | |
|
44 | + = render :partial => 'grader_list', :locals => {:grader_list => @stalled_processes} | |
|
45 | + | |
|
46 | + %h2 Terminated graders | |
|
30 | 47 | |
|
31 | - %br/ | |
|
48 | + = form_for :clear, :url => {:action => 'clear_terminated'} do |f| | |
|
49 | + = submit_tag 'Clear data for terminated graders' | |
|
32 | 50 | |
|
33 | - - if @last_test_request | |
|
34 | - Last test_request: | |
|
35 | - = link_to "#{@last_test_request.id}", :action => 'view', :id => @last_test_request.id, :type => 'TestRequest' | |
|
51 | + = render :partial => 'grader_list', :locals => {:grader_list => @terminated_processes} | |
|
52 | + %div{} | |
|
53 | + %h2 Last 20 submissions | |
|
54 | + %table.graders | |
|
55 | + %thead | |
|
56 | + %th ID | |
|
57 | + %th User | |
|
58 | + %th Problem | |
|
59 | + %th Submitted | |
|
60 | + %th Graded | |
|
61 | + %th Result | |
|
62 | + %tbody | |
|
63 | + - @submission.each do |sub| | |
|
64 | + %tr.inactive | |
|
65 | + %td= link_to sub.id, controller: 'graders' ,action: 'submission', id: sub.id | |
|
66 | + %td= sub.try(:user).try(:full_name) | |
|
67 | + %td= sub.try(:problem).try(:full_name) | |
|
68 | + %td= "#{time_ago_in_words(sub.submitted_at)} ago" | |
|
69 | + %td= "#{time_ago_in_words(sub.graded_at)} ago" | |
|
70 | + %td= sub.grader_comment | |
|
36 | 71 | |
|
37 | 72 | |
|
38 | - %h2 Current graders | |
|
39 | - | |
|
40 | - = render :partial => 'grader_list', :locals => {:grader_list => @grader_processes} | |
|
41 | - | |
|
42 | - %h2 Stalled graders | |
|
43 | - | |
|
44 | - = render :partial => 'grader_list', :locals => {:grader_list => @stalled_processes} | |
|
45 | - | |
|
46 | - %h2 Terminated graders | |
|
47 | - | |
|
48 | - = form_for :clear, :url => {:action => 'clear_terminated'} do |f| | |
|
49 | - = submit_tag 'Clear data for terminated graders' | |
|
50 | - | |
|
51 | - = render :partial => 'grader_list', :locals => {:grader_list => @terminated_processes} |
You need to be logged in to leave comments.
Login now