diff --git a/app/controllers/user_admin_controller.rb b/app/controllers/user_admin_controller.rb
--- a/app/controllers/user_admin_controller.rb
+++ b/app/controllers/user_admin_controller.rb
@@ -129,12 +129,33 @@
ustat = Array.new
ustat[0] = u
@problems.each do |p|
- sub = Submission.find_last_by_user_and_problem(u.id,p.id)
- if (sub!=nil) and (sub.points!=nil)
- ustat << [(sub.points.to_f*100/p.full_score).round, (sub.points>=p.full_score)]
- else
- ustat << [0,false]
- end
+ sub = Submission.find_last_by_user_and_problem(u.id,p.id)
+ if (sub!=nil) and (sub.points!=nil)
+ ustat << [(sub.points.to_f*100/p.full_score).round, (sub.points>=p.full_score)]
+ else
+ ustat << [0,false]
+ end
+ end
+ @scorearray << ustat
+ end
+ end
+
+ def user_stat_max
+ @problems = Problem.find_available_problems
+ @users = User.find(:all, :include => [:contests, :contest_stat])
+ @scorearray = Array.new
+ #set up range from param
+ since_id = params.fetch(:since_id, 0).to_i
+ until_id = params.fetch(:until_id, 0).to_i
+ @users.each do |u|
+ ustat = Array.new
+ ustat[0] = u
+ @problems.each do |p|
+ max_points = 0
+ Submission.find_in_range_by_user_and_problem(u.id,p.id,since_id,until_id).each do |sub|
+ max_points = sub.points if sub and sub.points and (sub.points > max_points)
+ end
+ ustat << [(max_points.to_f*100/p.full_score).round, (max_points>=p.full_score)]
end
@scorearray << ustat
end
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -129,7 +129,7 @@
:login => user.login,
:password => user.password,
:activation_url => activation_url,
- :admin_email => admin_email
+ :admin_email => GraderConfiguration['system.admin_email']
})
logger.info mail_body
@@ -145,7 +145,7 @@
:contest_name => contest_name,
:login => user.login,
:password => user.password,
- :admin_email => admin_email
+ :admin_email => GraderConfiguration['system.admin_email']
})
logger.info mail_body
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
@@ -113,7 +113,7 @@
#{user.full_name}
-#{t 'title_bar.current_time'} #{format_short_time(Time.new)}
+#{t 'title_bar.current_time'} #{format_short_time(Time.zone.now)}
#{time_left}
|
diff --git a/app/models/submission.rb b/app/models/submission.rb
--- a/app/models/submission.rb
+++ b/app/models/submission.rb
@@ -34,6 +34,13 @@
"ORDER BY user_id")
end
+ def self.find_in_range_by_user_and_problem(user_id, problem_id,since_id,until_id)
+ records = Submission.where(problem_id: problem_id,user_id: user_id)
+ records = records.where('id >= ?',since_id) if since_id > 0
+ records = records.where('id <= ?',until_id) if until_id > 0
+ records.all
+ end
+
def self.find_last_for_all_available_problems(user_id)
submissions = Array.new
problems = Problem.find_available_problems
diff --git a/app/views/user_admin/_submission_range.html.haml b/app/views/user_admin/_submission_range.html.haml
new file mode 100644
--- /dev/null
+++ b/app/views/user_admin/_submission_range.html.haml
@@ -0,0 +1,18 @@
+
+
+= form_tag({action: :user_stat_max }) do
+ .submitbox
+ %table
+ %tr
+ %td{colspan: 6, style: 'font-weight: bold'} Query maximum score in submission range
+ %tr
+ %td{style: 'width: 120px; font-weight: bold'} Submission ID:
+ %td{align: 'right'} From:
+ %td= text_field_tag 'since_id', params[:since_id], style: 'width:40px'
+ %td To:
+ %td= text_field_tag 'until_id', params[:until_id], style: 'width:40px'
+ %td= submit_tag 'query'
+ %tr
+ %td
+ %td{colspan: 5} Leave blank for uncondition
+
diff --git a/app/views/user_admin/user_stat.html.erb b/app/views/user_admin/user_stat.html.erb
--- a/app/views/user_admin/user_stat.html.erb
+++ b/app/views/user_admin/user_stat.html.erb
@@ -1,4 +1,9 @@
User grading results
+Show scores from latest submission
+
+<%= render 'submission_range' %>
+
+Latest scores
diff --git a/app/views/user_admin/user_stat_max.html.haml b/app/views/user_admin/user_stat_max.html.haml
new file mode 100644
--- /dev/null
+++ b/app/views/user_admin/user_stat_max.html.haml
@@ -0,0 +1,44 @@
+%h1 User grading results
+%h2 Show max scores in submission range
+
+- if @problem and @problem.errors
+ =error_messages_for 'problem'
+
+= render partial: 'submission_range'
+
+- if @log
+ %h3 Import log
+ %pre.import-log
+ = @log
+
+%p= link_to '[Show only latest submissions]', controller: :user_admin, action: :user_stat
+
+%table.info
+ %thead
+ %tr.info-head
+ %th User
+ %th Name
+ %th Activated?
+ %th Logged in
+ %th Contest(s)
+ - @problems.each do |p|
+ %th= p.name
+ %th Total
+ %th Passed
+ %tbody
+ - @scorearray.each do |sc|
+ %tr{class: cycle('info-even','info-odd')}
+ - total,num_passed = 0,0
+ - sc.each_index do |i|
+ - if i == 0
+ %td= sc[i].login
+ %td= sc[i].full_name
+ %td= sc[i].activated
+ %td= sc[i].try(:contest_stat).try(:started_at)!=nil ? 'yes' : 'no'
+ %td= sc[i].contests.collect {|c| c.name}.join(', ')
+ - else
+ %td= sc[i][0]
+ - total += sc[i][0]
+ - num_passed += 1 if sc[i][1]
+ %td= total
+ %td= num_passed
diff --git a/lib/mail_helper_methods.rb b/lib/mail_helper_methods.rb
--- a/lib/mail_helper_methods.rb
+++ b/lib/mail_helper_methods.rb
@@ -22,7 +22,18 @@
body mail_body
end
- mail.delivery_settings = { :address => smtp_server }
+ mail_option = {
+ :address => smtp_server,
+# :domain => nil,
+# :port => 25,
+# :user_name => nil,
+# :password => nil,
+# :authentication=>'plain',
+# :enable_starttls_auto => true
+ }
+
+ mail.delivery_method :smtp, mail_option
+
mail.deliver
end