Description:
add submission view loggin
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r529:32578781bde7 - - 3 files changed: 8 inserted, 2 deleted

@@ -0,0 +1,5
1 + class AddLastIpToUser < ActiveRecord::Migration
2 + def change
3 + add_column :users, :last_ip, :string
4 + end
5 + end
@@ -1,121 +1,121
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 - SubmissionLogView.create(user_id: user.id,submission_id: @submission.id)
89 + SubmissionViewLogs.create(user_id: session[:user_id],submission_id: @submission.id)
90
90
91 end
91 end
92
92
93 # various grader controls
93 # various grader controls
94
94
95 def stop
95 def stop
96 grader_proc = GraderProcess.find(params[:id])
96 grader_proc = GraderProcess.find(params[:id])
97 GraderScript.stop_grader(grader_proc.pid)
97 GraderScript.stop_grader(grader_proc.pid)
98 flash[:notice] = 'Grader stopped. It may not disappear now, but it should disappear shortly.'
98 flash[:notice] = 'Grader stopped. It may not disappear now, but it should disappear shortly.'
99 redirect_to :action => 'list'
99 redirect_to :action => 'list'
100 end
100 end
101
101
102 def stop_all
102 def stop_all
103 GraderScript.stop_graders(GraderProcess.find_running_graders +
103 GraderScript.stop_graders(GraderProcess.find_running_graders +
104 GraderProcess.find_stalled_process)
104 GraderProcess.find_stalled_process)
105 flash[:notice] = 'Graders stopped. They may not disappear now, but they should disappear shortly.'
105 flash[:notice] = 'Graders stopped. They may not disappear now, but they should disappear shortly.'
106 redirect_to :action => 'list'
106 redirect_to :action => 'list'
107 end
107 end
108
108
109 def start_grading
109 def start_grading
110 GraderScript.start_grader('grading')
110 GraderScript.start_grader('grading')
111 flash[:notice] = '2 graders in grading env started, one for grading queue tasks, another for grading test request'
111 flash[:notice] = '2 graders in grading env started, one for grading queue tasks, another for grading test request'
112 redirect_to :action => 'list'
112 redirect_to :action => 'list'
113 end
113 end
114
114
115 def start_exam
115 def start_exam
116 GraderScript.start_grader('exam')
116 GraderScript.start_grader('exam')
117 flash[:notice] = '2 graders in grading env started, one for grading queue tasks, another for grading test request'
117 flash[:notice] = '2 graders in grading env started, one for grading queue tasks, another for grading test request'
118 redirect_to :action => 'list'
118 redirect_to :action => 'list'
119 end
119 end
120
120
121 end
121 end
@@ -1,110 +1,110
1 # encoding: UTF-8
1 # encoding: UTF-8
2 # This file is auto-generated from the current state of the database. Instead
2 # This file is auto-generated from the current state of the database. Instead
3 # of editing this file, please use the migrations feature of Active Record to
3 # of editing this file, please use the migrations feature of Active Record to
4 # incrementally modify your database, and then regenerate this schema definition.
4 # incrementally modify your database, and then regenerate this schema definition.
5 #
5 #
6 # Note that this schema.rb definition is the authoritative source for your
6 # Note that this schema.rb definition is the authoritative source for your
7 # database schema. If you need to create the application database on another
7 # database schema. If you need to create the application database on another
8 # system, you should be using db:schema:load, not running all the migrations
8 # system, you should be using db:schema:load, not running all the migrations
9 # from scratch. The latter is a flawed and unsustainable approach (the more migrations
9 # from scratch. The latter is a flawed and unsustainable approach (the more migrations
10 # you'll amass, the slower it'll run and the greater likelihood for issues).
10 # you'll amass, the slower it'll run and the greater likelihood for issues).
11 #
11 #
12 # It's strongly recommended to check this file into your version control system.
12 # It's strongly recommended to check this file into your version control system.
13
13
14 - ActiveRecord::Schema.define(:version => 20150827131927) do
14 + ActiveRecord::Schema.define(:version => 20150827133841) do
15
15
16 create_table "announcements", :force => true do |t|
16 create_table "announcements", :force => true do |t|
17 t.string "author"
17 t.string "author"
18 t.text "body", :limit => 16777215
18 t.text "body", :limit => 16777215
19 t.boolean "published"
19 t.boolean "published"
20 t.datetime "created_at", :null => false
20 t.datetime "created_at", :null => false
21 t.datetime "updated_at", :null => false
21 t.datetime "updated_at", :null => false
22 t.boolean "frontpage", :default => false
22 t.boolean "frontpage", :default => false
23 t.boolean "contest_only", :default => false
23 t.boolean "contest_only", :default => false
24 t.string "title"
24 t.string "title"
25 t.string "notes"
25 t.string "notes"
26 end
26 end
27
27
28 create_table "contests", :force => true do |t|
28 create_table "contests", :force => true do |t|
29 t.string "title"
29 t.string "title"
30 t.boolean "enabled"
30 t.boolean "enabled"
31 t.datetime "created_at", :null => false
31 t.datetime "created_at", :null => false
32 t.datetime "updated_at", :null => false
32 t.datetime "updated_at", :null => false
33 t.string "name"
33 t.string "name"
34 end
34 end
35
35
36 create_table "contests_problems", :id => false, :force => true do |t|
36 create_table "contests_problems", :id => false, :force => true do |t|
37 t.integer "contest_id"
37 t.integer "contest_id"
38 t.integer "problem_id"
38 t.integer "problem_id"
39 end
39 end
40
40
41 create_table "contests_users", :id => false, :force => true do |t|
41 create_table "contests_users", :id => false, :force => true do |t|
42 t.integer "contest_id"
42 t.integer "contest_id"
43 t.integer "user_id"
43 t.integer "user_id"
44 end
44 end
45
45
46 create_table "countries", :force => true do |t|
46 create_table "countries", :force => true do |t|
47 t.string "name"
47 t.string "name"
48 t.datetime "created_at", :null => false
48 t.datetime "created_at", :null => false
49 t.datetime "updated_at", :null => false
49 t.datetime "updated_at", :null => false
50 end
50 end
51
51
52 create_table "descriptions", :force => true do |t|
52 create_table "descriptions", :force => true do |t|
53 t.text "body", :limit => 16777215
53 t.text "body", :limit => 16777215
54 t.boolean "markdowned"
54 t.boolean "markdowned"
55 t.datetime "created_at", :null => false
55 t.datetime "created_at", :null => false
56 t.datetime "updated_at", :null => false
56 t.datetime "updated_at", :null => false
57 end
57 end
58
58
59 create_table "grader_configurations", :force => true do |t|
59 create_table "grader_configurations", :force => true do |t|
60 t.string "key"
60 t.string "key"
61 t.string "value_type"
61 t.string "value_type"
62 t.string "value"
62 t.string "value"
63 t.datetime "created_at", :null => false
63 t.datetime "created_at", :null => false
64 t.datetime "updated_at", :null => false
64 t.datetime "updated_at", :null => false
65 t.text "description", :limit => 16777215
65 t.text "description", :limit => 16777215
66 end
66 end
67
67
68 create_table "grader_processes", :force => true do |t|
68 create_table "grader_processes", :force => true do |t|
69 t.string "host", :limit => 20
69 t.string "host", :limit => 20
70 t.integer "pid"
70 t.integer "pid"
71 t.string "mode"
71 t.string "mode"
72 t.boolean "active"
72 t.boolean "active"
73 t.datetime "created_at", :null => false
73 t.datetime "created_at", :null => false
74 t.datetime "updated_at", :null => false
74 t.datetime "updated_at", :null => false
75 t.integer "task_id"
75 t.integer "task_id"
76 t.string "task_type"
76 t.string "task_type"
77 t.boolean "terminated"
77 t.boolean "terminated"
78 end
78 end
79
79
80 add_index "grader_processes", ["host", "pid"], :name => "index_grader_processes_on_ip_and_pid"
80 add_index "grader_processes", ["host", "pid"], :name => "index_grader_processes_on_ip_and_pid"
81
81
82 create_table "languages", :force => true do |t|
82 create_table "languages", :force => true do |t|
83 t.string "name", :limit => 10
83 t.string "name", :limit => 10
84 t.string "pretty_name"
84 t.string "pretty_name"
85 t.string "ext", :limit => 10
85 t.string "ext", :limit => 10
86 t.string "common_ext"
86 t.string "common_ext"
87 end
87 end
88
88
89 create_table "logins", :force => true do |t|
89 create_table "logins", :force => true do |t|
90 t.integer "user_id"
90 t.integer "user_id"
91 t.string "ip_address"
91 t.string "ip_address"
92 t.datetime "created_at", :null => false
92 t.datetime "created_at", :null => false
93 t.datetime "updated_at", :null => false
93 t.datetime "updated_at", :null => false
94 end
94 end
95
95
96 create_table "messages", :force => true do |t|
96 create_table "messages", :force => true do |t|
97 t.integer "sender_id"
97 t.integer "sender_id"
98 t.integer "receiver_id"
98 t.integer "receiver_id"
99 t.integer "replying_message_id"
99 t.integer "replying_message_id"
100 t.text "body", :limit => 16777215
100 t.text "body", :limit => 16777215
101 t.boolean "replied"
101 t.boolean "replied"
102 t.datetime "created_at", :null => false
102 t.datetime "created_at", :null => false
103 t.datetime "updated_at", :null => false
103 t.datetime "updated_at", :null => false
104 end
104 end
105
105
106 create_table "problems", :force => true do |t|
106 create_table "problems", :force => true do |t|
107 t.string "name", :limit => 30
107 t.string "name", :limit => 30
108 t.string "full_name"
108 t.string "full_name"
109 t.integer "full_score"
109 t.integer "full_score"
110 t.date "date_added"
110 t.date "date_added"
@@ -156,101 +156,102
156 t.datetime "created_at", :null => false
156 t.datetime "created_at", :null => false
157 t.datetime "updated_at", :null => false
157 t.datetime "updated_at", :null => false
158 t.integer "country_id"
158 t.integer "country_id"
159 t.string "password"
159 t.string "password"
160 end
160 end
161
161
162 create_table "submission_view_logs", :force => true do |t|
162 create_table "submission_view_logs", :force => true do |t|
163 t.integer "user_id"
163 t.integer "user_id"
164 t.integer "submission_id"
164 t.integer "submission_id"
165 t.datetime "created_at", :null => false
165 t.datetime "created_at", :null => false
166 t.datetime "updated_at", :null => false
166 t.datetime "updated_at", :null => false
167 end
167 end
168
168
169 create_table "submissions", :force => true do |t|
169 create_table "submissions", :force => true do |t|
170 t.integer "user_id"
170 t.integer "user_id"
171 t.integer "problem_id"
171 t.integer "problem_id"
172 t.integer "language_id"
172 t.integer "language_id"
173 t.text "source", :limit => 16777215
173 t.text "source", :limit => 16777215
174 t.binary "binary"
174 t.binary "binary"
175 t.datetime "submitted_at"
175 t.datetime "submitted_at"
176 t.datetime "compiled_at"
176 t.datetime "compiled_at"
177 t.text "compiler_message", :limit => 16777215
177 t.text "compiler_message", :limit => 16777215
178 t.datetime "graded_at"
178 t.datetime "graded_at"
179 t.integer "points"
179 t.integer "points"
180 t.text "grader_comment", :limit => 16777215
180 t.text "grader_comment", :limit => 16777215
181 t.integer "number"
181 t.integer "number"
182 t.string "source_filename"
182 t.string "source_filename"
183 t.float "max_runtime"
183 t.float "max_runtime"
184 t.integer "peak_memory"
184 t.integer "peak_memory"
185 t.integer "effective_code_length"
185 t.integer "effective_code_length"
186 t.string "ip_address"
186 t.string "ip_address"
187 end
187 end
188
188
189 add_index "submissions", ["user_id", "problem_id", "number"], :name => "index_submissions_on_user_id_and_problem_id_and_number", :unique => true
189 add_index "submissions", ["user_id", "problem_id", "number"], :name => "index_submissions_on_user_id_and_problem_id_and_number", :unique => true
190 add_index "submissions", ["user_id", "problem_id"], :name => "index_submissions_on_user_id_and_problem_id"
190 add_index "submissions", ["user_id", "problem_id"], :name => "index_submissions_on_user_id_and_problem_id"
191
191
192 create_table "tasks", :force => true do |t|
192 create_table "tasks", :force => true do |t|
193 t.integer "submission_id"
193 t.integer "submission_id"
194 t.datetime "created_at"
194 t.datetime "created_at"
195 t.integer "status"
195 t.integer "status"
196 t.datetime "updated_at"
196 t.datetime "updated_at"
197 end
197 end
198
198
199 create_table "test_pairs", :force => true do |t|
199 create_table "test_pairs", :force => true do |t|
200 t.integer "problem_id"
200 t.integer "problem_id"
201 t.text "input", :limit => 2147483647
201 t.text "input", :limit => 2147483647
202 t.text "solution", :limit => 2147483647
202 t.text "solution", :limit => 2147483647
203 t.datetime "created_at", :null => false
203 t.datetime "created_at", :null => false
204 t.datetime "updated_at", :null => false
204 t.datetime "updated_at", :null => false
205 end
205 end
206
206
207 create_table "test_requests", :force => true do |t|
207 create_table "test_requests", :force => true do |t|
208 t.integer "user_id"
208 t.integer "user_id"
209 t.integer "problem_id"
209 t.integer "problem_id"
210 t.integer "submission_id"
210 t.integer "submission_id"
211 t.string "input_file_name"
211 t.string "input_file_name"
212 t.string "output_file_name"
212 t.string "output_file_name"
213 t.string "running_stat"
213 t.string "running_stat"
214 t.integer "status"
214 t.integer "status"
215 t.datetime "updated_at", :null => false
215 t.datetime "updated_at", :null => false
216 t.datetime "submitted_at"
216 t.datetime "submitted_at"
217 t.datetime "compiled_at"
217 t.datetime "compiled_at"
218 t.text "compiler_message", :limit => 16777215
218 t.text "compiler_message", :limit => 16777215
219 t.datetime "graded_at"
219 t.datetime "graded_at"
220 t.string "grader_comment"
220 t.string "grader_comment"
221 t.datetime "created_at", :null => false
221 t.datetime "created_at", :null => false
222 t.float "running_time"
222 t.float "running_time"
223 t.string "exit_status"
223 t.string "exit_status"
224 t.integer "memory_usage"
224 t.integer "memory_usage"
225 end
225 end
226
226
227 add_index "test_requests", ["user_id", "problem_id"], :name => "index_test_requests_on_user_id_and_problem_id"
227 add_index "test_requests", ["user_id", "problem_id"], :name => "index_test_requests_on_user_id_and_problem_id"
228
228
229 create_table "user_contest_stats", :force => true do |t|
229 create_table "user_contest_stats", :force => true do |t|
230 t.integer "user_id"
230 t.integer "user_id"
231 t.datetime "started_at"
231 t.datetime "started_at"
232 t.datetime "created_at", :null => false
232 t.datetime "created_at", :null => false
233 t.datetime "updated_at", :null => false
233 t.datetime "updated_at", :null => false
234 t.boolean "forced_logout"
234 t.boolean "forced_logout"
235 end
235 end
236
236
237 create_table "users", :force => true do |t|
237 create_table "users", :force => true do |t|
238 t.string "login", :limit => 50
238 t.string "login", :limit => 50
239 t.string "full_name"
239 t.string "full_name"
240 t.string "hashed_password"
240 t.string "hashed_password"
241 t.string "salt", :limit => 5
241 t.string "salt", :limit => 5
242 t.string "alias"
242 t.string "alias"
243 t.string "email"
243 t.string "email"
244 t.integer "site_id"
244 t.integer "site_id"
245 t.integer "country_id"
245 t.integer "country_id"
246 t.boolean "activated", :default => false
246 t.boolean "activated", :default => false
247 t.datetime "created_at"
247 t.datetime "created_at"
248 t.datetime "updated_at"
248 t.datetime "updated_at"
249 t.string "section"
249 t.string "section"
250 t.boolean "enabled", :default => true
250 t.boolean "enabled", :default => true
251 t.string "remark"
251 t.string "remark"
252 + t.string "last_ip"
252 end
253 end
253
254
254 add_index "users", ["login"], :name => "index_users_on_login", :unique => true
255 add_index "users", ["login"], :name => "index_users_on_login", :unique => true
255
256
256 end
257 end
You need to be logged in to leave comments. Login now