diff --git a/Gemfile b/Gemfile
--- a/Gemfile
+++ b/Gemfile
@@ -1,6 +1,6 @@
source 'https://rubygems.org'
-gem 'rails', '3.2.19'
+gem 'rails', '3.2.21'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
@@ -10,13 +10,13 @@
# Gems used only for assets and not required
# in production environments by default.
group :assets do
- gem 'sass-rails', '~> 3.2.3'
- gem 'coffee-rails', '~> 3.2.1'
+ gem 'sass-rails', '~> 3.2.6'
+ gem 'coffee-rails', '~> 3.2.2'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', :platforms => :ruby
- gem 'uglifier', '>= 1.0.3'
+ gem 'uglifier'
end
gem 'prototype-rails'
@@ -37,6 +37,9 @@
# gem 'debugger'
#
+#in-place editor
+gem 'best_in_place', '~> 3.0.1'
+
# jquery addition
gem 'jquery-rails'
gem 'jquery-ui-sass-rails'
@@ -46,15 +49,15 @@
#syntax highlighter
gem 'rouge'
-gem "haml"
-gem "mail"
-gem "rdiscount"
-gem "test-unit"
-gem 'will_paginate', '~> 3.0.0'
+gem 'haml'
+gem 'mail'
+gem 'rdiscount'
+gem 'test-unit'
+gem 'will_paginate', '~> 3.0.7'
gem 'dynamic_form'
gem 'in_place_editing'
-gem 'verification', :git => 'git://github.com/sikachu/verification.git'
+gem 'verification', :git => 'https://github.com/sikachu/verification.git'
group :test, :development do
- gem "rspec-rails", "~> 2.0"
+ gem 'rspec-rails', '~> 2.99.0'
end
diff --git a/Gemfile.lock b/Gemfile.lock
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -1,5 +1,5 @@
GIT
- remote: git://github.com/sikachu/verification.git
+ remote: https://github.com/sikachu/verification.git
revision: 76eaf51b13276ecae54bd9cd115832595d2ff56d
specs:
verification (1.0.3)
@@ -9,12 +9,12 @@
GEM
remote: https://rubygems.org/
specs:
- actionmailer (3.2.19)
- actionpack (= 3.2.19)
+ actionmailer (3.2.21)
+ actionpack (= 3.2.21)
mail (~> 2.5.4)
- actionpack (3.2.19)
- activemodel (= 3.2.19)
- activesupport (= 3.2.19)
+ actionpack (3.2.21)
+ activemodel (= 3.2.21)
+ activesupport (= 3.2.21)
builder (~> 3.0.0)
erubis (~> 2.7.0)
journey (~> 1.0.4)
@@ -22,21 +22,24 @@
rack-cache (~> 1.2)
rack-test (~> 0.6.1)
sprockets (~> 2.2.1)
- activemodel (3.2.19)
- activesupport (= 3.2.19)
+ activemodel (3.2.21)
+ activesupport (= 3.2.21)
builder (~> 3.0.0)
- activerecord (3.2.19)
- activemodel (= 3.2.19)
- activesupport (= 3.2.19)
+ activerecord (3.2.21)
+ activemodel (= 3.2.21)
+ activesupport (= 3.2.21)
arel (~> 3.0.2)
tzinfo (~> 0.3.29)
- activeresource (3.2.19)
- activemodel (= 3.2.19)
- activesupport (= 3.2.19)
- activesupport (3.2.19)
+ activeresource (3.2.21)
+ activemodel (= 3.2.21)
+ activesupport (= 3.2.21)
+ activesupport (3.2.21)
i18n (~> 0.6, >= 0.6.4)
multi_json (~> 1.0)
arel (3.0.3)
+ best_in_place (3.0.3)
+ actionpack (>= 3.2)
+ railties (>= 3.2)
builder (3.0.4)
coffee-rails (3.2.2)
coffee-script (>= 2.2.0)
@@ -44,21 +47,21 @@
coffee-script (2.3.0)
coffee-script-source
execjs
- coffee-script-source (1.7.1)
+ coffee-script-source (1.9.0)
diff-lcs (1.2.5)
dynamic_form (1.1.4)
erubis (2.7.0)
- execjs (2.2.1)
- haml (4.0.5)
+ execjs (2.3.0)
+ haml (4.0.6)
tilt
hike (1.2.3)
- i18n (0.6.11)
+ i18n (0.7.0)
in_place_editing (1.2.0)
journey (1.0.4)
- jquery-rails (3.1.1)
+ jquery-rails (3.1.2)
railties (>= 3.0, < 5.0)
thor (>= 0.14, < 2.0)
- jquery-tablesorter (1.12.7)
+ jquery-tablesorter (1.13.4)
railties (>= 3.1, < 5)
jquery-timepicker-addon-rails (1.4.1)
railties (>= 3.1)
@@ -69,15 +72,15 @@
jquery-rails
jquery-ui-rails (= 4.0.3)
railties (>= 3.1.0)
- json (1.8.1)
+ json (1.8.2)
mail (2.5.4)
mime-types (~> 1.16)
treetop (~> 1.4.8)
mime-types (1.25.1)
multi_json (1.10.1)
- mysql2 (0.3.16)
+ mysql2 (0.3.17)
polyglot (0.3.5)
- power_assert (0.1.3)
+ power_assert (0.2.2)
prototype-rails (3.2.1)
rails (~> 3.2)
rack (1.4.5)
@@ -85,34 +88,34 @@
rack (>= 0.4)
rack-ssl (1.3.4)
rack
- rack-test (0.6.2)
+ rack-test (0.6.3)
rack (>= 1.0)
- rails (3.2.19)
- actionmailer (= 3.2.19)
- actionpack (= 3.2.19)
- activerecord (= 3.2.19)
- activeresource (= 3.2.19)
- activesupport (= 3.2.19)
+ rails (3.2.21)
+ actionmailer (= 3.2.21)
+ actionpack (= 3.2.21)
+ activerecord (= 3.2.21)
+ activeresource (= 3.2.21)
+ activesupport (= 3.2.21)
bundler (~> 1.0)
- railties (= 3.2.19)
- railties (3.2.19)
- actionpack (= 3.2.19)
- activesupport (= 3.2.19)
+ railties (= 3.2.21)
+ railties (3.2.21)
+ actionpack (= 3.2.21)
+ activesupport (= 3.2.21)
rack-ssl (~> 1.3.2)
rake (>= 0.8.7)
rdoc (~> 3.4)
thor (>= 0.14.6, < 2.0)
- rake (10.3.2)
- rdiscount (2.1.7.1)
+ rake (10.4.2)
+ rdiscount (2.1.8)
rdoc (3.12.2)
json (~> 1.4)
- rouge (1.6.2)
- rspec-collection_matchers (1.0.0)
+ rouge (1.8.0)
+ rspec-collection_matchers (1.1.2)
rspec-expectations (>= 2.99.0.beta1)
rspec-core (2.99.2)
rspec-expectations (2.99.2)
diff-lcs (>= 1.1.3, < 2.0)
- rspec-mocks (2.99.2)
+ rspec-mocks (2.99.3)
rspec-rails (2.99.0)
actionpack (>= 3.0)
activemodel (>= 3.0)
@@ -122,25 +125,25 @@
rspec-core (~> 2.99.0)
rspec-expectations (~> 2.99.0)
rspec-mocks (~> 2.99.0)
- sass (3.4.1)
+ sass (3.4.11)
sass-rails (3.2.6)
railties (~> 3.2.0)
sass (>= 3.1.10)
tilt (~> 1.3)
- sprockets (2.2.2)
+ sprockets (2.2.3)
hike (~> 1.2)
multi_json (~> 1.0)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
- test-unit (3.0.1)
+ test-unit (3.0.9)
power_assert
thor (0.19.1)
tilt (1.4.1)
treetop (1.4.15)
polyglot
polyglot (>= 0.3.1)
- tzinfo (0.3.41)
- uglifier (2.5.3)
+ tzinfo (0.3.43)
+ uglifier (2.7.0)
execjs (>= 0.3.0)
json (>= 1.8.0)
will_paginate (3.0.7)
@@ -149,7 +152,8 @@
ruby
DEPENDENCIES
- coffee-rails (~> 3.2.1)
+ best_in_place (~> 3.0.1)
+ coffee-rails (~> 3.2.2)
dynamic_form
haml
in_place_editing
@@ -160,12 +164,12 @@
mail
mysql2
prototype-rails
- rails (= 3.2.19)
+ rails (= 3.2.21)
rdiscount
rouge
- rspec-rails (~> 2.0)
- sass-rails (~> 3.2.3)
+ rspec-rails (~> 2.99.0)
+ sass-rails (~> 3.2.6)
test-unit
- uglifier (>= 1.0.3)
+ uglifier
verification!
- will_paginate (~> 3.0.0)
+ will_paginate (~> 3.0.7)
diff --git a/README b/README
--- a/README
+++ b/README
@@ -1,182 +1,10 @@
-== Welcome to Rails
-
-Rails is a web-application and persistence framework that includes everything
-needed to create database-backed web-applications according to the
-Model-View-Control pattern of separation. This pattern splits the view (also
-called the presentation) into "dumb" templates that are primarily responsible
-for inserting pre-built data in between HTML tags. The model contains the
-"smart" domain objects (such as Account, Product, Person, Post) that holds all
-the business logic and knows how to persist themselves to a database. The
-controller handles the incoming requests (such as Save New Account, Update
-Product, Show Post) by manipulating the model and directing data to the view.
-
-In Rails, the model is handled by what's called an object-relational mapping
-layer entitled Active Record. This layer allows you to present the data from
-database rows as objects and embellish these data objects with business logic
-methods. You can read more about Active Record in
-link:files/vendor/rails/activerecord/README.html.
-
-The controller and view are handled by the Action Pack, which handles both
-layers by its two parts: Action View and Action Controller. These two layers
-are bundled in a single package due to their heavy interdependence. This is
-unlike the relationship between the Active Record and Action Pack that is much
-more separate. Each of these packages can be used independently outside of
-Rails. You can read more about Action Pack in
-link:files/vendor/rails/actionpack/README.html.
-
-
-== Getting started
-
-1. At the command prompt, start a new rails application using the rails command
- and your application name. Ex: rails myapp
- (If you've downloaded rails in a complete tgz or zip, this step is already done)
-2. Change directory into myapp and start the web server: script/server (run with --help for options)
-3. Go to http://localhost:3000/ and get "Welcome aboard: You’re riding the Rails!"
-4. Follow the guidelines to start developing your application
-
-
-== Web Servers
-
-By default, Rails will try to use Mongrel and lighttpd if they are installed, otherwise
-Rails will use the WEBrick, the webserver that ships with Ruby. When you run script/server,
-Rails will check if Mongrel exists, then lighttpd and finally fall back to WEBrick. This ensures
-that you can always get up and running quickly.
+== cafe grader
-Mongrel is a Ruby-based webserver with a C-component (which requires compilation) that is
-suitable for development and deployment of Rails applications. If you have Ruby Gems installed,
-getting up and running with mongrel is as easy as: gem install mongrel.
-More info at: http://mongrel.rubyforge.org
-
-If Mongrel is not installed, Rails will look for lighttpd. It's considerably faster than
-Mongrel and WEBrick and also suited for production use, but requires additional
-installation and currently only works well on OS X/Unix (Windows users are encouraged
-to start with Mongrel). We recommend version 1.4.11 and higher. You can download it from
-http://www.lighttpd.net.
-
-And finally, if neither Mongrel or lighttpd are installed, Rails will use the built-in Ruby
-web server, WEBrick. WEBrick is a small Ruby web server suitable for development, but not
-for production.
-
-But of course its also possible to run Rails on any platform that supports FCGI.
-Apache, LiteSpeed, IIS are just a few. For more information on FCGI,
-please visit: http://wiki.rubyonrails.com/rails/pages/FastCGI
-
-
-== Debugging Rails
-
-Have "tail -f" commands running on the server.log and development.log. Rails will
-automatically display debugging and runtime information to these files. Debugging
-info will also be shown in the browser on requests from 127.0.0.1.
-
-
-== Breakpoints
-
-Breakpoint support is available through the script/breakpointer client. This
-means that you can break out of execution at any point in the code, investigate
-and change the model, AND then resume execution! Example:
-
- class WeblogController < ActionController::Base
- def index
- @posts = Post.find(:all)
- breakpoint "Breaking out from the list"
- end
- end
-
-So the controller will accept the action, run the first line, then present you
-with a IRB prompt in the breakpointer window. Here you can do things like:
-
-Executing breakpoint "Breaking out from the list" at .../webrick_server.rb:16 in 'breakpoint'
+cafe grader is a programming contest platform used in Thailand IOI training.
+The package includes 2 repositories, jittat/cafe-grader-web and jittat/cafe-grader-judge-scripts.
- >> @posts.inspect
- => "[#nil, \"body\"=>nil, \"id\"=>\"1\"}>,
- #\"Rails you know!\", \"body\"=>\"Only ten..\", \"id\"=>\"2\"}>]"
- >> @posts.first.title = "hello from a breakpoint"
- => "hello from a breakpoint"
-
-...and even better is that you can examine how your runtime objects actually work:
-
- >> f = @posts.first
- => #nil, "body"=>nil, "id"=>"1"}>
- >> f.
- Display all 152 possibilities? (y or n)
-
-Finally, when you're ready to resume execution, you press CTRL-D
-
-
-== Console
-
-You can interact with the domain model by starting the console through script/console.
-Here you'll have all parts of the application configured, just like it is when the
-application is running. You can inspect domain models, change values, and save to the
-database. Starting the script without arguments will launch it in the development environment.
-Passing an argument will specify a different environment, like script/console production.
-
-To reload your controllers and models after launching the console run reload!
-
-To reload your controllers and models after launching the console run reload!
-
-
-
-== Description of contents
-
-app
- Holds all the code that's specific to this particular application.
-
-app/controllers
- Holds controllers that should be named like weblogs_controller.rb for
- automated URL mapping. All controllers should descend from ApplicationController
- which itself descends from ActionController::Base.
-
-app/models
- Holds models that should be named like post.rb.
- Most models will descend from ActiveRecord::Base.
+=== Installation
-app/views
- Holds the template files for the view that should be named like
- weblogs/index.rhtml for the WeblogsController#index action. All views use eRuby
- syntax.
-
-app/views/layouts
- Holds the template files for layouts to be used with views. This models the common
- header/footer method of wrapping views. In your views, define a layout using the
- layout :default and create a file named default.rhtml. Inside default.rhtml,
- call <% yield %> to render the view using this layout.
-
-app/helpers
- Holds view helpers that should be named like weblogs_helper.rb. These are generated
- for you automatically when using script/generate for controllers. Helpers can be used to
- wrap functionality for your views into methods.
-
-config
- Configuration files for the Rails environment, the routing map, the database, and other dependencies.
-
-components
- Self-contained mini-applications that can bundle together controllers, models, and views.
+The system is tested on ubuntu 14.04 LTS. Use the installation script in
+cafe-grader-judge-scripts/installer/install.sh . See http://theory.cpe.ku.ac.th/wiki/index.php/%E0%B8%81%E0%B8%B2%E0%B8%A3%E0%B8%95%E0%B8%B4%E0%B8%94%E0%B8%95%E0%B8%B1%E0%B9%89%E0%B8%87_Cafe_grader for the detail.
-db
- Contains the database schema in schema.rb. db/migrate contains all
- the sequence of Migrations for your schema.
-
-doc
- This directory is where your application documentation will be stored when generated
- using rake doc:app
-
-lib
- Application specific libraries. Basically, any kind of custom code that doesn't
- belong under controllers, models, or helpers. This directory is in the load path.
-
-public
- The directory available for the web server. Contains subdirectories for images, stylesheets,
- and javascripts. Also contains the dispatchers and the default HTML files. This should be
- set as the DOCUMENT_ROOT of your web server.
-
-script
- Helper scripts for automation and generation.
-
-test
- Unit and functional tests along with fixtures. When using the script/generate scripts, template
- test files will be generated for you and placed in this directory.
-
-vendor
- External libraries that the application depends on. Also includes the plugins subdirectory.
- This directory is in the load path.
diff --git a/app/assets/javascripts/local_jquery.js b/app/assets/javascripts/local_jquery.js
--- a/app/assets/javascripts/local_jquery.js
+++ b/app/assets/javascripts/local_jquery.js
@@ -5,3 +5,10 @@
//= require jquery.ui.slider
//= require jquery-ui-timepicker-addon
//= require jquery-tablesorter
+//= require best_in_place
+//= require best_in_place.jquery-ui
+
+$(document).ready(function() {
+ /* Activating Best In Place */
+ jQuery(".best_in_place").best_in_place();
+});
diff --git a/app/controllers/configurations_controller.rb b/app/controllers/configurations_controller.rb
--- a/app/controllers/configurations_controller.rb
+++ b/app/controllers/configurations_controller.rb
@@ -3,9 +3,6 @@
before_filter :authenticate
before_filter { |controller| controller.authorization_by_roles(['admin'])}
- in_place_edit_for :grader_configuration, :key
- in_place_edit_for :grader_configuration, :type
- in_place_edit_for :grader_configuration, :value
def index
@configurations = GraderConfiguration.find(:all,
@@ -17,4 +14,15 @@
redirect_to :action => 'index'
end
+ def update
+ @config = GraderConfiguration.find(params[:id])
+ respond_to do |format|
+ if @config.update_attributes(params[:grader_configuration])
+ format.json { head :ok }
+ else
+ format.json { respond_with_bip(@config) }
+ end
+ end
+ end
+
end
diff --git a/app/controllers/contest_management_controller.rb b/app/controllers/contest_management_controller.rb
--- a/app/controllers/contest_management_controller.rb
+++ b/app/controllers/contest_management_controller.rb
@@ -37,7 +37,7 @@
end
def change_contest_mode
- if ['standard', 'contest', 'indv-contest'].include? params[:id]
+ if ['standard', 'contest', 'indv-contest', 'analysis'].include? params[:id]
config = GraderConfiguration.find_by_key('system.mode')
config.value = params[:id]
config.save
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
@@ -71,7 +71,7 @@
@submission.ip_address = request.remote_ip
if GraderConfiguration.time_limit_mode? and user.contest_finished?
- @submission.errors.add_to_base "The contest is over."
+ @submission.errors.add(:base,"The contest is over.")
prepare_list_information
render :action => 'list' and return
end
@@ -194,7 +194,7 @@
def confirm_contest_start
user = User.find(session[:user_id])
- if request.method == :post
+ if request.method == 'POST'
user.update_start_time
redirect_to :action => 'list'
else
diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb
--- a/app/controllers/messages_controller.rb
+++ b/app/controllers/messages_controller.rb
@@ -31,20 +31,21 @@
user = User.find(session[:user_id])
@message = Message.new(params[:message])
@message.sender = user
- if !@message.save
- render :action => 'list' and return
+ if @message.body == '' or !@message.save
+ flash[:notice] = 'An error occurred'
else
flash[:notice] = 'New message posted'
- redirect_to :action => 'list'
end
+ redirect_to :action => 'list'
end
def reply
user = User.find(session[:user_id])
@message = Message.new(params[:r_message])
@message.sender = user
- if !@message.save
- render :action => 'show' and return
+ if @message.body == '' or !@message.save
+ flash[:notice] = 'An error occurred'
+ redirect_to :action => 'show', :id => @message.replying_message_id
else
flash[:notice] = 'Message replied'
rep_msg = @message.replying_message
@@ -58,7 +59,7 @@
message = Message.find(params[:id])
message.replied = true
message.save
- flash[:notice] = 'Message hided (just marked replied)'
+ flash[:notice] = 'Message hidden (just marked replied)'
redirect_to :action => 'console'
end
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
@@ -1,6 +1,6 @@
class ReportController < ApplicationController
- before_filter :admin_authorization, only: [:login_stat,:submission_stat]
+ before_filter :admin_authorization, only: [:login_stat,:submission_stat, :stuck]
before_filter(only: [:problem_hof]) { |c|
return false unless authenticate
@@ -118,6 +118,7 @@
d = (DateTime.now.in_time_zone - sub.submitted_at) / 24 / 60 / 60
@histogram[:data][d.to_i] += 1 if d < range
+ next unless sub.points
@summary[:count] += 1
user[sub.user_id] = [user[sub.user_id], (sub.points >= @problem.full_score) ? 1 : 0].max
@@ -196,7 +197,7 @@
@struggle = Array.new
record = {}
Submission.includes(:problem,:user).order(:problem_id,:user_id).find_each do |sub|
- next unless sub.user and sub.problem
+ next unless sub.problem and sub.user
if user != sub.user_id or problem != sub.problem_id
@struggle << { user: record[:user], problem: record[:problem], tries: tries } unless solve
record = {user: sub.user, problem: sub.problem}
diff --git a/app/controllers/test_controller.rb b/app/controllers/test_controller.rb
--- a/app/controllers/test_controller.rb
+++ b/app/controllers/test_controller.rb
@@ -26,7 +26,7 @@
if GraderConfiguration.time_limit_mode?
if @user.contest_finished?
- @submitted_test_request.errors.add_to_base('Contest is over.')
+ @submitted_test_request.errors.add(:base,'Contest is over.')
prepare_index_information
render :action => 'index' and return
end
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
@@ -2,7 +2,6 @@
class UserAdminController < ApplicationController
-
include MailHelperMethods
before_filter :admin_authorization
@@ -85,7 +84,8 @@
end
user = User.find_by_login(login)
- if user
+ if (user)
+ user.full_name = full_name
user.password = password
else
user = User.new({:login => login,
@@ -150,7 +150,6 @@
end
@scorearray << ustat
end
-
if params[:commit] == 'download csv' then
csv = gen_csv_from_scorearray(@scorearray,@problems)
send_data csv, filename: 'last_score.csv'
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
@@ -63,7 +63,7 @@
render :action => 'email_error', :layout => 'empty'
end
else
- @user.errors.add_to_base("Email cannot be blank") if @user.email==''
+ @user.errors.add(:base,"Email cannot be blank") if @user.email==''
render :action => 'new', :layout => 'empty'
end
end
@@ -154,7 +154,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
@@ -170,7 +170,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
@@ -118,7 +118,7 @@