Description:
rename submission_view_log class
don't log when admin is viewing
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r530:d41578f393ed - - 2 files changed: 3 inserted, 2 deleted
@@ -1,121 +1,122 | |||||
|
1 | class GradersController < ApplicationController |
|
1 | class GradersController < ApplicationController |
|
2 |
|
2 | ||
|
3 | before_filter :admin_authorization, except: [ :submission ] |
|
3 | before_filter :admin_authorization, except: [ :submission ] |
|
4 | before_filter(only: [:submission]) { |
|
4 | before_filter(only: [:submission]) { |
|
5 | return false unless authenticate |
|
5 | return false unless authenticate |
|
6 |
|
6 | ||
|
7 | if GraderConfiguration["right.user_view_submission"] |
|
7 | if GraderConfiguration["right.user_view_submission"] |
|
8 | return true; |
|
8 | return true; |
|
9 | end |
|
9 | end |
|
10 |
|
10 | ||
|
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 | @submission = Submission.order("id desc").limit(20) |
|
36 | end |
|
36 | end |
|
37 |
|
37 | ||
|
38 | def clear |
|
38 | def clear |
|
39 | grader_proc = GraderProcess.find(params[:id]) |
|
39 | grader_proc = GraderProcess.find(params[:id]) |
|
40 | grader_proc.destroy if grader_proc!=nil |
|
40 | grader_proc.destroy if grader_proc!=nil |
|
41 | redirect_to :action => 'list' |
|
41 | redirect_to :action => 'list' |
|
42 | end |
|
42 | end |
|
43 |
|
43 | ||
|
44 | def clear_terminated |
|
44 | def clear_terminated |
|
45 | GraderProcess.find_terminated_graders.each do |p| |
|
45 | GraderProcess.find_terminated_graders.each do |p| |
|
46 | p.destroy |
|
46 | p.destroy |
|
47 | end |
|
47 | end |
|
48 | redirect_to :action => 'list' |
|
48 | redirect_to :action => 'list' |
|
49 | end |
|
49 | end |
|
50 |
|
50 | ||
|
51 | def clear_all |
|
51 | def clear_all |
|
52 | GraderProcess.find(:all).each do |p| |
|
52 | GraderProcess.find(:all).each do |p| |
|
53 | p.destroy |
|
53 | p.destroy |
|
54 | end |
|
54 | end |
|
55 | redirect_to :action => 'list' |
|
55 | redirect_to :action => 'list' |
|
56 | end |
|
56 | end |
|
57 |
|
57 | ||
|
58 | def view |
|
58 | def view |
|
59 | if params[:type]=='Task' |
|
59 | if params[:type]=='Task' |
|
60 | redirect_to :action => 'task', :id => params[:id] |
|
60 | redirect_to :action => 'task', :id => params[:id] |
|
61 | else |
|
61 | else |
|
62 | redirect_to :action => 'test_request', :id => params[:id] |
|
62 | redirect_to :action => 'test_request', :id => params[:id] |
|
63 | end |
|
63 | end |
|
64 | end |
|
64 | end |
|
65 |
|
65 | ||
|
66 | def test_request |
|
66 | def test_request |
|
67 | @test_request = TestRequest.find(params[:id]) |
|
67 | @test_request = TestRequest.find(params[:id]) |
|
68 | end |
|
68 | end |
|
69 |
|
69 | ||
|
70 | def task |
|
70 | def task |
|
71 | @task = Task.find(params[:id]) |
|
71 | @task = Task.find(params[:id]) |
|
72 | end |
|
72 | end |
|
73 |
|
73 | ||
|
74 | def submission |
|
74 | def submission |
|
75 | @submission = Submission.find(params[:id]) |
|
75 | @submission = Submission.find(params[:id]) |
|
76 | formatter = Rouge::Formatters::HTML.new(css_class: 'highlight', line_numbers: true ) |
|
76 | formatter = Rouge::Formatters::HTML.new(css_class: 'highlight', line_numbers: true ) |
|
77 | lexer = case @submission.language.name |
|
77 | lexer = case @submission.language.name |
|
78 | when "c" then Rouge::Lexers::C.new |
|
78 | when "c" then Rouge::Lexers::C.new |
|
79 | when "cpp" then Rouge::Lexers::Cpp.new |
|
79 | when "cpp" then Rouge::Lexers::Cpp.new |
|
80 | when "pas" then Rouge::Lexers::Pas.new |
|
80 | when "pas" then Rouge::Lexers::Pas.new |
|
81 | when "ruby" then Rouge::Lexers::Ruby.new |
|
81 | when "ruby" then Rouge::Lexers::Ruby.new |
|
82 | when "python" then Rouge::Lexers::Python.new |
|
82 | when "python" then Rouge::Lexers::Python.new |
|
83 | when "java" then Rouge::Lexers::Java.new |
|
83 | when "java" then Rouge::Lexers::Java.new |
|
84 | when "php" then Rouge::Lexers::PHP.new |
|
84 | when "php" then Rouge::Lexers::PHP.new |
|
85 | end |
|
85 | end |
|
86 | @formatted_code = formatter.format(lexer.lex(@submission.source)) |
|
86 | @formatted_code = formatter.format(lexer.lex(@submission.source)) |
|
87 | @css_style = Rouge::Themes::ThankfulEyes.render(scope: '.highlight') |
|
87 | @css_style = Rouge::Themes::ThankfulEyes.render(scope: '.highlight') |
|
88 |
|
88 | ||
|
89 | - SubmissionViewLogs.create(user_id: session[:user_id],submission_id: @submission.id) |
|
89 | + user = User.find(session[:user_id]) |
|
|
90 | + SubmissionViewLog.create(user_id: session[:user_id],submission_id: @submission.id) unless user.admin? | ||
|
90 |
|
91 | ||
|
91 | end |
|
92 | end |
|
92 |
|
93 | ||
|
93 | # various grader controls |
|
94 | # various grader controls |
|
94 |
|
95 | ||
|
95 | def stop |
|
96 | def stop |
|
96 | grader_proc = GraderProcess.find(params[:id]) |
|
97 | grader_proc = GraderProcess.find(params[:id]) |
|
97 | GraderScript.stop_grader(grader_proc.pid) |
|
98 | GraderScript.stop_grader(grader_proc.pid) |
|
98 | flash[:notice] = 'Grader stopped. It may not disappear now, but it should disappear shortly.' |
|
99 | flash[:notice] = 'Grader stopped. It may not disappear now, but it should disappear shortly.' |
|
99 | redirect_to :action => 'list' |
|
100 | redirect_to :action => 'list' |
|
100 | end |
|
101 | end |
|
101 |
|
102 | ||
|
102 | def stop_all |
|
103 | def stop_all |
|
103 | GraderScript.stop_graders(GraderProcess.find_running_graders + |
|
104 | GraderScript.stop_graders(GraderProcess.find_running_graders + |
|
104 | GraderProcess.find_stalled_process) |
|
105 | GraderProcess.find_stalled_process) |
|
105 | flash[:notice] = 'Graders stopped. They may not disappear now, but they should disappear shortly.' |
|
106 | flash[:notice] = 'Graders stopped. They may not disappear now, but they should disappear shortly.' |
|
106 | redirect_to :action => 'list' |
|
107 | redirect_to :action => 'list' |
|
107 | end |
|
108 | end |
|
108 |
|
109 | ||
|
109 | def start_grading |
|
110 | def start_grading |
|
110 | GraderScript.start_grader('grading') |
|
111 | GraderScript.start_grader('grading') |
|
111 | flash[:notice] = '2 graders in grading env started, one for grading queue tasks, another for grading test request' |
|
112 | flash[:notice] = '2 graders in grading env started, one for grading queue tasks, another for grading test request' |
|
112 | redirect_to :action => 'list' |
|
113 | redirect_to :action => 'list' |
|
113 | end |
|
114 | end |
|
114 |
|
115 | ||
|
115 | def start_exam |
|
116 | def start_exam |
|
116 | GraderScript.start_grader('exam') |
|
117 | GraderScript.start_grader('exam') |
|
117 | flash[:notice] = '2 graders in grading env started, one for grading queue tasks, another for grading test request' |
|
118 | flash[:notice] = '2 graders in grading env started, one for grading queue tasks, another for grading test request' |
|
118 | redirect_to :action => 'list' |
|
119 | redirect_to :action => 'list' |
|
119 | end |
|
120 | end |
|
120 |
|
121 | ||
|
121 | end |
|
122 | end |
You need to be logged in to leave comments.
Login now