diff --git a/app/controllers/main_controller.rb b/app/controllers/main_controller.rb --- a/app/controllers/main_controller.rb +++ b/app/controllers/main_controller.rb @@ -67,6 +67,7 @@ @submission.source_filename = params['file'].original_filename end @submission.submitted_at = Time.new.gmtime + @submission.ip_address = request.remote_ip if GraderConfiguration.time_limit_mode? and user.contest_finished? @submission.errors.add_to_base "The contest is over." diff --git a/app/views/graders/submission.html.haml b/app/views/graders/submission.html.haml --- a/app/views/graders/submission.html.haml +++ b/app/views/graders/submission.html.haml @@ -50,6 +50,10 @@ %tr{class: cycle('info-even','info-odd')} %td.field Memory (kb): %td.value #{@submission.peak_memory} + - if session[:admin] + %tr{class: cycle('info-even','info-odd')} + %td.field IP: + %td.value #{@submission.ip_address} %h2 Source code //%div.highlight{:style => "border: 1px solid black;"} diff --git a/app/views/users/profile.html.haml b/app/views/users/profile.html.haml --- a/app/views/users/profile.html.haml +++ b/app/views/users/profile.html.haml @@ -31,6 +31,8 @@ %th Language %th Result %th Score + - if session[:admin] + %th IP %tbody - @submission.each do |s| - next unless s.problem @@ -41,6 +43,8 @@ %td= s.language.pretty_name %td.fix-width= s.grader_comment %td= (s.points*100)/s.problem.full_score + - if session[:admin] + %td= s.ip_address diff --git a/db/migrate/20140917150629_add_ip_to_submissions.rb b/db/migrate/20140917150629_add_ip_to_submissions.rb new file mode 100644 --- /dev/null +++ b/db/migrate/20140917150629_add_ip_to_submissions.rb @@ -0,0 +1,5 @@ +class AddIpToSubmissions < ActiveRecord::Migration + def change + add_column :submissions, :ip_address, :string + 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 to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20140826095949) do +ActiveRecord::Schema.define(:version => 20140917150629) do create_table "announcements", :force => true do |t| t.string "author" - t.text "body", :limit => 16777215 + t.text "body" 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" t.string "notes" end @@ -50,19 +50,19 @@ end create_table "descriptions", :force => true do |t| - t.text "body", :limit => 16777215 + t.text "body" 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 => true do |t| t.string "key" t.string "value_type" t.string "value" - 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" end create_table "grader_processes", :force => true do |t| @@ -97,10 +97,10 @@ t.integer "sender_id" t.integer "receiver_id" t.integer "replying_message_id" - t.text "body", :limit => 16777215 + t.text "body" 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 => true do |t| @@ -142,7 +142,7 @@ create_table "sessions", :force => true do |t| t.string "session_id" - t.text "data", :limit => 16777215 + t.text "data" t.datetime "updated_at" end @@ -163,16 +163,20 @@ t.integer "user_id" t.integer "problem_id" t.integer "language_id" - t.text "source", :limit => 16777215 + t.text "source" t.binary "binary" t.datetime "submitted_at" t.datetime "compiled_at" - t.text "compiler_message", :limit => 16777215 + t.text "compiler_message" t.datetime "graded_at" t.integer "points" - t.text "grader_comment", :limit => 16777215 + t.text "grader_comment" t.integer "number" t.string "source_filename" + t.float "max_runtime" + t.integer "peak_memory" + t.integer "effective_code_length" + t.string "ip_address" end add_index "submissions", ["user_id", "problem_id", "number"], :name => "index_submissions_on_user_id_and_problem_id_and_number", :unique => true @@ -187,10 +191,10 @@ create_table "test_pairs", :force => true do |t| t.integer "problem_id" - t.text "input", :limit => 2147483647 - t.text "solution", :limit => 2147483647 - 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 => true do |t| @@ -201,13 +205,13 @@ t.string "output_file_name" t.string "running_stat" t.integer "status" - 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" t.datetime "graded_at" t.string "grader_comment" - t.datetime "created_at", :null => false + t.datetime "created_at", :null => false t.float "running_time" t.string "exit_status" t.integer "memory_usage" @@ -235,6 +239,7 @@ t.boolean "activated", :default => false t.datetime "created_at" t.datetime "updated_at" + t.string "section" end add_index "users", ["login"], :name => "index_users_on_login", :unique => true