Description:
fix compiler message add testing database
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r621:3b5645cfc80e - - 9 files changed: 125 inserted, 106 deleted

@@ -9,6 +9,7
9 9 # gem 'rails', :git => 'git://github.com/rails/rails.git'
10 10
11 11 gem 'mysql2'
12 + gem 'sqlite3'
12 13
13 14 # Gems used only for assets and not required
14 15 # in production environments by default.
@@ -45,7 +46,7
45 46
46 47 # jquery addition
47 48 gem 'jquery-rails'
48 - gem 'jquery-ui-sass-rails'
49 + gem 'jquery-ui-rails'
49 50 gem 'jquery-timepicker-addon-rails'
50 51 gem 'jquery-tablesorter'
51 52 gem 'jquery-countdown-rails'
@@ -103,10 +103,6
103 103 jquery-ui-rails (4.0.3)
104 104 jquery-rails
105 105 railties (>= 3.1.0)
106 - jquery-ui-sass-rails (4.0.3.0)
107 - jquery-rails
108 - jquery-ui-rails (= 4.0.3)
109 - railties (>= 3.1.0)
110 106 json (1.8.3)
111 107 loofah (2.0.3)
112 108 nokogiri (>= 1.5.9)
@@ -192,6 +188,7
192 188 actionpack (>= 4.0)
193 189 activesupport (>= 4.0)
194 190 sprockets (>= 3.0.0)
191 + sqlite3 (1.3.12)
195 192 test-unit (3.2.3)
196 193 power_assert
197 194 thor (0.19.4)
@@ -223,7 +220,7
223 220 jquery-rails
224 221 jquery-tablesorter
225 222 jquery-timepicker-addon-rails
226 - jquery-ui-sass-rails
223 + jquery-ui-rails
227 224 mail
228 225 momentjs-rails
229 226 mysql2
@@ -234,6 +231,7
234 231 rspec-rails
235 232 sass-rails
236 233 select2-rails
234 + sqlite3
237 235 test-unit
238 236 uglifier
239 237 verification!
@@ -1,6 +1,6
1 1 class SubmissionsController < ApplicationController
2 2 before_filter :authenticate
3 - before_filter :submission_authorization, only: [:show, :direct_edit_submission]
3 + before_filter :submission_authorization, only: [:show, :direct_edit_submission, :download]
4 4
5 5 # GET /submissions
6 6 # GET /submissions.json
@@ -33,6 +33,18
33 33 SubmissionViewLog.create(user_id: session[:user_id],submission_id: @submission.id) unless user.admin?
34 34 end
35 35
36 + def download
37 + @submission = Submission.find(params[:id])
38 + send_data(@submission.source, {:filename => @submission.download_filename, :type => 'text/plain'})
39 + end
40 +
41 + def compiler_msg
42 + @submission = Submission.find(params[:id])
43 + respond_to do |format|
44 + format.js
45 + end
46 + end
47 +
36 48 #on-site new submission on specific problem
37 49 def direct_edit_problem
38 50 @problem = Problem.find(params[:problem_id])
@@ -62,6 +74,7
62 74
63 75
64 76 protected
77 +
65 78 def submission_authorization
66 79 #admin always has privileged
67 80 if @current_user.admin?
@@ -6,21 +6,21
6 6 = t 'main.submitted_at'
7 7 = format_short_time(submission.submitted_at.localtime)
8 8 - else
9 - = t 'main.graded_at'
10 - = "#{format_short_time(submission.graded_at.localtime)}, "
9 + %strong= t 'main.graded_at'
10 + = "#{format_short_time(submission.graded_at.localtime)} "
11 + %br
11 12 - if GraderConfiguration['ui.show_score']
12 - = t 'main.score'
13 + %strong=t 'main.score'
13 14 = "#{(submission.points*100/submission.problem.full_score).to_i} "
14 15 = " ["
15 16 %tt
16 17 = submission.grader_comment
17 18 = "]"
19 + %br
20 + %strong View:
18 21 - if GraderConfiguration.show_grading_result
19 - = " | "
20 22 = link_to '[detailed result]', :action => 'result', :id => submission.id
21 - = " | "
22 - = link_to("[#{t 'main.cmp_msg'}]", {:action => 'compiler_msg', :id => submission.id}, {:popup => true})
23 - = " | "
24 - = link_to("[#{t 'main.src_link'}]",{:action => 'source', :id => submission.id})
25 - //= " | "
26 - //= link_to "[#{t 'main.submissions_link'}]", main_submission_path(submission.problem.id)
23 + = link_to "#{t 'main.cmp_msg'}", {:action => 'compiler_msg', :id => submission.id}, {popup: true,class: 'btn btn-xs btn-info'}
24 + = link_to "#{t 'main.src_link'}", download_submission_path(submission.id), class: 'btn btn-xs btn-info'
25 + = link_to "#{t 'main.submissions_link'}", problem_submissions_path(problem_id), class: 'btn btn-xs btn-info'
26 +
@@ -20,7 +20,8
20 20 %strong View:
21 21 - if GraderConfiguration.show_grading_result
22 22 = link_to '[detailed result]', :action => 'result', :id => submission.id
23 - = link_to "#{t 'main.cmp_msg'}", {:action => 'compiler_msg', :id => submission.id}, {popup: true,class: 'btn btn-xs btn-info'}
23 + /= link_to "#{t 'main.cmp_msg'}", {:action => 'compiler_msg', :id => submission.id}, {popup: true,class: 'btn btn-xs btn-info'}
24 + = link_to "#{t 'main.cmp_msg'}", compiler_msg_submission_path(submission.id), {popup: true,remote: true,class: 'btn btn-xs btn-info'}
24 25 = link_to "#{t 'main.src_link'}",{:action => 'source', :id => submission.id}, class: 'btn btn-xs btn-info'
25 26 = link_to "#{t 'main.submissions_link'}", problem_submissions_path(problem_id), class: 'btn btn-xs btn-info'
26 27
@@ -28,10 +28,11
28 28 .panel.panel-info
29 29 .panel-heading
30 30 Latest Submission Status
31 + = link_to "Refresh",get_latest_submission_status_submissions_path(@submission.user,@problem), class: "btn btn-default btn-sm", remote: true
31 32 .panel-body
32 33 - if @submission
33 34 = render :partial => 'submission_short',
34 - :locals => {:submission => @submission, :problem_name => @problem.name }
35 + :locals => {submission: @submission, problem_name: @problem.name, problem_id: @problem.id }
35 36 .row
36 37 .col-md-12
37 38 %h2 Console
@@ -85,6 +85,12
85 85 %td
86 86 %button.btn.btn-info.btn-xs{type: 'button', data: {toggle: 'modal', target: '#compiler'}}
87 87 view
88 + - if session[:admin]
89 + %tr
90 + %td.text-right
91 + %strong IP
92 + %td #{@submission.ip_address}
93 +
88 94 .modal.fade#compiler{tabindex: -1,role: 'dialog'}
89 95 .modal-dialog.modal-lg{role:'document'}
90 96 .modal-content
@@ -93,11 +99,6
93 99 %span{aria: {hidden: 'true'}, data: {dismiss: 'modal'}} &times;
94 100 %h4 Compiler message
95 101 .modal-body
96 - %pre= @submission.compiler_message
102 + %pre#compiler_msg= @submission.compiler_message
97 103 .modal-footer
98 104 %button.btn.btn-default{type: 'button', data: {dismiss: 'modal'}} Close
99 - - if session[:admin]
100 - %tr
101 - %td.text-right
102 - %strong IP
103 - %td #{@submission.ip_address}
@@ -37,6 +37,10
37 37 end
38 38
39 39 resources :submissions do
40 + member do
41 + get 'download'
42 + get 'compiler_msg'
43 + end
40 44 collection do
41 45 get 'prob/:problem_id', to: 'submissions#index', as: 'problem'
42 46 get 'direct_edit_problem/:problem_id', to: 'submissions#direct_edit_problem', as: 'direct_edit_problem'
@@ -9,112 +9,112
9 9 # from scratch. The latter is a flawed and unsustainable approach (the more migrations
10 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 that you check this file into your version control system.
13 13
14 - ActiveRecord::Schema.define(:version => 20161031063337) do
14 + ActiveRecord::Schema.define(version: 20161031063337) do
15 15
16 - create_table "announcements", :force => true do |t|
16 + create_table "announcements", force: :cascade do |t|
17 17 t.string "author"
18 18 t.text "body"
19 19 t.boolean "published"
20 - t.datetime "created_at", :null => false
21 - t.datetime "updated_at", :null => false
22 - t.boolean "frontpage", :default => false
23 - t.boolean "contest_only", :default => false
20 + t.datetime "created_at", null: false
21 + t.datetime "updated_at", null: false
22 + t.boolean "frontpage", default: false
23 + t.boolean "contest_only", default: false
24 24 t.string "title"
25 25 t.string "notes"
26 26 end
27 27
28 - create_table "contests", :force => true do |t|
28 + create_table "contests", force: :cascade do |t|
29 29 t.string "title"
30 30 t.boolean "enabled"
31 - t.datetime "created_at", :null => false
32 - t.datetime "updated_at", :null => false
31 + t.datetime "created_at", null: false
32 + t.datetime "updated_at", null: false
33 33 t.string "name"
34 34 end
35 35
36 - create_table "contests_problems", :id => false, :force => true do |t|
36 + create_table "contests_problems", id: false, force: :cascade do |t|
37 37 t.integer "contest_id"
38 38 t.integer "problem_id"
39 39 end
40 40
41 - create_table "contests_users", :id => false, :force => true do |t|
41 + create_table "contests_users", id: false, force: :cascade do |t|
42 42 t.integer "contest_id"
43 43 t.integer "user_id"
44 44 end
45 45
46 - create_table "countries", :force => true do |t|
46 + create_table "countries", force: :cascade do |t|
47 47 t.string "name"
48 - t.datetime "created_at", :null => false
49 - t.datetime "updated_at", :null => false
48 + t.datetime "created_at", null: false
49 + t.datetime "updated_at", null: false
50 50 end
51 51
52 - create_table "descriptions", :force => true do |t|
52 + create_table "descriptions", force: :cascade do |t|
53 53 t.text "body"
54 54 t.boolean "markdowned"
55 - t.datetime "created_at", :null => false
56 - t.datetime "updated_at", :null => false
55 + t.datetime "created_at", null: false
56 + t.datetime "updated_at", null: false
57 57 end
58 58
59 - create_table "grader_configurations", :force => true do |t|
59 + create_table "grader_configurations", force: :cascade do |t|
60 60 t.string "key"
61 61 t.string "value_type"
62 62 t.string "value"
63 - t.datetime "created_at", :null => false
64 - t.datetime "updated_at", :null => false
63 + t.datetime "created_at", null: false
64 + t.datetime "updated_at", null: false
65 65 t.text "description"
66 66 end
67 67
68 - create_table "grader_processes", :force => true do |t|
68 + create_table "grader_processes", force: :cascade do |t|
69 69 t.string "host"
70 70 t.integer "pid"
71 71 t.string "mode"
72 72 t.boolean "active"
73 - t.datetime "created_at", :null => false
74 - t.datetime "updated_at", :null => false
73 + t.datetime "created_at", null: false
74 + t.datetime "updated_at", null: false
75 75 t.integer "task_id"
76 76 t.string "task_type"
77 77 t.boolean "terminated"
78 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 "heart_beats", :force => true do |t|
82 + create_table "heart_beats", force: :cascade do |t|
83 83 t.integer "user_id"
84 84 t.string "ip_address"
85 - t.datetime "created_at", :null => false
86 - t.datetime "updated_at", :null => false
85 + t.datetime "created_at", null: false
86 + t.datetime "updated_at", null: false
87 87 t.string "status"
88 88 end
89 89
90 - add_index "heart_beats", ["updated_at"], :name => "index_heart_beats_on_updated_at"
90 + add_index "heart_beats", ["updated_at"], name: "index_heart_beats_on_updated_at"
91 91
92 - create_table "languages", :force => true do |t|
93 - t.string "name", :limit => 10
92 + create_table "languages", force: :cascade do |t|
93 + t.string "name", limit: 10
94 94 t.string "pretty_name"
95 - t.string "ext", :limit => 10
95 + t.string "ext", limit: 10
96 96 t.string "common_ext"
97 97 end
98 98
99 - create_table "logins", :force => true do |t|
99 + create_table "logins", force: :cascade do |t|
100 100 t.integer "user_id"
101 101 t.string "ip_address"
102 - t.datetime "created_at", :null => false
103 - t.datetime "updated_at", :null => false
102 + t.datetime "created_at", null: false
103 + t.datetime "updated_at", null: false
104 104 end
105 105
106 - create_table "messages", :force => true do |t|
106 + create_table "messages", force: :cascade do |t|
107 107 t.integer "sender_id"
108 108 t.integer "receiver_id"
109 109 t.integer "replying_message_id"
110 110 t.text "body"
111 111 t.boolean "replied"
112 - t.datetime "created_at", :null => false
113 - t.datetime "updated_at", :null => false
112 + t.datetime "created_at", null: false
113 + t.datetime "updated_at", null: false
114 114 end
115 115
116 - create_table "problems", :force => true do |t|
117 - t.string "name", :limit => 30
116 + create_table "problems", force: :cascade do |t|
117 + t.string "name", limit: 30
118 118 t.string "full_name"
119 119 t.integer "full_score"
120 120 t.date "date_added"
@@ -126,57 +126,57
126 126 t.string "description_filename"
127 127 end
128 128
129 - create_table "rights", :force => true do |t|
129 + create_table "rights", force: :cascade do |t|
130 130 t.string "name"
131 131 t.string "controller"
132 132 t.string "action"
133 133 end
134 134
135 - create_table "rights_roles", :id => false, :force => true do |t|
135 + create_table "rights_roles", id: false, force: :cascade do |t|
136 136 t.integer "right_id"
137 137 t.integer "role_id"
138 138 end
139 139
140 - add_index "rights_roles", ["role_id"], :name => "index_rights_roles_on_role_id"
140 + add_index "rights_roles", ["role_id"], name: "index_rights_roles_on_role_id"
141 141
142 - create_table "roles", :force => true do |t|
142 + create_table "roles", force: :cascade do |t|
143 143 t.string "name"
144 144 end
145 145
146 - create_table "roles_users", :id => false, :force => true do |t|
146 + create_table "roles_users", id: false, force: :cascade do |t|
147 147 t.integer "role_id"
148 148 t.integer "user_id"
149 149 end
150 150
151 - add_index "roles_users", ["user_id"], :name => "index_roles_users_on_user_id"
151 + add_index "roles_users", ["user_id"], name: "index_roles_users_on_user_id"
152 152
153 - create_table "sessions", :force => true do |t|
153 + create_table "sessions", force: :cascade do |t|
154 154 t.string "session_id"
155 155 t.text "data"
156 156 t.datetime "updated_at"
157 157 end
158 158
159 - add_index "sessions", ["session_id"], :name => "index_sessions_on_session_id"
160 - add_index "sessions", ["updated_at"], :name => "index_sessions_on_updated_at"
159 + add_index "sessions", ["session_id"], name: "index_sessions_on_session_id"
160 + add_index "sessions", ["updated_at"], name: "index_sessions_on_updated_at"
161 161
162 - create_table "sites", :force => true do |t|
162 + create_table "sites", force: :cascade do |t|
163 163 t.string "name"
164 164 t.boolean "started"
165 165 t.datetime "start_time"
166 - t.datetime "created_at", :null => false
167 - t.datetime "updated_at", :null => false
166 + t.datetime "created_at", null: false
167 + t.datetime "updated_at", null: false
168 168 t.integer "country_id"
169 169 t.string "password"
170 170 end
171 171
172 - create_table "submission_view_logs", :force => true do |t|
172 + create_table "submission_view_logs", force: :cascade do |t|
173 173 t.integer "user_id"
174 174 t.integer "submission_id"
175 - t.datetime "created_at", :null => false
176 - t.datetime "updated_at", :null => false
175 + t.datetime "created_at", null: false
176 + t.datetime "updated_at", null: false
177 177 end
178 178
179 - create_table "submissions", :force => true do |t|
179 + create_table "submissions", force: :cascade do |t|
180 180 t.integer "user_id"
181 181 t.integer "problem_id"
182 182 t.integer "language_id"
@@ -196,25 +196,25
196 196 t.string "ip_address"
197 197 end
198 198
199 - add_index "submissions", ["user_id", "problem_id", "number"], :name => "index_submissions_on_user_id_and_problem_id_and_number", :unique => true
200 - add_index "submissions", ["user_id", "problem_id"], :name => "index_submissions_on_user_id_and_problem_id"
199 + add_index "submissions", ["user_id", "problem_id", "number"], name: "index_submissions_on_user_id_and_problem_id_and_number", unique: true
200 + add_index "submissions", ["user_id", "problem_id"], name: "index_submissions_on_user_id_and_problem_id"
201 201
202 - create_table "tasks", :force => true do |t|
202 + create_table "tasks", force: :cascade do |t|
203 203 t.integer "submission_id"
204 204 t.datetime "created_at"
205 205 t.integer "status"
206 206 t.datetime "updated_at"
207 207 end
208 208
209 - create_table "test_pairs", :force => true do |t|
209 + create_table "test_pairs", force: :cascade do |t|
210 210 t.integer "problem_id"
211 - t.text "input", :limit => 16777215
212 - t.text "solution", :limit => 16777215
213 - t.datetime "created_at", :null => false
214 - t.datetime "updated_at", :null => false
211 + t.text "input", limit: 16777215
212 + t.text "solution", limit: 16777215
213 + t.datetime "created_at", null: false
214 + t.datetime "updated_at", null: false
215 215 end
216 216
217 - create_table "test_requests", :force => true do |t|
217 + create_table "test_requests", force: :cascade do |t|
218 218 t.integer "user_id"
219 219 t.integer "problem_id"
220 220 t.integer "submission_id"
@@ -222,59 +222,59
222 222 t.string "output_file_name"
223 223 t.string "running_stat"
224 224 t.integer "status"
225 - t.datetime "updated_at", :null => false
225 + t.datetime "updated_at", null: false
226 226 t.datetime "submitted_at"
227 227 t.datetime "compiled_at"
228 228 t.text "compiler_message"
229 229 t.datetime "graded_at"
230 230 t.string "grader_comment"
231 - t.datetime "created_at", :null => false
231 + t.datetime "created_at", null: false
232 232 t.float "running_time"
233 233 t.string "exit_status"
234 234 t.integer "memory_usage"
235 235 end
236 236
237 - add_index "test_requests", ["user_id", "problem_id"], :name => "index_test_requests_on_user_id_and_problem_id"
237 + add_index "test_requests", ["user_id", "problem_id"], name: "index_test_requests_on_user_id_and_problem_id"
238 238
239 - create_table "testcases", :force => true do |t|
239 + create_table "testcases", force: :cascade do |t|
240 240 t.integer "problem_id"
241 241 t.integer "num"
242 242 t.integer "group"
243 243 t.integer "score"
244 244 t.text "input"
245 245 t.text "sol"
246 - t.datetime "created_at", :null => false
247 - t.datetime "updated_at", :null => false
246 + t.datetime "created_at", null: false
247 + t.datetime "updated_at", null: false
248 248 end
249 249
250 - add_index "testcases", ["problem_id"], :name => "index_testcases_on_problem_id"
250 + add_index "testcases", ["problem_id"], name: "index_testcases_on_problem_id"
251 251
252 - create_table "user_contest_stats", :force => true do |t|
252 + create_table "user_contest_stats", force: :cascade do |t|
253 253 t.integer "user_id"
254 254 t.datetime "started_at"
255 - t.datetime "created_at", :null => false
256 - t.datetime "updated_at", :null => false
255 + t.datetime "created_at", null: false
256 + t.datetime "updated_at", null: false
257 257 t.boolean "forced_logout"
258 258 end
259 259
260 - create_table "users", :force => true do |t|
261 - t.string "login", :limit => 50
260 + create_table "users", force: :cascade do |t|
261 + t.string "login", limit: 50
262 262 t.string "full_name"
263 263 t.string "hashed_password"
264 - t.string "salt", :limit => 5
264 + t.string "salt", limit: 5
265 265 t.string "alias"
266 266 t.string "email"
267 267 t.integer "site_id"
268 268 t.integer "country_id"
269 - t.boolean "activated", :default => false
269 + t.boolean "activated", default: false
270 270 t.datetime "created_at"
271 271 t.datetime "updated_at"
272 - t.boolean "enabled", :default => true
272 + t.boolean "enabled", default: true
273 273 t.string "remark"
274 274 t.string "last_ip"
275 275 t.string "section"
276 276 end
277 277
278 - add_index "users", ["login"], :name => "index_users_on_login", :unique => true
278 + add_index "users", ["login"], name: "index_users_on_login", unique: true
279 279
280 280 end
You need to be logged in to leave comments. Login now