code stringlengths 1 1.73M | language stringclasses 1
value |
|---|---|
class TasksController < ApplicationController
before_filter :authenticate, :check_viewability
def index
redirect_to :action => 'list'
end
def list
@problems = Problem.find_available_problems
@user = User.find(session[:user_id])
end
def view
base_filename = File.basename("#{params[:file]}... | Ruby |
require 'tmail'
require 'net/smtp'
class UsersController < ApplicationController
before_filter :authenticate, :except => [:new,
:register,
:confirm,
:forget,
... | Ruby |
class AnnouncementsController < ApplicationController
before_filter :admin_authorization
in_place_edit_for :announcement, :published
# GET /announcements
# GET /announcements.xml
def index
@announcements = Announcement.find(:all,
:order => "created_at DESC")
... | Ruby |
class UserAdminController < ApplicationController
before_filter :admin_authorization
def index
list
render :action => 'list'
end
# GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html)
verify :method => :post, :only => [ :destroy,
:create,... | Ruby |
class SiteController < ApplicationController
before_filter :site_admin_authorization, :except => 'login'
def login
# Site administrator login
@countries = Country.find(:all, :include => :sites)
@country_select = @countries.collect { |c| [c.name, c.id] }
@country_select_with_all = [['Any',0]]
... | Ruby |
class TestController < ApplicationController
SYSTEM_MODE_CONF_KEY = 'system.mode'
before_filter :authenticate, :check_viewability
#
# COMMENT OUT: filter in each action instead
#
# before_filter :verify_time_limit, :only => [:submit]
verify :method => :post, :only => [:submit],
:redirect_to => { :a... | Ruby |
ActionController::Routing::Routes.draw do |map|
map.resources :announcements
map.resources :sites
# The priority is based upon order of creation: first created -> highest priority.
# Sample of regular route:
# map.connect 'products/:id', :controller => 'catalog', :action => 'view'
# Keep in mind you can... | Ruby |
# Don't change this file!
# Configure your app in config/environment.rb and config/environments/*.rb
RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT)
module Rails
class << self
def boot!
unless booted?
preinitialize
pick_boot.run
end
end
def booted?
... | Ruby |
# Thai translation for Ruby on Rails
# original by Prem Sichanugrist (s@sikachu.com/sikandsak@gmail.com)
# activerecord keys fixed by Jittat Fakcharoenphol (jittat@gmail.com)
{
:'th' => {
:date => {
:formats => {
:default => lambda { |date| "%d-%m-#{date.year+543}" },
:short =>... | Ruby |
class SizeFilterHandler < Mongrel::HttpHandler
def initialize(options = {})
@max_size = options[:max_size] || -1
@redirect_url = options[:redirect_url]
@request_notify = true
end
def request_begins(params)
@request_too_large = false
# Only operate on POST requests
return unless pa... | Ruby |
# Settings specified here will take precedence over those in config/environment.rb
# The production environment is meant for finished, "live" apps.
# Code is not reloaded between requests
config.cache_classes = true
# Use a different logger for distributed setups
# config.logger = SyslogLogger.new
# Full error repor... | Ruby |
# Settings specified here will take precedence over those in config/environment.rb
# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
# since you don't have to restart the webserver when you make code changes.
config.ca... | Ruby |
# Settings specified here will take precedence over those in config/environment.rb
# The test environment is used exclusively to run your application's
# test suite. You never need to work with it otherwise. Remember that
# your test database is "scratch space" for the test suite and is wiped
# and recreated between... | Ruby |
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
require(File.join(File.dirname(__FILE__), 'config', 'boot'))
require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'
require 'tasks/rails'
require 'spe... | Ruby |
gem 'test-unit', '1.2.3' if RUBY_VERSION.to_f >= 1.9
rspec_gem_dir = nil
Dir["#{RAILS_ROOT}/vendor/gems/*"].each do |subdir|
rspec_gem_dir = subdir if subdir.gsub("#{RAILS_ROOT}/vendor/gems/","") =~ /^(\w+-)?rspec-(\d+)/ && File.exist?("#{subdir}/lib/spec/rake/spectask.rb")
end
rspec_plugin_dir = File.expand_path(Fil... | Ruby |
#!/usr/bin/ruby
def talk(str)
if TALKATIVE
puts str
end
end
def execute(command, error_message="")
if not system(command)
puts "ERROR: #{error_message}"
exit(127)
end
end
def save_source(submission,dir,fname)
f = File.open("#{dir}/#{fname}","w")
f.write(submission.source)
f.close
end
def c... | Ruby |
#!/usr/bin/ruby
problem_home = ENV['PROBLEM_HOME']
require "#{problem_home}/script/test_dsl.rb"
if ARGV.length < 2
puts "Usage: check <language> <test-number> [<output-file>]"
exit(0)
end
language = ARGV[0]
test_num = ARGV[1].to_i
if ARGV.length >= 3
output_file_name = ARGV[2]
else
output_file_name = "output... | Ruby |
#!/usr/bin/ruby
problem_home = ENV['PROBLEM_HOME']
require "#{problem_home}/script/test_dsl.rb"
if ARGV.length < 2
puts "Usage: check <language> <test-number> [<output-file>]"
exit(0)
end
language = ARGV[0]
test_num = ARGV[1].to_i
if ARGV.length >= 3
output_file_name = ARGV[2]
else
output_file_name = "output... | Ruby |
#!/usr/bin/ruby
problem_home = ENV['PROBLEM_HOME']
require "#{problem_home}/script/test_dsl.rb"
if ARGV.length < 2
puts "Usage: check <language> <test-number> [<output-file>]"
exit(0)
end
language = ARGV[0]
test_num = ARGV[1].to_i
if ARGV.length >= 3
output_file_name = ARGV[2]
else
output_file_name = "output... | Ruby |
#!/usr/bin/ruby
problem_home = ENV['PROBLEM_HOME']
require "#{problem_home}/script/test_dsl.rb"
if ARGV.length < 2
puts "Usage: check <language> <test-number> [<output-file>]"
exit(0)
end
language = ARGV[0]
test_num = ARGV[1].to_i
if ARGV.length >= 3
output_file_name = ARGV[2]
else
output_file_name = "output... | Ruby |
#!/usr/bin/ruby
problem_home = ENV['PROBLEM_HOME']
require "#{problem_home}/script/test_dsl.rb"
if ARGV.length < 2
puts "Usage: check <language> <test-number> [<output-file>]"
exit(0)
end
language = ARGV[0]
test_num = ARGV[1].to_i
if ARGV.length >= 3
output_file_name = ARGV[2]
else
output_file_name = "output... | Ruby |
#!/usr/bin/ruby
problem_home = ENV['PROBLEM_HOME']
require "#{problem_home}/script/test_dsl.rb"
if ARGV.length < 2
puts "Usage: check <language> <test-number> [<output-file>]"
exit(0)
end
language = ARGV[0]
test_num = ARGV[1].to_i
if ARGV.length >= 3
output_file_name = ARGV[2]
else
output_file_name = "output... | Ruby |
#!/usr/bin/ruby
problem_home = ENV['PROBLEM_HOME']
require "#{problem_home}/script/test_dsl.rb"
if ARGV.length < 2
puts "Usage: check <language> <test-number> [<output-file>]"
exit(0)
end
language = ARGV[0]
test_num = ARGV[1].to_i
if ARGV.length >= 3
output_file_name = ARGV[2]
else
output_file_name = "output... | Ruby |
#!/usr/bin/ruby
problem_home = ENV['PROBLEM_HOME']
require "#{problem_home}/script/test_dsl.rb"
if ARGV.length < 2
puts "Usage: check <language> <test-number> [<output-file>]"
exit(0)
end
language = ARGV[0]
test_num = ARGV[1].to_i
if ARGV.length >= 3
output_file_name = ARGV[2]
else
output_file_name = "output... | Ruby |
module GraderEngineHelperMethods
def clear_sandbox
config = Grader::Configuration.get_instance
clear_cmd = "rm -rf #{config.test_sandbox_dir}/*"
system(clear_cmd)
end
def init_sandbox
config = Grader::Configuration.get_instance
clear_sandbox
FileUtils.mkdir_p config.user_result_dir
c... | Ruby |
# This test helper loads the grader's environment and rails environment
GRADER_ENV = 'test'
require File.join(File.dirname(__FILE__),'../config/environment')
# this shall be removed soon
RAILS_ENV = Grader::Configuration.get_instance.rails_env
require RAILS_ROOT + '/config/environment'
# make sure not to access re... | Ruby |
# This test helper loads the grader's environment and rails environment
GRADER_ENV = 'test'
require File.join(File.dirname(__FILE__),'../config/environment')
# this shall be removed soon
RAILS_ENV = Grader::Configuration.get_instance.rails_env
require RAILS_ROOT + '/config/environment'
# make sure not to access re... | Ruby |
#!/usr/bin/ruby
# new_problem:
# * creates a directory for a problem in the current directory,
# * create standard testcase config file
require 'erb'
def process_options(options)
i = 2
while i<ARGV.length
if ARGV[i]=='-t'
options[:time_limit] = ARGV[i+1].to_i if ARGV.length>i+1
i += 1
end
... | Ruby |
#!/usr/bin/ruby
def talk(str)
if TALKATIVE
puts str
end
end
def execute(command, error_message="")
if not system(command)
puts "ERROR: #{error_message}"
exit(127)
end
end
def save_source(submission,dir,fname)
f = File.open("#{dir}/#{fname}","w")
f.write(submission.source)
f.close
end
def c... | Ruby |
#!/usr/bin/ruby
def stop_grader(id)
if id==:all
File.open(File.dirname(__FILE__) + "/stop.all",'w').close
else
File.open(File.dirname(__FILE__) + "/stop.#{id}",'w').close
end
end
def check_stopfile
FileTest.exist?(File.dirname(__FILE__) + "/stop.all") or
FileTest.exist?(File.dirname(__FILE__) + "/... | Ruby |
#!/usr/bin/ruby
# import_problem:
# * creates a directory for a problem in the current directory,
# * copy testdata in the old format and create standard testcase config file
require 'erb'
require 'fileutils'
require File.join(File.dirname(__FILE__),'lib/import_helper')
def input_filename(dir,i)
"#{dir}/input-#{... | Ruby |
#!/usr/bin/ruby
# import_problem:
# * creates a directory for a problem in the current directory,
# * copy testdata in the old format and create standard testcase config file
require 'erb'
require 'fileutils'
require File.join(File.dirname(__FILE__),'lib/import_helper')
def input_filename(dir,i)
"#{dir}/input-#{... | Ruby |
#!/usr/bin/ruby
# new_problem:
# * creates a directory for a problem in the current directory,
# * create standard testcase config file
require 'erb'
def process_options(options)
i = 2
while i<ARGV.length
if ARGV[i]=='-t'
options[:time_limit] = ARGV[i+1].to_i if ARGV.length>i+1
i += 1
end
... | Ruby |
#!/usr/bin/ruby
def log(str='')
if ENV['TALKATIVE']!=nil
puts str
end
if ENV['GRADER_LOGGING']!=nil
log_fname = ENV['GRADER_LOGGING']
fp = File.open(log_fname,"a")
fp.puts("judge: #{Time.new.strftime("%H:%M")} #{str}")
fp.close
end
end
problem_home = ENV['PROBLEM_HOME']
def execute(comman... | Ruby |
#!/usr/bin/ruby
CORRECT_MARK = 'P'
INCORRECT_MARK = '-'
TIMEOUT_MARK = 'T'
RUN_ERROR_MARK = 'x'
def log(str='')
if ENV['TALKATIVE']!=nil
puts str
end
if ENV['GRADER_LOGGING']!=nil
log_fname = ENV['GRADER_LOGGING']
fp = File.open(log_fname,"a")
fp.puts("grade: #{Time.new.strftime("%H:%M")} #{str}... | Ruby |
#!/usr/bin/ruby
problem_home = ENV['PROBLEM_HOME']
require "#{problem_home}/script/test_dsl.rb"
if ARGV.length < 2
puts "Usage: check <language> <test-number> [<output-file>]"
exit(0)
end
language = ARGV[0]
test_num = ARGV[1].to_i
if ARGV.length >= 3
output_file_name = ARGV[2]
else
output_file_name = "output... | Ruby |
#!/usr/bin/ruby
def log(str='')
if ENV['TALKATIVE']!=nil
puts str
end
if ENV['GRADER_LOGGING']!=nil
log_fname = ENV['GRADER_LOGGING']
fp = File.open(log_fname,"a")
fp.puts("run: #{Time.new.strftime("%H:%M")} #{str}")
fp.close
end
end
def extract_time(t)
# puts "TIME: #{t}"
if (result=... | Ruby |
#!/usr/bin/ruby
def log(str='')
if ENV['TALKATIVE']!=nil
puts str
end
if ENV['GRADER_LOGGING']!=nil
log_fname = ENV['GRADER_LOGGING']
fp = File.open(log_fname,"a")
fp.puts("judge: #{Time.new.strftime("%H:%M")} #{str}")
fp.close
end
end
problem_home = ENV['PROBLEM_HOME']
def execute(comman... | Ruby |
#!/usr/bin/ruby
CORRECT_MARK = 'P'
INCORRECT_MARK = '-'
TIMEOUT_MARK = 'T'
RUN_ERROR_MARK = 'x'
def log(str='')
if ENV['TALKATIVE']!=nil
puts str
end
if ENV['GRADER_LOGGING']!=nil
log_fname = ENV['GRADER_LOGGING']
fp = File.open(log_fname,"a")
fp.puts("grade: #{Time.new.strftime("%H:%M")} #{str}... | Ruby |
#!/usr/bin/ruby
def log(str='')
if ENV['TALKATIVE']!=nil
puts str
end
if ENV['GRADER_LOGGING']!=nil
log_fname = ENV['GRADER_LOGGING']
fp = File.open(log_fname,"a")
fp.puts("run: #{Time.new.strftime("%H:%M")} #{str}")
fp.close
end
end
def extract_time(t)
# puts "TIME: #{t}"
if (result=... | Ruby |
class DSLNode
def DSLNode.scalar_attr(*names)
names.each do |name|
define_method name do |*a|
if a.length == 0
instance_variable_get( "@#{name}" )
else
instance_variable_set( "@#{name}", a[0] )
end
end
end
end
def DSLNode.array_attr(*names)
... | Ruby |
#!/usr/bin/ruby
problem_home = ENV['PROBLEM_HOME']
require "#{problem_home}/script/test_dsl.rb"
if ARGV.length < 2
puts "Usage: check <language> <test-number> [<output-file>]"
exit(0)
end
language = ARGV[0]
test_num = ARGV[1].to_i
if ARGV.length >= 3
output_file_name = ARGV[2]
else
output_file_name = "output... | Ruby |
#!/usr/bin/ruby
#
# This is a check script wrapper. It read all required information
# and call a real check script call REAL_CHECK_SCRIPT in directory
# [problem_home]/script
#
REAL_CHECK_SCRIPT = "<%= script_name %>"
# The REAL_CHECK_SCRIPT is called with:
#
# (script) <lang> <test-num> <in-file> <out-file> <ans... | Ruby |
#!/usr/bin/ruby
#
# This is a check script wrapper. It read all required information
# and call a real check script call REAL_CHECK_SCRIPT in directory
# [problem_home]/script
#
REAL_CHECK_SCRIPT = "<%= script_name %>"
# The REAL_CHECK_SCRIPT is called with:
#
# (script) <lang> <test-num> <in-file> <out-file> <ans... | Ruby |
#!/usr/bin/ruby
problem_home = ENV['PROBLEM_HOME']
require "#{problem_home}/script/test_dsl.rb"
if ARGV.length < 2
puts "Usage: check <language> <test-number> [<output-file>]"
exit(0)
end
language = ARGV[0]
test_num = ARGV[1].to_i
if ARGV.length >= 3
output_file_name = ARGV[2]
else
output_file_name = "output... | Ruby |
#!/usr/bin/ruby
problem_home = ENV['PROBLEM_HOME']
require "#{problem_home}/script/test_dsl.rb"
if ARGV.length < 2
puts "Usage: check <language> <test-number> [<output-file>]"
exit(0)
end
language = ARGV[0]
test_num = ARGV[1].to_i
if ARGV.length >= 3
output_file_name = ARGV[2]
else
output_file_name = "output... | Ruby |
#!/usr/bin/ruby
problem_home = ENV['PROBLEM_HOME']
require "#{problem_home}/script/test_dsl.rb"
if ARGV.length < 2
puts "Usage: check <language> <test-number> [<output-file>]"
exit(0)
end
language = ARGV[0]
test_num = ARGV[1].to_i
if ARGV.length >= 3
output_file_name = ARGV[2]
else
output_file_name = "output... | Ruby |
#!/usr/bin/ruby
problem_home = ENV['PROBLEM_HOME']
require "#{problem_home}/script/test_dsl.rb"
if ARGV.length < 2
puts "Usage: check <language> <test-number> [<output-file>]"
exit(0)
end
language = ARGV[0]
test_num = ARGV[1].to_i
if ARGV.length >= 3
output_file_name = ARGV[2]
else
output_file_name = "output... | Ruby |
#!/usr/bin/ruby
problem_home = ENV['PROBLEM_HOME']
require "#{problem_home}/script/test_dsl.rb"
if ARGV.length < 2
puts "Usage: check <language> <test-number> [<output-file>]"
exit(0)
end
language = ARGV[0]
test_num = ARGV[1].to_i
if ARGV.length >= 3
output_file_name = ARGV[2]
else
output_file_name = "output... | Ruby |
#!/usr/bin/ruby
problem_home = ENV['PROBLEM_HOME']
require "#{problem_home}/script/test_dsl.rb"
if ARGV.length < 2
puts "Usage: check <language> <test-number> [<output-file>]"
exit(0)
end
language = ARGV[0]
test_num = ARGV[1].to_i
if ARGV.length >= 3
output_file_name = ARGV[2]
else
output_file_name = "output... | Ruby |
#!/usr/bin/ruby
def stop_grader(id)
if id==:all
File.open(File.dirname(__FILE__) + "/stop.all",'w').close
else
File.open(File.dirname(__FILE__) + "/stop.#{id}",'w').close
end
end
def check_stopfile
FileTest.exist?(File.dirname(__FILE__) + "/stop.all") or
FileTest.exist?(File.dirname(__FILE__) + "/... | Ruby |
#
# A runner drives the engine into various tasks.
#
module Grader
class Runner
def initialize(engine, grader_process=nil)
@engine = engine
@grader_process = grader_process
end
def grade_oldest_task
task = Task.get_inqueue_and_change_status(Task::STATUS_GRADING)
if task!=nil
... | Ruby |
module Grader
# This singleton class holds basic configurations for grader. When
# running in each mode, grader uses resources from different
# directories and outputs differently. Usually the attributes name
# are descriptive; below we explain more on each attributes.
class Configuration
# Rails' envi... | Ruby |
def filter_filename_for_testrun(testrun, filename_list)
l = []
regex = Regexp.new("^(#{testrun}[a-z]*|#{testrun}-.*)$")
filename_list.each do |filename|
if regex.match(filename)
l << filename
end
end
l
end
def build_testrun_info(num_testruns, input_filename_list)
info = []
num_testcases = ... | Ruby |
module Grader
class SubmissionRoomMaker
def initialize
@config = Grader::Configuration.get_instance
end
def produce_grading_room(submission)
user = submission.user
problem = submission.problem
grading_room = "#{@config.user_result_dir}/" +
"#{user.login}/#{problem.na... | Ruby |
module Grader
class Initializer
def self.run(&block)
config = Grader::Configuration.get_instance
yield config
end
end
end
| Ruby |
require File.join(File.dirname(__FILE__), 'configuration')
require File.join(File.dirname(__FILE__), 'initializer')
require File.join(File.dirname(__FILE__), 'submission_helper')
require File.join(File.dirname(__FILE__), 'test_request_helper')
require File.join(File.dirname(__FILE__), 'engine')
require File.join(Fil... | Ruby |
#
# This part contains various test_request helpers for interfacing
# with Grader::Engine. There are TestRequestRoomMaker and
# TestRequestReporter.
module Grader
#
# A TestRequestRoomMaker is a helper object for Engine
# - finds grading room: in user_result_dir/(user)/test_request/ ...
# - prepare problem c... | Ruby |
require 'fileutils'
require 'ftools'
require 'lib/dir_init'
module Grader
#
# A grader engine grades a submission, against anything: a test
# data, or a user submitted test data. It uses two helpers objects:
# room_maker and reporter.
#
class Engine
attr_writer :room_maker
attr_writer :repor... | Ruby |
require 'ftools'
# DirInit::Manager handles directory initialization and clean-up when
# there are many concurrent processes that wants to modify the
# directory in the same way.
#
# An example usage is when each process wants to copy some temporary
# files to the directory and delete these files after finishing its
#... | Ruby |
dir = File.dirname(__FILE__)
Dir[File.expand_path("#{dir}/**/*.rb")].uniq.each do |file|
require file
end | Ruby |
ENV["RAILS_ENV"] = "test"
require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
require 'spec/rails/story_adapter' | Ruby |
class CreateSubmissions < ActiveRecord::Migration
def self.up
create_table :submissions do |t|
t.column :user_id, :integer
t.column :problem_id, :integer
t.column :language_id, :integer
t.column :source, :text
t.column :binary, :binary
t.column :submitted_at, :datetime
t.... | Ruby |
class AddLanguageExt < ActiveRecord::Migration
def self.up
add_column :languages, :ext, :string, :limit => 10
Language.reset_column_information
langs = Language.find(:all)
langs.each do |l|
l.ext = l.name
l.save
end
end
def self.down
remove_column :languages, :ext
end
end
| Ruby |
class AddSessions < ActiveRecord::Migration
def self.up
create_table :sessions do |t|
t.column :session_id, :string
t.column :data, :text
t.column :updated_at, :datetime
end
add_index :sessions, :session_id
add_index :sessions, :updated_at
end
def self.down
drop_table :sess... | Ruby |
class AddSiteToUserAndAddDefaultSite < ActiveRecord::Migration
def self.up
default_site = Site.new({:name => 'default',
:started => false})
default_site.save!
add_column :users, :site_id, :integer
User.reset_column_information
User.find(:all).each do |user|
c... | Ruby |
class AddTimestampsToUsers < ActiveRecord::Migration
def self.up
add_timestamps :users
end
def self.down
remove_timestamps :users
end
end
| Ruby |
class AddAdminEmailToConfig < ActiveRecord::Migration
def self.up
Configuration.create(:key => 'system.admin_email',
:value_type => 'string',
:value => 'admin@admin.email')
end
def self.down
Configuration.find_by_key('system.admin_email').destroy
end
en... | Ruby |
class CreateMessages < ActiveRecord::Migration
def self.up
create_table :messages do |t|
t.column "sender_id", :integer
t.column "receiver_id", :integer
t.column "replying_message_id", :integer
t.column "body", :text
t.column "replied", :boolean # this is for efficiency
... | Ruby |
class AddTitleToAnnouncements < ActiveRecord::Migration
def self.up
add_column :announcements, :title, :string
end
def self.down
remove_column :announcements, :title
end
end
| Ruby |
class AddTaskToGraderProcess < ActiveRecord::Migration
def self.up
add_column :grader_processes, :task_id, :integer
end
def self.down
remove_column :grader_processes, :task_id
end
end
| Ruby |
class ChangeUserLoginStringLimit < ActiveRecord::Migration
def self.up
execute "ALTER TABLE `users` CHANGE `login` `login` VARCHAR( 50 )"
end
def self.down
# don't have to revert
end
end
| Ruby |
class AddContestFlagToAnnouncements < ActiveRecord::Migration
def self.up
add_column :announcements, :contest_only, :boolean, :default => false
end
def self.down
remove_column :announcements, :contest_only
end
end
| Ruby |
class AddRunstatColumnsToTestRequest < ActiveRecord::Migration
def self.up
add_column :test_requests, :running_time, :float
add_column :test_requests, :exit_status, :string
add_column :test_requests, :memory_usage, :integer
end
def self.down
remove_column :test_requests, :running_time
remove_... | Ruby |
class AddStatusToTasks < ActiveRecord::Migration
def self.up
add_column :tasks, :status, :integer
add_column :tasks, :updated_at, :datetime
Task.reset_column_information
Task.find(:all).each do |task|
task.status_complete
task.save
end
end
def self.down
remove_column :tasks, ... | Ruby |
class CreateConfigurations < ActiveRecord::Migration
def self.up
create_table :configurations do |t|
t.column :key, :string
t.column :value_type, :string
t.column :value, :string
t.timestamps
end
Configuration.reset_column_information
Configuration.create(:key => 'system.sing... | Ruby |
class AddCountryToSitesAndUsers < ActiveRecord::Migration
def self.up
add_column 'sites', 'country_id', :integer
add_column 'sites', 'password', :string
add_column 'users', 'country_id', :integer
end
def self.down
remove_column 'users', 'country_id'
remove_column 'sites', 'country_id'
r... | Ruby |
class AddModeToConfigurations < ActiveRecord::Migration
def self.up
# Configuration['system.mode']:
# * 'standard' mode
# * 'contest' mode (check site start time/stop time)
# * 'analysis' mode (show results, no new submissions)
Configuration.create(:key => 'system.mode',
... | Ruby |
class RefactorProblemBodyToDescription < ActiveRecord::Migration
def self.up
add_column :problems, :description_id, :integer
Problem.reset_column_information
Problem.find(:all).each do |problem|
if problem.body!=nil
description = Description.new
description.body = problem.body
... | Ruby |
class ChangeCompilerMessageTypeTestRequest < ActiveRecord::Migration
def self.up
change_column :test_requests, :compiler_message, :text
end
def self.down
change_column :test_requests, :compiler_message, :string
end
end
| Ruby |
class CreateRoles < ActiveRecord::Migration
def self.up
create_table :roles do |t|
t.column 'name', :string
end
create_table :roles_users, :id => false do |t|
t.column 'role_id', :integer
t.column 'user_id', :integer
end
add_index :roles_users, :user_id
end
def self.down
... | Ruby |
class AddFrontpageFlagToAnnouncement < ActiveRecord::Migration
def self.up
add_column :announcements, "frontpage", :boolean, :default => 0
end
def self.down
remove_column :announcements, "frontpage"
end
end
| Ruby |
class AddMoreOptionsToConfigurations < ActiveRecord::Migration
def self.up
# If the server is in contest mode and
# Configuration['contest.multisites'] is true
# the menu for site administrator is shown.
Configuration.create(:key => 'contest.multisites',
:value_type => 'b... | Ruby |
class CreateGraderProcesses < ActiveRecord::Migration
def self.up
create_table :grader_processes do |t|
t.column :ip, :string, :limit => 20
t.column :pid, :integer
t.column :mode, :string
t.column :active, :boolean
t.timestamps
end
add_index :grader_processes, ["ip","pid"]
... | Ruby |
class AddIndexToSubmissions < ActiveRecord::Migration
def self.up
add_index :submissions, [:user_id, :problem_id]
end
def self.down
remove_index :submissions, :column => [:user_id, :problem_id]
end
end
| Ruby |
class CreateDescriptions < ActiveRecord::Migration
def self.up
create_table :descriptions do |t|
t.column :body, :text
t.column :markdowned, :boolean
t.timestamps
end
end
def self.down
drop_table :descriptions
end
end
| Ruby |
class AddUrlToProblem < ActiveRecord::Migration
def self.up
add_column :problems, :url, :string
end
def self.down
remove_column :problems, :url
end
end
| Ruby |
class AddEmailingInfoOnConfigOption < ActiveRecord::Migration
def self.up
# If Configuration['system.online_registration'] is true, the
# system allows online registration, and will use these
# information for sending confirmation emails.
Configuration.create(:key => 'system.online_registration.smtp',... | Ruby |
class CreateRights < ActiveRecord::Migration
def self.up
create_table :rights do |t|
t.column 'name', :string
t.column 'controller', :string
t.column 'action', :string
end
create_table :rights_roles, :id => false do |t|
t.column 'right_id', :integer
t.column 'role_id', :inte... | Ruby |
class AddEmailToUsers < ActiveRecord::Migration
def self.up
add_column :users, :email, :string
end
def self.down
remove_column :users, :email
end
end
| Ruby |
class CreateCountries < ActiveRecord::Migration
def self.up
create_table :countries do |t|
t.column :name, :string
t.timestamps
end
end
def self.down
drop_table :countries
end
end
| Ruby |
class AddActivatedToUsers < ActiveRecord::Migration
def self.up
add_column :users, :activated, :boolean, :default => 0
User.reset_column_information
User.find(:all).each do |user|
# disable validation
class <<user
def valid?
return true
end
end
user.ac... | Ruby |
class AddTerminatedToGraderProcesses < ActiveRecord::Migration
def self.up
add_column :grader_processes, :terminated, :boolean
end
def self.down
remove_column :grader_processes, :terminated
end
end
| Ruby |
class CreateTasks < ActiveRecord::Migration
def self.up
create_table :tasks do |t|
t.column 'submission_id', :integer
t.column 'created_at', :datetime
end
end
def self.down
drop_table :tasks
end
end
| Ruby |
class CreateAnnouncements < ActiveRecord::Migration
def self.up
create_table :announcements do |t|
t.string :author
t.text :body
t.boolean :published
t.timestamps
end
end
def self.down
drop_table :announcements
end
end
| Ruby |
class AddCommonExtToLanguages < ActiveRecord::Migration
def self.up
# language.common_ext is a comma-separated list of common file
# extensions.
add_column :languages, :common_ext, :string
# updating table information
Language.reset_column_information
common_ext = {
'c' => 'c',
'... | Ruby |
class AddGradersRightToAdminRole < ActiveRecord::Migration
def self.up
admin_role = Role.find_by_name('admin')
graders_right = Right.create(:name => 'graders_admin',
:controller => 'graders',
:action => 'all')
admin_role.rights << gra... | Ruby |
class AddTaskTypeToGraderProcesses < ActiveRecord::Migration
def self.up
add_column 'grader_processes', 'task_type', :string
end
def self.down
remove_column 'grader_processes', 'task_type'
end
end
| Ruby |
class AddBodyToProblems < ActiveRecord::Migration
def self.up
add_column :problems, :body, :text
end
def self.down
remove_column :problems, :body
end
end
| Ruby |
class CreateProblems < ActiveRecord::Migration
def self.up
create_table :problems do |t|
t.column :name, :string, :limit => 30
t.column :full_name, :string
t.column :full_score, :integer
t.column :date_added, :date
t.column :available, :boolean
end
end
def self.down
drop... | Ruby |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.