Description:
rename submission_view_log class don't log when admin is viewing
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r530:d41578f393ed - - 2 files changed: 3 inserted, 2 deleted

@@ -1,121 +1,122
1 1 class GradersController < ApplicationController
2 2
3 3 before_filter :admin_authorization, except: [ :submission ]
4 4 before_filter(only: [:submission]) {
5 5 return false unless authenticate
6 6
7 7 if GraderConfiguration["right.user_view_submission"]
8 8 return true;
9 9 end
10 10
11 11 admin_authorization
12 12 }
13 13
14 14 verify :method => :post, :only => ['clear_all',
15 15 'start_exam',
16 16 'start_grading',
17 17 'stop_all',
18 18 'clear_terminated'],
19 19 :redirect_to => {:action => 'index'}
20 20
21 21 def index
22 22 redirect_to :action => 'list'
23 23 end
24 24
25 25 def list
26 26 @grader_processes = GraderProcess.find_running_graders
27 27 @stalled_processes = GraderProcess.find_stalled_process
28 28
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 35 @submission = Submission.order("id desc").limit(20)
36 36 end
37 37
38 38 def clear
39 39 grader_proc = GraderProcess.find(params[:id])
40 40 grader_proc.destroy if grader_proc!=nil
41 41 redirect_to :action => 'list'
42 42 end
43 43
44 44 def clear_terminated
45 45 GraderProcess.find_terminated_graders.each do |p|
46 46 p.destroy
47 47 end
48 48 redirect_to :action => 'list'
49 49 end
50 50
51 51 def clear_all
52 52 GraderProcess.find(:all).each do |p|
53 53 p.destroy
54 54 end
55 55 redirect_to :action => 'list'
56 56 end
57 57
58 58 def view
59 59 if params[:type]=='Task'
60 60 redirect_to :action => 'task', :id => params[:id]
61 61 else
62 62 redirect_to :action => 'test_request', :id => params[:id]
63 63 end
64 64 end
65 65
66 66 def test_request
67 67 @test_request = TestRequest.find(params[:id])
68 68 end
69 69
70 70 def task
71 71 @task = Task.find(params[:id])
72 72 end
73 73
74 74 def submission
75 75 @submission = Submission.find(params[:id])
76 76 formatter = Rouge::Formatters::HTML.new(css_class: 'highlight', line_numbers: true )
77 77 lexer = case @submission.language.name
78 78 when "c" then Rouge::Lexers::C.new
79 79 when "cpp" then Rouge::Lexers::Cpp.new
80 80 when "pas" then Rouge::Lexers::Pas.new
81 81 when "ruby" then Rouge::Lexers::Ruby.new
82 82 when "python" then Rouge::Lexers::Python.new
83 83 when "java" then Rouge::Lexers::Java.new
84 84 when "php" then Rouge::Lexers::PHP.new
85 85 end
86 86 @formatted_code = formatter.format(lexer.lex(@submission.source))
87 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 92 end
92 93
93 94 # various grader controls
94 95
95 96 def stop
96 97 grader_proc = GraderProcess.find(params[:id])
97 98 GraderScript.stop_grader(grader_proc.pid)
98 99 flash[:notice] = 'Grader stopped. It may not disappear now, but it should disappear shortly.'
99 100 redirect_to :action => 'list'
100 101 end
101 102
102 103 def stop_all
103 104 GraderScript.stop_graders(GraderProcess.find_running_graders +
104 105 GraderProcess.find_stalled_process)
105 106 flash[:notice] = 'Graders stopped. They may not disappear now, but they should disappear shortly.'
106 107 redirect_to :action => 'list'
107 108 end
108 109
109 110 def start_grading
110 111 GraderScript.start_grader('grading')
111 112 flash[:notice] = '2 graders in grading env started, one for grading queue tasks, another for grading test request'
112 113 redirect_to :action => 'list'
113 114 end
114 115
115 116 def start_exam
116 117 GraderScript.start_grader('exam')
117 118 flash[:notice] = '2 graders in grading env started, one for grading queue tasks, another for grading test request'
118 119 redirect_to :action => 'list'
119 120 end
120 121
121 122 end
@@ -1,3 +1,3
1 - class SubmissionViewLogs < ActiveRecord::Base
1 + class SubmissionViewLog < ActiveRecord::Base
2 2 attr_accessible :submission_id, :user_id
3 3 end
You need to be logged in to leave comments. Login now