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: 69 inserted, 3 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] |
@@ -11,48 +11,49 | |||||
|
11 | admin_authorization |
|
11 | admin_authorization |
|
12 | } |
|
12 | } |
|
13 |
|
13 | ||
|
14 | verify :method => :post, :only => ['clear_all', |
|
14 | verify :method => :post, :only => ['clear_all', |
|
15 | 'start_exam', |
|
15 | 'start_exam', |
|
16 | 'start_grading', |
|
16 | 'start_grading', |
|
17 | 'stop_all', |
|
17 | 'stop_all', |
|
18 | 'clear_terminated'], |
|
18 | 'clear_terminated'], |
|
19 | :redirect_to => {:action => 'index'} |
|
19 | :redirect_to => {:action => 'index'} |
|
20 |
|
20 | ||
|
21 | def index |
|
21 | def index |
|
22 | redirect_to :action => 'list' |
|
22 | redirect_to :action => 'list' |
|
23 | end |
|
23 | end |
|
24 |
|
24 | ||
|
25 | def list |
|
25 | def list |
|
26 | @grader_processes = GraderProcess.find_running_graders |
|
26 | @grader_processes = GraderProcess.find_running_graders |
|
27 | @stalled_processes = GraderProcess.find_stalled_process |
|
27 | @stalled_processes = GraderProcess.find_stalled_process |
|
28 |
|
28 | ||
|
29 | @terminated_processes = GraderProcess.find_terminated_graders |
|
29 | @terminated_processes = GraderProcess.find_terminated_graders |
|
30 |
|
30 | ||
|
31 | @last_task = Task.find(:first, |
|
31 | @last_task = Task.find(:first, |
|
32 | :order => 'created_at DESC') |
|
32 | :order => 'created_at DESC') |
|
33 | @last_test_request = TestRequest.find(:first, |
|
33 | @last_test_request = TestRequest.find(:first, |
|
34 | :order => 'created_at DESC') |
|
34 | :order => 'created_at DESC') |
|
|
35 | + @submission = Submission.order("id desc").limit(20) | ||
|
35 | end |
|
36 | end |
|
36 |
|
37 | ||
|
37 | def clear |
|
38 | def clear |
|
38 | grader_proc = GraderProcess.find(params[:id]) |
|
39 | grader_proc = GraderProcess.find(params[:id]) |
|
39 | grader_proc.destroy if grader_proc!=nil |
|
40 | grader_proc.destroy if grader_proc!=nil |
|
40 | redirect_to :action => 'list' |
|
41 | redirect_to :action => 'list' |
|
41 | end |
|
42 | end |
|
42 |
|
43 | ||
|
43 | def clear_terminated |
|
44 | def clear_terminated |
|
44 | GraderProcess.find_terminated_graders.each do |p| |
|
45 | GraderProcess.find_terminated_graders.each do |p| |
|
45 | p.destroy |
|
46 | p.destroy |
|
46 | end |
|
47 | end |
|
47 | redirect_to :action => 'list' |
|
48 | redirect_to :action => 'list' |
|
48 | end |
|
49 | end |
|
49 |
|
50 | ||
|
50 | def clear_all |
|
51 | def clear_all |
|
51 | GraderProcess.find(:all).each do |p| |
|
52 | GraderProcess.find(:all).each do |p| |
|
52 | p.destroy |
|
53 | p.destroy |
|
53 | end |
|
54 | end |
|
54 | redirect_to :action => 'list' |
|
55 | redirect_to :action => 'list' |
|
55 | end |
|
56 | end |
|
56 |
|
57 | ||
|
57 | def view |
|
58 | def view |
|
58 | if params[:type]=='Task' |
|
59 | if params[:type]=='Task' |
@@ -42,49 +42,50 | |||||
|
42 | # request.path!='/main/login' |
|
42 | # request.path!='/main/login' |
|
43 | # @hidelogin = true |
|
43 | # @hidelogin = true |
|
44 | # end |
|
44 | # end |
|
45 |
|
45 | ||
|
46 | @announcements = Announcement.find_for_frontpage |
|
46 | @announcements = Announcement.find_for_frontpage |
|
47 | render :action => 'login', :layout => 'empty' |
|
47 | render :action => 'login', :layout => 'empty' |
|
48 | end |
|
48 | end |
|
49 |
|
49 | ||
|
50 | def list |
|
50 | def list |
|
51 | prepare_list_information |
|
51 | prepare_list_information |
|
52 | end |
|
52 | end |
|
53 |
|
53 | ||
|
54 | def help |
|
54 | def help |
|
55 | @user = User.find(session[:user_id]) |
|
55 | @user = User.find(session[:user_id]) |
|
56 | end |
|
56 | end |
|
57 |
|
57 | ||
|
58 | def submit |
|
58 | def submit |
|
59 | user = User.find(session[:user_id]) |
|
59 | user = User.find(session[:user_id]) |
|
60 |
|
60 | ||
|
61 | @submission = Submission.new |
|
61 | @submission = Submission.new |
|
62 | @submission.problem_id = params[:submission][:problem_id] |
|
62 | @submission.problem_id = params[:submission][:problem_id] |
|
63 | @submission.user = user |
|
63 | @submission.user = user |
|
64 | @submission.language_id = 0 |
|
64 | @submission.language_id = 0 |
|
65 | if (params['file']) and (params['file']!='') |
|
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 | @submission.source_filename = params['file'].original_filename |
|
68 | @submission.source_filename = params['file'].original_filename |
|
68 | end |
|
69 | end |
|
69 | @submission.submitted_at = Time.new.gmtime |
|
70 | @submission.submitted_at = Time.new.gmtime |
|
70 | @submission.ip_address = request.remote_ip |
|
71 | @submission.ip_address = request.remote_ip |
|
71 |
|
72 | ||
|
72 | if GraderConfiguration.time_limit_mode? and user.contest_finished? |
|
73 | if GraderConfiguration.time_limit_mode? and user.contest_finished? |
|
73 | @submission.errors.add_to_base "The contest is over." |
|
74 | @submission.errors.add_to_base "The contest is over." |
|
74 | prepare_list_information |
|
75 | prepare_list_information |
|
75 | render :action => 'list' and return |
|
76 | render :action => 'list' and return |
|
76 | end |
|
77 | end |
|
77 |
|
78 | ||
|
78 | if @submission.valid? |
|
79 | if @submission.valid? |
|
79 | if @submission.save == false |
|
80 | if @submission.save == false |
|
80 | flash[:notice] = 'Error saving your submission' |
|
81 | flash[:notice] = 'Error saving your submission' |
|
81 | elsif Task.create(:submission_id => @submission.id, |
|
82 | elsif Task.create(:submission_id => @submission.id, |
|
82 | :status => Task::STATUS_INQUEUE) == false |
|
83 | :status => Task::STATUS_INQUEUE) == false |
|
83 | flash[:notice] = 'Error adding your submission to task queue' |
|
84 | flash[:notice] = 'Error adding your submission to task queue' |
|
84 | end |
|
85 | end |
|
85 | else |
|
86 | else |
|
86 | prepare_list_information |
|
87 | prepare_list_information |
|
87 | render :action => 'list' and return |
|
88 | render :action => 'list' and return |
|
88 | end |
|
89 | end |
|
89 | redirect_to :action => 'list' |
|
90 | redirect_to :action => 'list' |
|
90 | end |
|
91 | end |
@@ -167,25 +167,50 | |||||
|
167 | if @best[:runtime][:value] >= prop[:runtime][:value] |
|
167 | if @best[:runtime][:value] >= prop[:runtime][:value] |
|
168 | @best[:runtime] = prop[:runtime] |
|
168 | @best[:runtime] = prop[:runtime] |
|
169 | @best[:runtime][:lang] = lang |
|
169 | @best[:runtime][:lang] = lang |
|
170 | end |
|
170 | end |
|
171 | if @best[:memory][:value] >= prop[:memory][:value] |
|
171 | if @best[:memory][:value] >= prop[:memory][:value] |
|
172 | @best[:memory] = prop[:memory] |
|
172 | @best[:memory] = prop[:memory] |
|
173 | @best[:memory][:lang] = lang |
|
173 | @best[:memory][:lang] = lang |
|
174 | end |
|
174 | end |
|
175 | if @best[:length][:value] >= prop[:length][:value] |
|
175 | if @best[:length][:value] >= prop[:length][:value] |
|
176 | @best[:length] = prop[:length] |
|
176 | @best[:length] = prop[:length] |
|
177 | @best[:length][:lang] = lang |
|
177 | @best[:length][:lang] = lang |
|
178 | end |
|
178 | end |
|
179 | if @best[:first][:value] >= prop[:first][:value] |
|
179 | if @best[:first][:value] >= prop[:first][:value] |
|
180 | @best[:first] = prop[:first] |
|
180 | @best[:first] = prop[:first] |
|
181 | @best[:first][:lang] = lang |
|
181 | @best[:first][:lang] = lang |
|
182 | end |
|
182 | end |
|
183 | end |
|
183 | end |
|
184 | end |
|
184 | end |
|
185 |
|
185 | ||
|
186 | @histogram[:summary][:max] = [@histogram[:data].max,1].max |
|
186 | @histogram[:summary][:max] = [@histogram[:data].max,1].max |
|
187 | @summary[:attempt] = user.count |
|
187 | @summary[:attempt] = user.count |
|
188 | user.each_value { |v| @summary[:solve] += 1 if v == 1 } |
|
188 | user.each_value { |v| @summary[:solve] += 1 if v == 1 } |
|
189 | end |
|
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 | ||
|
191 | end |
|
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 | + | ||
|
|
216 | + end |
@@ -103,48 +103,49 | |||||
|
103 | send_new_password_email(user) |
|
103 | send_new_password_email(user) |
|
104 | flash[:notice] = 'New password has been mailed to you.' |
|
104 | flash[:notice] = 'New password has been mailed to you.' |
|
105 | end |
|
105 | end |
|
106 | else |
|
106 | else |
|
107 | flash[:notice] = I18n.t 'registration.password_retrieval.no_email' |
|
107 | flash[:notice] = I18n.t 'registration.password_retrieval.no_email' |
|
108 | end |
|
108 | end |
|
109 | redirect_to :action => 'forget' |
|
109 | redirect_to :action => 'forget' |
|
110 | end |
|
110 | end |
|
111 |
|
111 | ||
|
112 | def profile |
|
112 | def profile |
|
113 | @user = User.find(params[:id]) |
|
113 | @user = User.find(params[:id]) |
|
114 | @submission = Submission.includes(:problem).where(user_id: params[:id]) |
|
114 | @submission = Submission.includes(:problem).where(user_id: params[:id]) |
|
115 |
|
115 | ||
|
116 | range = 120 |
|
116 | range = 120 |
|
117 | @histogram = { data: Array.new(range,0), summary: {} } |
|
117 | @histogram = { data: Array.new(range,0), summary: {} } |
|
118 | @summary = {count: 0, solve: 0, attempt: 0} |
|
118 | @summary = {count: 0, solve: 0, attempt: 0} |
|
119 | problem = Hash.new(0) |
|
119 | problem = Hash.new(0) |
|
120 |
|
120 | ||
|
121 | @submission.find_each do |sub| |
|
121 | @submission.find_each do |sub| |
|
122 | #histogram |
|
122 | #histogram |
|
123 | d = (DateTime.now.in_time_zone - sub.submitted_at) / 24 / 60 / 60 |
|
123 | d = (DateTime.now.in_time_zone - sub.submitted_at) / 24 / 60 / 60 |
|
124 | @histogram[:data][d.to_i] += 1 if d < range |
|
124 | @histogram[:data][d.to_i] += 1 if d < range |
|
125 |
|
125 | ||
|
126 | @summary[:count] += 1 |
|
126 | @summary[:count] += 1 |
|
|
127 | + next unless sub.problem | ||
|
127 | problem[sub.problem] = [problem[sub.problem], (sub.points >= sub.problem.full_score) ? 1 : 0].max |
|
128 | problem[sub.problem] = [problem[sub.problem], (sub.points >= sub.problem.full_score) ? 1 : 0].max |
|
128 | end |
|
129 | end |
|
129 |
|
130 | ||
|
130 | @histogram[:summary][:max] = [@histogram[:data].max,1].max |
|
131 | @histogram[:summary][:max] = [@histogram[:data].max,1].max |
|
131 | @summary[:attempt] = problem.count |
|
132 | @summary[:attempt] = problem.count |
|
132 | problem.each_value { |v| @summary[:solve] += 1 if v == 1 } |
|
133 | problem.each_value { |v| @summary[:solve] += 1 if v == 1 } |
|
133 | end |
|
134 | end |
|
134 |
|
135 | ||
|
135 | protected |
|
136 | protected |
|
136 |
|
137 | ||
|
137 | def verify_online_registration |
|
138 | def verify_online_registration |
|
138 | if !GraderConfiguration['system.online_registration'] |
|
139 | if !GraderConfiguration['system.online_registration'] |
|
139 | redirect_to :controller => 'main', :action => 'login' |
|
140 | redirect_to :controller => 'main', :action => 'login' |
|
140 | end |
|
141 | end |
|
141 | end |
|
142 | end |
|
142 |
|
143 | ||
|
143 | def send_confirmation_email(user) |
|
144 | def send_confirmation_email(user) |
|
144 | contest_name = GraderConfiguration['contest.name'] |
|
145 | contest_name = GraderConfiguration['contest.name'] |
|
145 | activation_url = url_for(:action => 'confirm', |
|
146 | activation_url = url_for(:action => 'confirm', |
|
146 | :login => user.login, |
|
147 | :login => user.login, |
|
147 | :activation => user.activation_key) |
|
148 | :activation => user.activation_key) |
|
148 | home_url = url_for(:controller => 'main', :action => 'index') |
|
149 | home_url = url_for(:controller => 'main', :action => 'index') |
|
149 | mail_subject = "[#{contest_name}] Confirmation" |
|
150 | mail_subject = "[#{contest_name}] Confirmation" |
|
150 | mail_body = t('registration.email_body', { |
|
151 | mail_body = t('registration.email_body', { |
@@ -3,49 +3,70 | |||||
|
3 | <meta http-equiv ="refresh" content="60"/> |
|
3 | <meta http-equiv ="refresh" content="60"/> |
|
4 |
|
4 | ||
|
5 | %h1 Grader information |
|
5 | %h1 Grader information |
|
6 |
|
6 | ||
|
7 | = link_to '[Refresh]', :action => 'list' |
|
7 | = link_to '[Refresh]', :action => 'list' |
|
8 | %br/ |
|
8 | %br/ |
|
9 |
|
9 | ||
|
10 | .submitbox |
|
10 | .submitbox |
|
11 | .item |
|
11 | .item |
|
12 | Grader control: |
|
12 | Grader control: |
|
13 | .item |
|
13 | .item |
|
14 | = form_for :clear, :url => {:action => 'start_grading'} do |f| |
|
14 | = form_for :clear, :url => {:action => 'start_grading'} do |f| |
|
15 | = submit_tag 'Start graders in grading env' |
|
15 | = submit_tag 'Start graders in grading env' |
|
16 | .item |
|
16 | .item |
|
17 | = form_for :clear, :url => {:action => 'start_exam'} do |f| |
|
17 | = form_for :clear, :url => {:action => 'start_exam'} do |f| |
|
18 | = submit_tag 'Start graders in exam env' |
|
18 | = submit_tag 'Start graders in exam env' |
|
19 | .item |
|
19 | .item |
|
20 | = form_for :clear, :url => {:action => 'stop_all'} do |f| |
|
20 | = form_for :clear, :url => {:action => 'stop_all'} do |f| |
|
21 | = submit_tag 'Stop all running graders' |
|
21 | = submit_tag 'Stop all running graders' |
|
22 | .item |
|
22 | .item |
|
23 | = form_for :clear, :url => {:action => 'clear_all'} do |f| |
|
23 | = form_for :clear, :url => {:action => 'clear_all'} do |f| |
|
24 | = submit_tag 'Clear all data' |
|
24 | = submit_tag 'Clear all data' |
|
25 | %br{:style => 'clear:both'}/ |
|
25 | %br{:style => 'clear:both'}/ |
|
26 |
|
26 | ||
|
|
27 | + %div{style: 'width:500px; float: left;'} | ||
|
27 | - if @last_task |
|
28 | - if @last_task |
|
28 | Last task: |
|
29 | Last task: |
|
29 | = link_to "#{@last_task.id}", :action => 'view', :id => @last_task.id, :type => 'Task' |
|
30 | = link_to "#{@last_task.id}", :action => 'view', :id => @last_task.id, :type => 'Task' |
|
30 |
|
31 | ||
|
31 | %br/ |
|
32 | %br/ |
|
32 |
|
33 | ||
|
33 | - if @last_test_request |
|
34 | - if @last_test_request |
|
34 | Last test_request: |
|
35 | Last test_request: |
|
35 | = link_to "#{@last_test_request.id}", :action => 'view', :id => @last_test_request.id, :type => 'TestRequest' |
|
36 | = link_to "#{@last_test_request.id}", :action => 'view', :id => @last_test_request.id, :type => 'TestRequest' |
|
36 |
|
37 | ||
|
37 | - |
|
||
|
38 | %h2 Current graders |
|
38 | %h2 Current graders |
|
39 |
|
39 | ||
|
40 | = render :partial => 'grader_list', :locals => {:grader_list => @grader_processes} |
|
40 | = render :partial => 'grader_list', :locals => {:grader_list => @grader_processes} |
|
41 |
|
41 | ||
|
42 | %h2 Stalled graders |
|
42 | %h2 Stalled graders |
|
43 |
|
43 | ||
|
44 | = render :partial => 'grader_list', :locals => {:grader_list => @stalled_processes} |
|
44 | = render :partial => 'grader_list', :locals => {:grader_list => @stalled_processes} |
|
45 |
|
45 | ||
|
46 | %h2 Terminated graders |
|
46 | %h2 Terminated graders |
|
47 |
|
47 | ||
|
48 | = form_for :clear, :url => {:action => 'clear_terminated'} do |f| |
|
48 | = form_for :clear, :url => {:action => 'clear_terminated'} do |f| |
|
49 | = submit_tag 'Clear data for terminated graders' |
|
49 | = submit_tag 'Clear data for terminated graders' |
|
50 |
|
50 | ||
|
51 | = render :partial => 'grader_list', :locals => {:grader_list => @terminated_processes} |
|
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 | ||
|
|
71 | + | ||
|
|
72 | + |
@@ -1,7 +1,7 | |||||
|
1 |
|
1 | ||
|
2 | .task-menu |
|
2 | .task-menu |
|
3 | Reports |
|
3 | Reports |
|
4 | %br/ |
|
4 | %br/ |
|
5 | = link_to '[Hall of Fame]', :action => 'problem_hof' |
|
5 | = link_to '[Hall of Fame]', :action => 'problem_hof' |
|
6 |
- = link_to '[S |
|
6 | + = link_to '[Struggle]', :action => 'stuck' |
|
7 | = link_to '[Login]', :action => 'login_stat' |
|
7 | = link_to '[Login]', :action => 'login_stat' |
You need to be logged in to leave comments.
Login now