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/controllers/report_controller.rb b/app/controllers/report_controller.rb
--- a/app/controllers/report_controller.rb
+++ b/app/controllers/report_controller.rb
@@ -16,12 +16,14 @@
date_and_time = '%Y-%m-%d %H:%M'
begin
- @since_time = DateTime.strptime(params[:since_datetime],date_and_time)
+ md = params[:since_datetime].match(/(\d+)-(\d+)-(\d+) (\d+):(\d+)/)
+ @since_time = Time.zone.local(md[1].to_i,md[2].to_i,md[3].to_i,md[4].to_i,md[5].to_i)
rescue
@since_time = DateTime.new(1000,1,1)
end
begin
- @until_time = DateTime.strptime(params[:until_datetime],date_and_time)
+ md = params[:until_datetime].match(/(\d+)-(\d+)-(\d+) (\d+):(\d+)/)
+ @until_time = Time.zone.local(md[1].to_i,md[2].to_i,md[3].to_i,md[4].to_i,md[5].to_i)
rescue
@until_time = DateTime.new(3000,1,1)
end
@@ -38,7 +40,11 @@
.minimum(:created_at),
max: Login.where("user_id = ? AND created_at >= ? AND created_at <= ?",
user.id,@since_time,@until_time)
- .maximum(:created_at)
+ .maximum(:created_at),
+ ip: Login.where("user_id = ? AND created_at >= ? AND created_at <= ?",
+ user.id,@since_time,@until_time)
+ .select(:ip_address).uniq
+
}
end
end
@@ -164,7 +170,7 @@
#sum into best
if @by_lang and @by_lang.first
- @best = @by_lang.first[1]
+ @best = @by_lang.first[1].clone
@by_lang.each do |lang,prop|
if @best[:runtime][:value] >= prop[:runtime][:value]
@best[:runtime] = prop[:runtime]
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
@@ -1,27 +1,61 @@
%style{type: "text/css"}
= @css_style
+:css
+ .field {
+ font-weight: bold;
+ text-align: right;
+ padding: 3px;
+ }
+
%h1= "Submission: #{@submission.id}"
-%p
- User:
- = "(#{@submission.user.login}) #{@submission.user.full_name}"
- %br/
- Problem:
- - if @submission.problem!=nil
- = "#{@submission.problem.full_name}"
- - else
- = "(n/a)"
- %br/
- = "Number: #{@submission.number}"
- %br/
- = "Submitted at: #{format_short_time(@submission.submitted_at)}"
- %br/
- = "Points : #{@submission.points}/#{@submission.problem.full_score}"
- %br/
- = "Comment : #{@submission.grader_comment}"
+
+%h2 Stat
-%b Source code (first 10kb)
+%table.info
+ %thead
+ %tr.info-head
+ %th Field
+ %th Value
+ %tbody
+ %tr{class: cycle('info-even','info-odd')}
+ %td.field User:
+ %td.value= "(#{@submission.user.login}) #{@submission.user.full_name}"
+ %tr{class: cycle('info-even','info-odd')}
+ %td.field Problem:
+ %td.value
+ - if @submission.problem!=nil
+ = "(#{@submission.problem.name}) #{@submission.problem.full_name}"
+ - else
+ = "(n/a)"
+ %tr{class: cycle('info-even','info-odd')}
+ %td.field Tries:
+ %td.value= @submission.number
+ %tr{class: cycle('info-even','info-odd')}
+ %td.field Submitted:
+ %td.value #{time_ago_in_words(@submission.submitted_at)} ago (at #{@submission.submitted_at.to_formatted_s(:long)})
+ %tr{class: cycle('info-even','info-odd')}
+ %td.field Graded:
+ %td.value #{time_ago_in_words(@submission.graded_at)} ago (at #{@submission.graded_at.to_formatted_s(:long)})
+ %tr{class: cycle('info-even','info-odd')}
+ %td.field Points:
+ %td.value #{@submission.points}/#{@submission.problem.full_score}
+ %tr{class: cycle('info-even','info-odd')}
+ %td.field Comment:
+ %td.value #{@submission.grader_comment}
+ %tr{class: cycle('info-even','info-odd')}
+ %td.field Runtime (s):
+ %td.value #{@submission.max_runtime}
+ %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;"}
=@formatted_code.html_safe
diff --git a/app/views/report/_task_hof.html.haml b/app/views/report/_task_hof.html.haml
--- a/app/views/report/_task_hof.html.haml
+++ b/app/views/report/_task_hof.html.haml
@@ -3,7 +3,7 @@
.hof_language { color: green; font-style: italic; }
.hof_value { color: deeppink;font-style: italic; }
-%h2 Overall
+%h2 Overall of #{Problem.find(params[:id]).full_name}
- if @best
%b Best Runtime:
@@ -17,7 +17,7 @@
%b Best Memory Usage:
by #{link_to @best[:memory][:user], controller:'users', action:'profile', id:@best[:memory][:user_id]}
using #{@best[:memory][:lang]}
- with #{@best[:memory][:value]} kbytes
+ with #{number_with_delimiter(@best[:memory][:value])} kbytes
at submission
= link_to("#" + @best[:memory][:sub_id].to_s, controller: 'graders' , action: 'submission', id:@best[:memory][:sub_id])
%br/
@@ -63,7 +63,7 @@
= "#{link_to("#" + value[:runtime][:sub_id].to_s, controller: 'graders' , action: 'submission', id: value[:runtime][:sub_id])} )".html_safe
%td
= link_to value[:memory][:user], controller: 'users', action: 'profile', id: value[:memory][:user_id]
- = "(#{value[:memory][:value]} @"
+ = "(#{number_with_delimiter(value[:memory][:value])} @"
= "#{link_to("#" + value[:memory][:sub_id].to_s, controller: 'graders' , action: 'submission', id: value[:memory][:sub_id])} )".html_safe
%td
= link_to value[:length][:user], controller: 'users', action: 'profile', id: value[:length][:user_id]
diff --git a/app/views/report/login_stat.html.haml b/app/views/report/login_stat.html.haml
--- a/app/views/report/login_stat.html.haml
+++ b/app/views/report/login_stat.html.haml
@@ -22,6 +22,7 @@
%th login count
%th earliest
%th latest
+ %th IP
%tbody
- @logins.each do |l|
%tr{class: cycle('info-even','info-odd')}
@@ -29,4 +30,7 @@
%td= l[:full_name]
%td= l[:count]
%td= l[:min] ? l[:min].in_time_zone.strftime('%Y-%m-%d %H:%M') : ''
- %td= l[:max] ? time_ago_in_words(l[:max].in_time_zone) + ' ago' : ''
+ %td= l[:max] ? "#{l[:max].in_time_zone.strftime('%Y-%m-%d %H:%M.%S')} (#{time_ago_in_words(l[:max].in_time_zone)} ago)" : ''
+ %td
+ - l[:ip].each do |ip|
+ #{ip.ip_address}
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
@@ -40,7 +42,9 @@
%td= s.problem.full_name
%td= s.language.pretty_name
%td.fix-width= s.grader_comment
- %td= s.points/s.problem.full_score * 100
+ %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