diff --git a/app/controllers/submissions_controller.rb b/app/controllers/submissions_controller.rb
--- a/app/controllers/submissions_controller.rb
+++ b/app/controllers/submissions_controller.rb
@@ -1,6 +1,7 @@
class SubmissionsController < ApplicationController
- before_filter :authenticate
- before_filter :submission_authorization, only: [:show, :direct_edit_submission, :download, :edit]
+ before_action :authenticate
+ before_action :submission_authorization, only: [:show, :direct_edit_submission, :download, :edit]
+ before_action :admin_authorization, only: [:rejudge]
# GET /submissions
# GET /submissions.json
@@ -31,6 +32,8 @@
#log the viewing
user = User.find(session[:user_id])
SubmissionViewLog.create(user_id: session[:user_id],submission_id: @submission.id) unless user.admin?
+
+ @task = @submission.task
end
def download
@@ -72,6 +75,16 @@
end
end
+ # GET /submissions/:id/rejudge
+ def rejudge
+ @submission = Submission.find(params[:id])
+ @task = @submission.task
+ @task.status_inqueue! if @task
+ respond_to do |format|
+ format.js
+ end
+ end
+
protected
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -209,7 +209,6 @@
end
def flash_messages
- puts "flahs size = #{flash.count}"
flash.each do |msg_type, message|
concat(content_tag(:div, message, class: "alert #{bootstrap_class_for(msg_type)} fade in") do
concat content_tag(:button, 'x', class: "close", data: { dismiss: 'alert' })
diff --git a/app/models/submission.rb b/app/models/submission.rb
--- a/app/models/submission.rb
+++ b/app/models/submission.rb
@@ -13,6 +13,8 @@
validate :must_have_valid_problem
validate :must_specify_language
+ has_one :task
+
before_save :assign_latest_number_if_new_recond
def self.find_last_by_user_and_problem(user_id, problem_id)
diff --git a/app/views/submissions/rejudge.js.haml b/app/views/submissions/rejudge.js.haml
new file mode 100644
--- /dev/null
+++ b/app/views/submissions/rejudge.js.haml
@@ -0,0 +1,2 @@
+:plain
+ $("body").prepend("
Submission #{@submission.id}'s task status has been chaned to \"#{@task.status_str}\"
")
diff --git a/app/views/submissions/show.html.haml b/app/views/submissions/show.html.haml
--- a/app/views/submissions/show.html.haml
+++ b/app/views/submissions/show.html.haml
@@ -90,6 +90,14 @@
%td.text-right
%strong IP
%td #{@submission.ip_address}
+ %tr
+ %td.text-right
+ %strong Grading Task Status
+ %td
+ = @task.status_str if @task
+ - if session[:admin]
+ = link_to "rejudge", rejudge_submission_path, data: {remote: true}, class: 'btn btn-info btn-xs'
+
.modal.fade#compiler{tabindex: -1,role: 'dialog'}
.modal-dialog.modal-lg{role:'document'}
diff --git a/config/routes.rb b/config/routes.rb
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -55,6 +55,7 @@
member do
get 'download'
get 'compiler_msg'
+ get 'rejudge'
end
collection do
get 'prob/:problem_id', to: 'submissions#index', as: 'problem'
diff --git a/db/migrate/20170310110146_add_index_to_task.rb b/db/migrate/20170310110146_add_index_to_task.rb
new file mode 100644
--- /dev/null
+++ b/db/migrate/20170310110146_add_index_to_task.rb
@@ -0,0 +1,5 @@
+class AddIndexToTask < ActiveRecord::Migration
+ def change
+ add_index :tasks, :submission_id
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -11,16 +11,16 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema.define(version: 20170124024527) do
+ActiveRecord::Schema.define(version: 20170310110146) do
create_table "announcements", force: :cascade do |t|
t.string "author", limit: 255
- t.text "body", limit: 16777215
+ t.text "body", limit: 65535
t.boolean "published"
- t.datetime "created_at", null: false
- t.datetime "updated_at", null: false
- t.boolean "frontpage", default: false
- t.boolean "contest_only", default: false
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ t.boolean "frontpage", default: false
+ t.boolean "contest_only", default: false
t.string "title", limit: 255
t.string "notes", limit: 255
end
@@ -50,19 +50,19 @@
end
create_table "descriptions", force: :cascade do |t|
- t.text "body", limit: 16777215
+ t.text "body", limit: 65535
t.boolean "markdowned"
- t.datetime "created_at", null: false
- t.datetime "updated_at", null: false
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
end
create_table "grader_configurations", force: :cascade do |t|
t.string "key", limit: 255
t.string "value_type", limit: 255
t.string "value", limit: 255
- t.datetime "created_at", null: false
- t.datetime "updated_at", null: false
- t.text "description", limit: 16777215
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ t.text "description", limit: 65535
end
create_table "grader_processes", force: :cascade do |t|
@@ -107,10 +107,10 @@
t.integer "sender_id", limit: 4
t.integer "receiver_id", limit: 4
t.integer "replying_message_id", limit: 4
- t.text "body", limit: 16777215
+ t.text "body", limit: 65535
t.boolean "replied"
- t.datetime "created_at", null: false
- t.datetime "updated_at", null: false
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
end
create_table "problems", force: :cascade do |t|
@@ -153,7 +153,7 @@
create_table "sessions", force: :cascade do |t|
t.string "session_id", limit: 255
- t.text "data", limit: 16777215
+ t.text "data", limit: 65535
t.datetime "updated_at"
end
@@ -181,14 +181,14 @@
t.integer "user_id", limit: 4
t.integer "problem_id", limit: 4
t.integer "language_id", limit: 4
- t.text "source", limit: 16777215
+ t.text "source", limit: 65535
t.binary "binary", limit: 65535
t.datetime "submitted_at"
t.datetime "compiled_at"
- t.text "compiler_message", limit: 16777215
+ t.text "compiler_message", limit: 65535
t.datetime "graded_at"
t.integer "points", limit: 4
- t.text "grader_comment", limit: 16777215
+ t.text "grader_comment", limit: 65535
t.integer "number", limit: 4
t.string "source_filename", limit: 255
t.float "max_runtime", limit: 24
@@ -207,12 +207,14 @@
t.datetime "updated_at"
end
+ add_index "tasks", ["submission_id"], name: "index_tasks_on_submission_id", using: :btree
+
create_table "test_pairs", force: :cascade do |t|
t.integer "problem_id", limit: 4
- t.text "input", limit: 4294967295
- t.text "solution", limit: 4294967295
- t.datetime "created_at", null: false
- t.datetime "updated_at", null: false
+ t.text "input", limit: 16777215
+ t.text "solution", limit: 16777215
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
end
create_table "test_requests", force: :cascade do |t|
@@ -223,13 +225,13 @@
t.string "output_file_name", limit: 255
t.string "running_stat", limit: 255
t.integer "status", limit: 4
- t.datetime "updated_at", null: false
+ t.datetime "updated_at", null: false
t.datetime "submitted_at"
t.datetime "compiled_at"
- t.text "compiler_message", limit: 16777215
+ t.text "compiler_message", limit: 65535
t.datetime "graded_at"
t.string "grader_comment", limit: 255
- t.datetime "created_at", null: false
+ t.datetime "created_at", null: false
t.float "running_time", limit: 24
t.string "exit_status", limit: 255
t.integer "memory_usage", limit: 4
@@ -244,8 +246,8 @@
t.integer "score", limit: 4
t.text "input", limit: 4294967295
t.text "sol", limit: 4294967295
- t.datetime "created_at", null: false
- t.datetime "updated_at", null: false
+ t.datetime "created_at"
+ t.datetime "updated_at"
end
add_index "testcases", ["problem_id"], name: "index_testcases_on_problem_id", using: :btree
@@ -270,10 +272,10 @@
t.boolean "activated", default: false
t.datetime "created_at"
t.datetime "updated_at"
- t.string "section", limit: 255
t.boolean "enabled", default: true
t.string "remark", limit: 255
t.string "last_ip", limit: 255
+ t.string "section", limit: 255
end
add_index "users", ["login"], name: "index_users_on_login", unique: true, using: :btree