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
@@ -41,81 +41,82 | |||||
|
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