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

r645:a2d233431d60 - - 8 files changed: 64 inserted, 32 deleted

@@ -0,0 +1,2
1 + :plain
2 + $("body").prepend("<div class=\"alert alert-info\"> Submission #{@submission.id}'s task status has been chaned to \"#{@task.status_str}\" </div>")
@@ -0,0 +1,5
1 + class AddIndexToTask < ActiveRecord::Migration
2 + def change
3 + add_index :tasks, :submission_id
4 + end
5 + end
@@ -1,6 +1,7
1 class SubmissionsController < ApplicationController
1 class SubmissionsController < ApplicationController
2 - before_filter :authenticate
2 + before_action :authenticate
3 - before_filter :submission_authorization, only: [:show, :direct_edit_submission, :download, :edit]
3 + before_action :submission_authorization, only: [:show, :direct_edit_submission, :download, :edit]
4 + before_action :admin_authorization, only: [:rejudge]
4
5
5 # GET /submissions
6 # GET /submissions
6 # GET /submissions.json
7 # GET /submissions.json
@@ -31,6 +32,8
31 #log the viewing
32 #log the viewing
32 user = User.find(session[:user_id])
33 user = User.find(session[:user_id])
33 SubmissionViewLog.create(user_id: session[:user_id],submission_id: @submission.id) unless user.admin?
34 SubmissionViewLog.create(user_id: session[:user_id],submission_id: @submission.id) unless user.admin?
35 +
36 + @task = @submission.task
34 end
37 end
35
38
36 def download
39 def download
@@ -72,6 +75,16
72 end
75 end
73 end
76 end
74
77
78 + # GET /submissions/:id/rejudge
79 + def rejudge
80 + @submission = Submission.find(params[:id])
81 + @task = @submission.task
82 + @task.status_inqueue! if @task
83 + respond_to do |format|
84 + format.js
85 + end
86 + end
87 +
75
88
76 protected
89 protected
77
90
@@ -209,7 +209,6
209 end
209 end
210
210
211 def flash_messages
211 def flash_messages
212 - puts "flahs size = #{flash.count}"
213 flash.each do |msg_type, message|
212 flash.each do |msg_type, message|
214 concat(content_tag(:div, message, class: "alert #{bootstrap_class_for(msg_type)} fade in") do
213 concat(content_tag(:div, message, class: "alert #{bootstrap_class_for(msg_type)} fade in") do
215 concat content_tag(:button, 'x', class: "close", data: { dismiss: 'alert' })
214 concat content_tag(:button, 'x', class: "close", data: { dismiss: 'alert' })
@@ -13,6 +13,8
13 validate :must_have_valid_problem
13 validate :must_have_valid_problem
14 validate :must_specify_language
14 validate :must_specify_language
15
15
16 + has_one :task
17 +
16 before_save :assign_latest_number_if_new_recond
18 before_save :assign_latest_number_if_new_recond
17
19
18 def self.find_last_by_user_and_problem(user_id, problem_id)
20 def self.find_last_by_user_and_problem(user_id, problem_id)
@@ -90,6 +90,14
90 %td.text-right
90 %td.text-right
91 %strong IP
91 %strong IP
92 %td #{@submission.ip_address}
92 %td #{@submission.ip_address}
93 + %tr
94 + %td.text-right
95 + %strong Grading Task Status
96 + %td
97 + = @task.status_str if @task
98 + - if session[:admin]
99 + = link_to "rejudge", rejudge_submission_path, data: {remote: true}, class: 'btn btn-info btn-xs'
100 +
93
101
94 .modal.fade#compiler{tabindex: -1,role: 'dialog'}
102 .modal.fade#compiler{tabindex: -1,role: 'dialog'}
95 .modal-dialog.modal-lg{role:'document'}
103 .modal-dialog.modal-lg{role:'document'}
@@ -55,6 +55,7
55 member do
55 member do
56 get 'download'
56 get 'download'
57 get 'compiler_msg'
57 get 'compiler_msg'
58 + get 'rejudge'
58 end
59 end
59 collection do
60 collection do
60 get 'prob/:problem_id', to: 'submissions#index', as: 'problem'
61 get 'prob/:problem_id', to: 'submissions#index', as: 'problem'
@@ -11,16 +11,16
11 #
11 #
12 # It's strongly recommended that you 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: 20170124024527) do
14 + ActiveRecord::Schema.define(version: 20170310110146) do
15
15
16 create_table "announcements", force: :cascade do |t|
16 create_table "announcements", force: :cascade do |t|
17 t.string "author", limit: 255
17 t.string "author", limit: 255
18 - t.text "body", limit: 16777215
18 + t.text "body", limit: 65535
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", limit: 255
24 t.string "title", limit: 255
25 t.string "notes", limit: 255
25 t.string "notes", limit: 255
26 end
26 end
@@ -50,19 +50,19
50 end
50 end
51
51
52 create_table "descriptions", force: :cascade do |t|
52 create_table "descriptions", force: :cascade do |t|
53 - t.text "body", limit: 16777215
53 + t.text "body", limit: 65535
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: :cascade do |t|
59 create_table "grader_configurations", force: :cascade do |t|
60 t.string "key", limit: 255
60 t.string "key", limit: 255
61 t.string "value_type", limit: 255
61 t.string "value_type", limit: 255
62 t.string "value", limit: 255
62 t.string "value", limit: 255
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: 65535
66 end
66 end
67
67
68 create_table "grader_processes", force: :cascade do |t|
68 create_table "grader_processes", force: :cascade do |t|
@@ -107,10 +107,10
107 t.integer "sender_id", limit: 4
107 t.integer "sender_id", limit: 4
108 t.integer "receiver_id", limit: 4
108 t.integer "receiver_id", limit: 4
109 t.integer "replying_message_id", limit: 4
109 t.integer "replying_message_id", limit: 4
110 - t.text "body", limit: 16777215
110 + t.text "body", limit: 65535
111 t.boolean "replied"
111 t.boolean "replied"
112 - t.datetime "created_at", null: false
112 + t.datetime "created_at", null: false
113 - t.datetime "updated_at", null: false
113 + t.datetime "updated_at", null: false
114 end
114 end
115
115
116 create_table "problems", force: :cascade do |t|
116 create_table "problems", force: :cascade do |t|
@@ -153,7 +153,7
153
153
154 create_table "sessions", force: :cascade do |t|
154 create_table "sessions", force: :cascade do |t|
155 t.string "session_id", limit: 255
155 t.string "session_id", limit: 255
156 - t.text "data", limit: 16777215
156 + t.text "data", limit: 65535
157 t.datetime "updated_at"
157 t.datetime "updated_at"
158 end
158 end
159
159
@@ -181,14 +181,14
181 t.integer "user_id", limit: 4
181 t.integer "user_id", limit: 4
182 t.integer "problem_id", limit: 4
182 t.integer "problem_id", limit: 4
183 t.integer "language_id", limit: 4
183 t.integer "language_id", limit: 4
184 - t.text "source", limit: 16777215
184 + t.text "source", limit: 65535
185 t.binary "binary", limit: 65535
185 t.binary "binary", limit: 65535
186 t.datetime "submitted_at"
186 t.datetime "submitted_at"
187 t.datetime "compiled_at"
187 t.datetime "compiled_at"
188 - t.text "compiler_message", limit: 16777215
188 + t.text "compiler_message", limit: 65535
189 t.datetime "graded_at"
189 t.datetime "graded_at"
190 t.integer "points", limit: 4
190 t.integer "points", limit: 4
191 - t.text "grader_comment", limit: 16777215
191 + t.text "grader_comment", limit: 65535
192 t.integer "number", limit: 4
192 t.integer "number", limit: 4
193 t.string "source_filename", limit: 255
193 t.string "source_filename", limit: 255
194 t.float "max_runtime", limit: 24
194 t.float "max_runtime", limit: 24
@@ -207,12 +207,14
207 t.datetime "updated_at"
207 t.datetime "updated_at"
208 end
208 end
209
209
210 + add_index "tasks", ["submission_id"], name: "index_tasks_on_submission_id", using: :btree
211 +
210 create_table "test_pairs", force: :cascade do |t|
212 create_table "test_pairs", force: :cascade do |t|
211 t.integer "problem_id", limit: 4
213 t.integer "problem_id", limit: 4
212 - t.text "input", limit: 4294967295
214 + t.text "input", limit: 16777215
213 - t.text "solution", limit: 4294967295
215 + t.text "solution", limit: 16777215
214 - t.datetime "created_at", null: false
216 + t.datetime "created_at", null: false
215 - t.datetime "updated_at", null: false
217 + t.datetime "updated_at", null: false
216 end
218 end
217
219
218 create_table "test_requests", force: :cascade do |t|
220 create_table "test_requests", force: :cascade do |t|
@@ -223,13 +225,13
223 t.string "output_file_name", limit: 255
225 t.string "output_file_name", limit: 255
224 t.string "running_stat", limit: 255
226 t.string "running_stat", limit: 255
225 t.integer "status", limit: 4
227 t.integer "status", limit: 4
226 - t.datetime "updated_at", null: false
228 + t.datetime "updated_at", null: false
227 t.datetime "submitted_at"
229 t.datetime "submitted_at"
228 t.datetime "compiled_at"
230 t.datetime "compiled_at"
229 - t.text "compiler_message", limit: 16777215
231 + t.text "compiler_message", limit: 65535
230 t.datetime "graded_at"
232 t.datetime "graded_at"
231 t.string "grader_comment", limit: 255
233 t.string "grader_comment", limit: 255
232 - t.datetime "created_at", null: false
234 + t.datetime "created_at", null: false
233 t.float "running_time", limit: 24
235 t.float "running_time", limit: 24
234 t.string "exit_status", limit: 255
236 t.string "exit_status", limit: 255
235 t.integer "memory_usage", limit: 4
237 t.integer "memory_usage", limit: 4
@@ -244,8 +246,8
244 t.integer "score", limit: 4
246 t.integer "score", limit: 4
245 t.text "input", limit: 4294967295
247 t.text "input", limit: 4294967295
246 t.text "sol", limit: 4294967295
248 t.text "sol", limit: 4294967295
247 - t.datetime "created_at", null: false
249 + t.datetime "created_at"
248 - t.datetime "updated_at", null: false
250 + t.datetime "updated_at"
249 end
251 end
250
252
251 add_index "testcases", ["problem_id"], name: "index_testcases_on_problem_id", using: :btree
253 add_index "testcases", ["problem_id"], name: "index_testcases_on_problem_id", using: :btree
@@ -270,10 +272,10
270 t.boolean "activated", default: false
272 t.boolean "activated", default: false
271 t.datetime "created_at"
273 t.datetime "created_at"
272 t.datetime "updated_at"
274 t.datetime "updated_at"
273 - t.string "section", limit: 255
274 t.boolean "enabled", default: true
275 t.boolean "enabled", default: true
275 t.string "remark", limit: 255
276 t.string "remark", limit: 255
276 t.string "last_ip", limit: 255
277 t.string "last_ip", limit: 255
278 + t.string "section", limit: 255
277 end
279 end
278
280
279 add_index "users", ["login"], name: "index_users_on_login", unique: true, using: :btree
281 add_index "users", ["login"], name: "index_users_on_login", unique: true, using: :btree
You need to be logged in to leave comments. Login now