diff --git a/Gemfile b/Gemfile --- a/Gemfile +++ b/Gemfile @@ -41,6 +41,7 @@ gem "rdiscount", :require => "rdiscount" gem "test-unit" gem 'will_paginate', '~> 3.0.0' +gem 'dynamic_form' group :test, :development do gem "rspec-rails", "~> 2.0" diff --git a/Gemfile.lock b/Gemfile.lock --- a/Gemfile.lock +++ b/Gemfile.lock @@ -38,6 +38,7 @@ execjs coffee-script-source (1.3.3) diff-lcs (1.1.3) + dynamic_form (1.1.4) erubis (2.7.0) execjs (1.4.0) multi_json (~> 1.0) @@ -122,6 +123,7 @@ DEPENDENCIES coffee-rails (~> 3.2.1) + dynamic_form haml mysql2 prototype-rails diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -28,7 +28,7 @@ end # check if run in single user mode - if Configuration[SINGLE_USER_MODE_CONF_KEY] + if GraderConfiguration[SINGLE_USER_MODE_CONF_KEY] user = User.find(session[:user_id]) if user==nil or (not user.admin?) flash[:notice] = 'You cannot log in at this time' @@ -38,7 +38,7 @@ return true end - if Configuration.multicontests? + if GraderConfiguration.multicontests? user = User.find(session[:user_id]) return true if user.admin? begin 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 @@ -8,12 +8,12 @@ in_place_edit_for :configuration, :value def index - @configurations = Configuration.find(:all, + @configurations = GraderConfiguration.find(:all, :order => '`key`') end def reload - Configuration.reload + GraderConfiguration.reload redirect_to :action => 'index' 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 @@ -7,7 +7,7 @@ end def user_stat - if not Configuration.indv_contest_mode? + if not GraderConfiguration.indv_contest_mode? redirect_to :action => 'index' and return end @@ -27,7 +27,7 @@ end def clear_all_stat - if not Configuration.indv_contest_mode? + if not GraderConfiguration.indv_contest_mode? redirect_to :action => 'index' and return end @@ -38,7 +38,7 @@ def change_contest_mode if ['standard', 'contest', 'indv-contest'].include? params[:id] - config = Configuration.find_by_key('system.mode') + config = GraderConfiguration.find_by_key('system.mode') config.value = params[:id] config.save else diff --git a/app/controllers/login_controller.rb b/app/controllers/login_controller.rb --- a/app/controllers/login_controller.rb +++ b/app/controllers/login_controller.rb @@ -12,7 +12,7 @@ session[:admin] = user.admin? # clear forced logout flag for multicontests contest change - if Configuration.multicontests? + if GraderConfiguration.multicontests? contest_stat = user.contest_stat if contest_stat.respond_to? :forced_logout if contest_stat.forced_logout 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 @@ -38,7 +38,7 @@ # explicitly specify /login # # logger.info "PATH: #{request.path}" - # if Configuration['system.single_user_mode'] and + # if GraderConfiguration['system.single_user_mode'] and # request.path!='/main/login' # @hidelogin = true # end @@ -67,7 +67,7 @@ end @submission.submitted_at = Time.new.gmtime - if Configuration.time_limit_mode? and user.contest_finished? + if GraderConfiguration.time_limit_mode? and user.contest_finished? @submission.errors.add_to_base "The contest is over." prepare_list_information render :action => 'list' and return @@ -129,7 +129,7 @@ end def result - if !Configuration.show_grading_result + if !GraderConfiguration.show_grading_result redirect_to :action => 'list' and return end @user = User.find(session[:user_id]) @@ -142,7 +142,7 @@ end def load_output - if !Configuration.show_grading_result or params[:num]==nil + if !GraderConfiguration.show_grading_result or params[:num]==nil redirect_to :action => 'list' and return end @user = User.find(session[:user_id]) @@ -203,7 +203,7 @@ protected def prepare_announcements(recent=nil) - if Configuration.show_tasks_to?(@user) + if GraderConfiguration.show_tasks_to?(@user) @announcements = Announcement.find_published(true) else @announcements = Announcement.find_published @@ -216,7 +216,7 @@ def prepare_list_information @user = User.find(session[:user_id]) - if not Configuration.multicontests? + if not GraderConfiguration.multicontests? @problems = @user.available_problems else @contest_problems = @user.available_problems_group_by_contests @@ -236,15 +236,15 @@ def check_viewability @user = User.find(session[:user_id]) - if (!Configuration.show_tasks_to?(@user)) and + if (!GraderConfiguration.show_tasks_to?(@user)) and ((action_name=='submission') or (action_name=='submit')) redirect_to :action => 'list' and return end end def prepare_grading_result(submission) - if Configuration.task_grading_info.has_key? submission.problem.name - grading_info = Configuration.task_grading_info[submission.problem.name] + if GraderConfiguration.task_grading_info.has_key? submission.problem.name + grading_info = GraderConfiguration.task_grading_info[submission.problem.name] else # guess task info from problem.full_score cases = submission.problem.full_score / 10 @@ -353,12 +353,12 @@ def confirm_and_update_start_time user = User.find(session[:user_id]) - if (Configuration.indv_contest_mode? and - Configuration['contest.confirm_indv_contest_start'] and + if (GraderConfiguration.indv_contest_mode? and + GraderConfiguration['contest.confirm_indv_contest_start'] and !user.contest_started?) redirect_to :action => 'confirm_contest_start' and return end - if not Configuration.analysis_mode? + if not GraderConfiguration.analysis_mode? user.update_start_time end end @@ -368,7 +368,7 @@ render :text => 'Access forbidden', :status => 403 end - if Configuration.multicontests? + if GraderConfiguration.multicontests? user = User.find(session[:user_id]) if user.contest_stat.forced_logout render :text => 'Access forbidden', :status => 403 diff --git a/app/controllers/site_controller.rb b/app/controllers/site_controller.rb --- a/app/controllers/site_controller.rb +++ b/app/controllers/site_controller.rb @@ -19,7 +19,7 @@ end end - @default_site = Site.first if !Configuration['contest.multisites'] + @default_site = Site.first if !GraderConfiguration['contest.multisites'] render :action => 'login', :layout => 'empty' end diff --git a/app/controllers/tasks_controller.rb b/app/controllers/tasks_controller.rb --- a/app/controllers/tasks_controller.rb +++ b/app/controllers/tasks_controller.rb @@ -66,7 +66,7 @@ def check_viewability @user = User.find(session[:user_id]) - if @user==nil or !Configuration.show_tasks_to?(@user) + if @user==nil or !GraderConfiguration.show_tasks_to?(@user) redirect_to :controller => 'main', :action => 'list' return false end 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 @@ -24,14 +24,14 @@ render :action => 'index' and return end - if Configuration.time_limit_mode? + if GraderConfiguration.time_limit_mode? if @user.contest_finished? @submitted_test_request.errors.add_to_base('Contest is over.') prepare_index_information render :action => 'index' and return end - if !Configuration.allow_test_request(@user) + if !GraderConfiguration.allow_test_request(@user) prepare_index_information flash[:notice] = 'Test request is not allowed during the last 30 minutes' redirect_to :action => 'index' and return @@ -107,10 +107,10 @@ def check_viewability user = User.find(session[:user_id]) - if !Configuration.show_tasks_to?(user) + if !GraderConfiguration.show_tasks_to?(user) redirect_to :controller => 'main', :action => 'list' end - if (!Configuration.show_submitbox_to?(user)) and (action_name=='submit') + if (!GraderConfiguration.show_submitbox_to?(user)) and (action_name=='submit') redirect_to :controller => 'test', :action => 'index' end 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 @@ -1,14 +1,9 @@ class UserAdminController < ApplicationController - include MailHelperMethods + #include MailHelperMethods 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, :create_from_list, @@ -18,6 +13,11 @@ ], :redirect_to => { :action => :list } + def index + list + render :action => 'list' + end + def list @user_count = User.count if params[:page] == 'all' @@ -424,7 +424,7 @@ end def send_contest_update_notification_email(user, contest) - contest_title_name = Configuration['contest.name'] + contest_title_name = GraderConfiguration['contest.name'] contest_name = contest.name subject = t('contest.notification.email_subject', { :contest_title_name => contest_title_name, 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 @@ -3,7 +3,7 @@ class UsersController < ApplicationController - include MailHelperMethods + #include MailHelperMethods before_filter :authenticate, :except => [:new, :register, @@ -23,7 +23,7 @@ #in_place_edit_for :user, :email_for_editing def index - if !Configuration['system.user_setting_enabled'] + if !GraderConfiguration['system.user_setting_enabled'] redirect_to :controller => 'main', :action => 'list' else @user = User.find(session[:user_id]) @@ -59,7 +59,7 @@ if send_confirmation_email(@user) render :action => 'new_splash', :layout => 'empty' else - @admin_email = Configuration['system.admin_email'] + @admin_email = GraderConfiguration['system.admin_email'] render :action => 'email_error', :layout => 'empty' end else @@ -112,14 +112,14 @@ protected def verify_online_registration - if !Configuration['system.online_registration'] + if !GraderConfiguration['system.online_registration'] redirect_to :controller => 'main', :action => 'login' end end def send_confirmation_email(user) - contest_name = Configuration['contest.name'] - admin_email = Configuration['system.admin_email'] + contest_name = GraderConfiguration['contest.name'] + admin_email = GraderConfiguration['system.admin_email'] activation_url = url_for(:action => 'confirm', :login => user.login, :activation => user.activation_key) @@ -140,8 +140,8 @@ end def send_new_password_email(user) - contest_name = Configuration['contest.name'] - admin_email = Configuration['system.admin_email'] + contest_name = GraderConfiguration['contest.name'] + admin_email = GraderConfiguration['system.admin_email'] subject = "[#{contest_name}] Password recovery" body = t('registration.password_retrieval.email_body', { :full_name => user.full_name, 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 @@ -24,19 +24,19 @@ append_to menu_items, "[#{I18n.t 'menu.main'}]", 'main', 'list' append_to menu_items, "[#{I18n.t 'menu.messages'}]", 'messages', 'list' - if (user!=nil) and (Configuration.show_tasks_to?(user)) + if (user!=nil) and (GraderConfiguration.show_tasks_to?(user)) append_to menu_items, "[#{I18n.t 'menu.tasks'}]", 'tasks', 'list' append_to menu_items, "[#{I18n.t 'menu.submissions'}]", 'main', 'submission' append_to menu_items, "[#{I18n.t 'menu.test'}]", 'test', 'index' end append_to menu_items, "[#{I18n.t 'menu.help'}]", 'main', 'help' - if Configuration['system.user_setting_enabled'] + if GraderConfiguration['system.user_setting_enabled'] append_to menu_items, "[#{I18n.t 'menu.settings'}]", 'users', 'index' end append_to menu_items, "[#{I18n.t 'menu.log_out'}]", 'main', 'login' - menu_items + menu_items.html_safe end def append_to(option,label, controller, action) @@ -76,7 +76,7 @@ # # if the contest is over - if Configuration.time_limit_mode? + if GraderConfiguration.time_limit_mode? if user.contest_finished? header = < @@ -94,7 +94,7 @@ # # if the contest is in the anaysis mode - if Configuration.analysis_mode? + if GraderConfiguration.analysis_mode? header = < ANALYSIS MODE @@ -102,11 +102,11 @@ ANALYSISMODE end - contest_name = Configuration['contest.name'] + contest_name = GraderConfiguration['contest.name'] # # build real title bar - < #{header} @@ -122,6 +122,7 @@
TITLEBAR + result.html_safe end end diff --git a/app/models/configuration.rb b/app/models/configuration.rb deleted file mode 100644 --- a/app/models/configuration.rb +++ /dev/null @@ -1,176 +0,0 @@ -require 'yaml' - -# -# This class also contains various login of the system. -# -class Configuration < ActiveRecord::Base - - SYSTEM_MODE_CONF_KEY = 'system.mode' - TEST_REQUEST_EARLY_TIMEOUT_KEY = 'contest.test_request.early_timeout' - MULTICONTESTS_KEY = 'system.multicontests' - CONTEST_TIME_LIMIT_KEY = 'contest.time_limit' - - cattr_accessor :config_cache - cattr_accessor :task_grading_info_cache - cattr_accessor :contest_time_str - cattr_accessor :contest_time - - Configuration.config_cache = nil - Configuration.task_grading_info_cache = nil - - def self.config_cached? - (defined? CONFIGURATION_CACHE_ENABLED) and (CONFIGURATION_CACHE_ENABLED) - end - - def self.get(key) - if Configuration.config_cached? - if Configuration.config_cache == nil - self.read_config - end - return Configuration.config_cache[key] - else - return Configuration.read_one_key(key) - end - end - - def self.[](key) - self.get(key) - end - - def self.reload - self.read_config - end - - def self.clear - Configuration.config_cache = nil - end - - # - # View decision - # - def self.show_submitbox_to?(user) - mode = get(SYSTEM_MODE_CONF_KEY) - return false if mode=='analysis' - if (mode=='contest') - return false if (user.site!=nil) and - ((user.site.started!=true) or (user.site.finished?)) - end - return true - end - - def self.show_tasks_to?(user) - if time_limit_mode? - return false if not user.contest_started? - end - return true - end - - def self.show_grading_result - return (get(SYSTEM_MODE_CONF_KEY)=='analysis') - end - - def self.allow_test_request(user) - mode = get(SYSTEM_MODE_CONF_KEY) - early_timeout = get(TEST_REQUEST_EARLY_TIMEOUT_KEY) - if (mode=='contest') - return false if ((user.site!=nil) and - ((user.site.started!=true) or - (early_timeout and (user.site.time_left < 30.minutes)))) - end - return false if mode=='analysis' - return true - end - - def self.task_grading_info - if Configuration.task_grading_info_cache==nil - read_grading_info - end - return Configuration.task_grading_info_cache - end - - def self.standard_mode? - return get(SYSTEM_MODE_CONF_KEY) == 'standard' - end - - def self.contest_mode? - return get(SYSTEM_MODE_CONF_KEY) == 'contest' - end - - def self.indv_contest_mode? - return get(SYSTEM_MODE_CONF_KEY) == 'indv-contest' - end - - def self.multicontests? - return get(MULTICONTESTS_KEY) == true - end - - def self.time_limit_mode? - mode = get(SYSTEM_MODE_CONF_KEY) - return ((mode == 'contest') or (mode == 'indv-contest')) - end - - def self.analysis_mode? - return get(SYSTEM_MODE_CONF_KEY) == 'analysis' - end - - def self.contest_time_limit - contest_time_str = Configuration[CONTEST_TIME_LIMIT_KEY] - - if not defined? Configuration.contest_time_str - Configuration.contest_time_str = nil - end - - if Configuration.contest_time_str != contest_time_str - Configuration.contest_time_str = contest_time_str - if tmatch = /(\d+):(\d+)/.match(contest_time_str) - h = tmatch[1].to_i - m = tmatch[2].to_i - - Configuration.contest_time = h.hour + m.minute - else - Configuration.contest_time = nil - end - end - return Configuration.contest_time - end - - protected - - def self.convert_type(val,type) - case type - when 'string' - return val - - when 'integer' - return val.to_i - - when 'boolean' - return (val=='true') - end - end - - def self.read_config - Configuration.config_cache = {} - Configuration.find(:all).each do |conf| - key = conf.key - val = conf.value - Configuration.config_cache[key] = Configuration.convert_type(val,conf.value_type) - end - end - - def self.read_one_key(key) - conf = Configuration.find_by_key(key) - if conf - return Configuration.convert_type(conf.value,conf.value_type) - else - return nil - end - end - - def self.read_grading_info - f = File.open(TASK_GRADING_INFO_FILENAME) - Configuration.task_grading_info_cache = YAML.load(f) - f.close - end - -end diff --git a/app/models/grader_configuration.rb b/app/models/grader_configuration.rb new file mode 100644 --- /dev/null +++ b/app/models/grader_configuration.rb @@ -0,0 +1,176 @@ +require 'yaml' + +# +# This class also contains various login of the system. +# +class GraderConfiguration < ActiveRecord::Base + + SYSTEM_MODE_CONF_KEY = 'system.mode' + TEST_REQUEST_EARLY_TIMEOUT_KEY = 'contest.test_request.early_timeout' + MULTICONTESTS_KEY = 'system.multicontests' + CONTEST_TIME_LIMIT_KEY = 'contest.time_limit' + + cattr_accessor :config_cache + cattr_accessor :task_grading_info_cache + cattr_accessor :contest_time_str + cattr_accessor :contest_time + + GraderConfiguration.config_cache = nil + GraderConfiguration.task_grading_info_cache = nil + + def self.config_cached? + (defined? CONFIGURATION_CACHE_ENABLED) and (CONFIGURATION_CACHE_ENABLED) + end + + def self.get(key) + if GraderConfiguration.config_cached? + if GraderConfiguration.config_cache == nil + self.read_config + end + return GraderConfiguration.config_cache[key] + else + return GraderConfiguration.read_one_key(key) + end + end + + def self.[](key) + self.get(key) + end + + def self.reload + self.read_config + end + + def self.clear + GraderConfiguration.config_cache = nil + end + + # + # View decision + # + def self.show_submitbox_to?(user) + mode = get(SYSTEM_MODE_CONF_KEY) + return false if mode=='analysis' + if (mode=='contest') + return false if (user.site!=nil) and + ((user.site.started!=true) or (user.site.finished?)) + end + return true + end + + def self.show_tasks_to?(user) + if time_limit_mode? + return false if not user.contest_started? + end + return true + end + + def self.show_grading_result + return (get(SYSTEM_MODE_CONF_KEY)=='analysis') + end + + def self.allow_test_request(user) + mode = get(SYSTEM_MODE_CONF_KEY) + early_timeout = get(TEST_REQUEST_EARLY_TIMEOUT_KEY) + if (mode=='contest') + return false if ((user.site!=nil) and + ((user.site.started!=true) or + (early_timeout and (user.site.time_left < 30.minutes)))) + end + return false if mode=='analysis' + return true + end + + def self.task_grading_info + if GraderConfiguration.task_grading_info_cache==nil + read_grading_info + end + return GraderConfiguration.task_grading_info_cache + end + + def self.standard_mode? + return get(SYSTEM_MODE_CONF_KEY) == 'standard' + end + + def self.contest_mode? + return get(SYSTEM_MODE_CONF_KEY) == 'contest' + end + + def self.indv_contest_mode? + return get(SYSTEM_MODE_CONF_KEY) == 'indv-contest' + end + + def self.multicontests? + return get(MULTICONTESTS_KEY) == true + end + + def self.time_limit_mode? + mode = get(SYSTEM_MODE_CONF_KEY) + return ((mode == 'contest') or (mode == 'indv-contest')) + end + + def self.analysis_mode? + return get(SYSTEM_MODE_CONF_KEY) == 'analysis' + end + + def self.contest_time_limit + contest_time_str = GraderConfiguration[CONTEST_TIME_LIMIT_KEY] + + if not defined? GraderConfiguration.contest_time_str + GraderConfiguration.contest_time_str = nil + end + + if GraderConfiguration.contest_time_str != contest_time_str + GraderConfiguration.contest_time_str = contest_time_str + if tmatch = /(\d+):(\d+)/.match(contest_time_str) + h = tmatch[1].to_i + m = tmatch[2].to_i + + GraderConfiguration.contest_time = h.hour + m.minute + else + GraderConfiguration.contest_time = nil + end + end + return GraderConfiguration.contest_time + end + + protected + + def self.convert_type(val,type) + case type + when 'string' + return val + + when 'integer' + return val.to_i + + when 'boolean' + return (val=='true') + end + end + + def self.read_config + GraderConfiguration.config_cache = {} + GraderConfiguration.find(:all).each do |conf| + key = conf.key + val = conf.value + GraderConfiguration.config_cache[key] = GraderConfiguration.convert_type(val,conf.value_type) + end + end + + def self.read_one_key(key) + conf = GraderConfiguration.find_by_key(key) + if conf + return GraderConfiguration.convert_type(conf.value,conf.value_type) + else + return nil + end + end + + def self.read_grading_info + f = File.open(TASK_GRADING_INFO_FILENAME) + GraderConfiguration.task_grading_info_cache = YAML.load(f) + f.close + end + +end diff --git a/app/models/site.rb b/app/models/site.rb --- a/app/models/site.rb +++ b/app/models/site.rb @@ -10,7 +10,7 @@ end def time_left - contest_time = Configuration.contest_time_limit + contest_time = GraderConfiguration.contest_time_limit return nil if contest_time == nil @@ -35,7 +35,7 @@ return false end - contest_time = Configuration.contest_time_limit + contest_time = GraderConfiguration.contest_time_limit if contest_time!=nil return Time.now.gmtime > (self.start_time + contest_time) else diff --git a/app/models/user.rb b/app/models/user.rb --- a/app/models/user.rb +++ b/app/models/user.rb @@ -136,11 +136,11 @@ def contest_time_left - if Configuration.contest_mode? + if GraderConfiguration.contest_mode? return nil if site==nil return site.time_left - elsif Configuration.indv_contest_mode? - time_limit = Configuration.contest_time_limit + elsif GraderConfiguration.indv_contest_mode? + time_limit = GraderConfiguration.contest_time_limit if time_limit == nil return nil end @@ -161,10 +161,10 @@ end def contest_finished? - if Configuration.contest_mode? + if GraderConfiguration.contest_mode? return false if site==nil return site.finished? - elsif Configuration.indv_contest_mode? + elsif GraderConfiguration.indv_contest_mode? return false if self.contest_stat(true)==nil return contest_time_left == 0 else @@ -173,10 +173,10 @@ end def contest_started? - if Configuration.indv_contest_mode? + if GraderConfiguration.indv_contest_mode? stat = self.contest_stat return ((stat != nil) and (stat.started_at != nil)) - elsif Configuration.contest_mode? + elsif GraderConfiguration.contest_mode? return true if site==nil return site.started else @@ -228,7 +228,7 @@ end def available_problems - if not Configuration.multicontests? + if not GraderConfiguration.multicontests? return Problem.find_available_problems else contest_problems = [] @@ -247,7 +247,7 @@ end def can_view_problem?(problem) - if not Configuration.multicontests? + if not GraderConfiguration.multicontests? return problem.available else return problem_in_user_contests? problem @@ -278,7 +278,7 @@ # have to catch error when migrating (because self.site is not available). begin if self.contests.length == 0 - default_contest = Contest.find_by_name(Configuration['contest.default_contest_name']) + default_contest = Contest.find_by_name(GraderConfiguration['contest.default_contest_name']) if default_contest self.contests = [default_contest] end diff --git a/app/views/configurations/index.html.haml b/app/views/configurations/index.html.haml --- a/app/views/configurations/index.html.haml +++ b/app/views/configurations/index.html.haml @@ -20,7 +20,7 @@ = in_place_editor_field :configuration, :value, {}, :rows=>1 %td= conf.description -- if Configuration.config_cached? +- if GraderConfiguration.config_cached? %br/ Your config is saved, but it does not automatically take effect. %br/ diff --git a/app/views/contest_management/index.html.haml b/app/views/contest_management/index.html.haml --- a/app/views/contest_management/index.html.haml +++ b/app/views/contest_management/index.html.haml @@ -11,9 +11,9 @@ .infobox %b Web interface mode: - - if (not Configuration.contest_mode?) and (not Configuration.indv_contest_mode?) + - if (not GraderConfiguration.contest_mode?) and (not GraderConfiguration.indv_contest_mode?) standard mode - - elsif Configuration.contest_mode? + - elsif GraderConfiguration.contest_mode? normal contest mode. - else individual contest mode. @@ -24,7 +24,7 @@ = "[#{link_to 'contest', :action => 'change_contest_mode', :id => 'contest'}]" = "[#{link_to 'individual contest', :action => 'change_contest_mode', :id => 'indv-contest'}]" -- if Configuration.indv_contest_mode? +- if GraderConfiguration.indv_contest_mode? = render :partial => 'indv_contest_mode_index' %br/ diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -1,13 +1,20 @@ - CafeGraderWeb - <%= stylesheet_link_tag "application", :media => "all" %> + <%= GraderConfiguration['contest.name'] %> + <%= stylesheet_link_tag "application", :media => "all" %> <%= javascript_include_tag "application" %> <%= csrf_meta_tags %> + <%= yield :head %> +
+<%= user_header %> +
+ +<%= content_tag(:p,flash[:notice],:style => "color:green") if flash[:notice]!=nil %> + <%= yield %> diff --git a/app/views/layouts/empty.html.erb b/app/views/layouts/empty.html.erb --- a/app/views/layouts/empty.html.erb +++ b/app/views/layouts/empty.html.erb @@ -4,7 +4,7 @@ - <%= Configuration['contest.name'] %> + <%= GraderConfiguration['contest.name'] %> <%= stylesheet_link_tag 'application' %> diff --git a/app/views/main/_login_box.html.haml b/app/views/main/_login_box.html.haml --- a/app/views/main/_login_box.html.haml +++ b/app/views/main/_login_box.html.haml @@ -1,4 +1,4 @@ -%b= Configuration['ui.front.welcome_message'] +%b= GraderConfiguration['ui.front.welcome_message'] %br/ - if !@hidelogin @@ -25,7 +25,7 @@ = submit_tag t('login.login_submit') %br/ -- if Configuration['system.online_registration'] +- if GraderConfiguration['system.online_registration'] =t 'login.participation' %b = "#{t 'login.please'} " diff --git a/app/views/main/_submission.html.haml b/app/views/main/_submission.html.haml --- a/app/views/main/_submission.html.haml +++ b/app/views/main/_submission.html.haml @@ -9,7 +9,7 @@ - if submission.graded_at!=nil = "Graded at #{format_short_time(submission.graded_at)}." %br/ - = "Score: #{(submission.points*100/submission.problem.full_score).to_i} " if Configuration['ui.show_score'] + = "Score: #{(submission.points*100/submission.problem.full_score).to_i} " if GraderConfiguration['ui.show_score'] = " [" %tt = submission.grader_comment diff --git a/app/views/main/_submission_short.html.haml b/app/views/main/_submission_short.html.haml --- a/app/views/main/_submission_short.html.haml +++ b/app/views/main/_submission_short.html.haml @@ -8,14 +8,14 @@ - else = t 'main.graded_at' = "#{format_short_time(submission.graded_at.localtime)}, " - - if Configuration['ui.show_score'] + - if GraderConfiguration['ui.show_score'] = t 'main.score' = "#{(submission.points*100/submission.problem.full_score).to_i} " = " [" %tt = submission.grader_comment = "]" - - if Configuration.show_grading_result + - if GraderConfiguration.show_grading_result = " | " = link_to '[detailed result]', :action => 'result', :id => submission.id = " | " diff --git a/app/views/main/help.html.haml b/app/views/main/help.html.haml --- a/app/views/main/help.html.haml +++ b/app/views/main/help.html.haml @@ -2,13 +2,13 @@ .announcementbox %span{:class => 'title'} - =t 'help.how_to_submit' + =raw t 'help.how_to_submit' .announcement %p - =t 'help.must_specify_language' + =raw t 'help.must_specify_language' %p - =t 'help.list_available_language' + =raw t 'help.list_available_language' %table{:border => '1'} %tr @@ -16,18 +16,18 @@ %th{:width => '150px'} C++ %th{:width => '150px'} Pascal %tr - %td= "/*
LANG: C
*/
" - %td= "/*
LANG: C++
*/
" - %td= "{
LANG: Pascal
}
" + %td=raw "/*
LANG: C
*/
" + %td=raw "/*
LANG: C++
*/
" + %td=raw "{
LANG: Pascal
}
" %p - =t 'help.accept_only_language_specified' + =raw t 'help.accept_only_language_specified' %p - =t 'help.specifying_task' + =raw t 'help.specifying_task' %p - =t 'help.example_cpp' + =raw t 'help.example_cpp' %table{:border => '1'} %tr @@ -35,7 +35,7 @@ %tt /*
LANG: C++
TASK: mobiles
*/
%p - =t 'help.example_pas' + =raw t 'help.example_pas' %table{:border => '1'} %tr @@ -43,5 +43,5 @@ %tt {
LANG: Pascal
TASK: mobiles
}
%p - = (t('help.ask_questions_at_messages',:message_link_name => (t 'menu.messages'),:url => url_for(:controller => 'messages', :action => 'list'))) + = raw(t('help.ask_questions_at_messages',:message_link_name => (t 'menu.messages'),:url => url_for(:controller => 'messages', :action => 'list'))) diff --git a/app/views/main/list.html.haml b/app/views/main/list.html.haml --- a/app/views/main/list.html.haml +++ b/app/views/main/list.html.haml @@ -10,7 +10,7 @@ #announcementbox-body = render :partial => 'announcement', :collection => @announcements -- if Configuration.show_submitbox_to?(@user) +- if GraderConfiguration.show_submitbox_to?(@user) .submitbox = error_messages_for 'submission' = render :partial => 'submission_box' @@ -18,11 +18,11 @@ %hr/ -- if (Configuration.contest_mode?) and (@user.site!=nil) and (@user.site.started!=true) +- if (GraderConfiguration.contest_mode?) and (@user.site!=nil) and (@user.site.started!=true) %p=t 'main.start_soon' -- if Configuration.show_tasks_to?(@user) - - if not Configuration.multicontests? +- if GraderConfiguration.show_tasks_to?(@user) + - if not GraderConfiguration.multicontests? %table.info %tr.info-head %th diff --git a/app/views/main/login.html.haml b/app/views/main/login.html.haml --- a/app/views/main/login.html.haml +++ b/app/views/main/login.html.haml @@ -1,4 +1,4 @@ -%h1= Configuration['ui.front.title'] +%h1= GraderConfiguration['ui.front.title'] %table %tr diff --git a/app/views/main/result.html.haml b/app/views/main/result.html.haml --- a/app/views/main/result.html.haml +++ b/app/views/main/result.html.haml @@ -11,7 +11,7 @@ %br/ = "Graded at #{format_short_time(@submission.graded_at)} " %br/ - = "score: #{(@submission.points*100/@submission.problem.full_score).to_i} " if Configuration['ui.show_score'] + = "score: #{(@submission.points*100/@submission.problem.full_score).to_i} " if GraderConfiguration['ui.show_score'] = " [" %tt = @submission.grader_comment diff --git a/app/views/problems/_form.html.erb b/app/views/problems/_form.html.erb new file mode 100644 --- /dev/null +++ b/app/views/problems/_form.html.erb @@ -0,0 +1,52 @@ +<%= error_messages_for 'problem' %> + + +


+<%= text_field 'problem', 'name' %>

+ +


+<%= text_field 'problem', 'full_name' %>

+ +


+<%= text_field 'problem', 'full_score' %>

+ +


+<%= date_select 'problem', 'date_added' %>

+ +<% +# TODO: these should be put in model Problem, but I can't think of +# nice default values for them. These values look fine only +# in this case (of lazily adding new problems). +@problem.available = true if @problem!=nil and @problem.available==nil +@problem.test_allowed = true if @problem!=nil and @problem.test_allowed==nil +@problem.output_only = false if @problem!=nil and @problem.output_only==nil +%> + +

+ +<%= check_box :problem, :available %> + + +<%= check_box :problem, :test_allowed %> + + +<%= check_box :problem, :output_only %> +

+ +<%= error_messages_for 'description' %> + +


+<%= text_area :description, :body, :rows => 10, :cols => 80 %>

+ +

+<%= select "description", + "markdowned", + [['True',true],['False',false]], + {:selected => (@description) ? @description.markdowned : false } +%>

+ +


+<%= text_field 'problem', 'url' %>

+ + + diff --git a/app/views/problems/_form.rhtml b/app/views/problems/_form.rhtml deleted file mode 100644 --- a/app/views/problems/_form.rhtml +++ /dev/null @@ -1,52 +0,0 @@ -<%= error_messages_for 'problem' %> - - -


-<%= text_field 'problem', 'name' %>

- -


-<%= text_field 'problem', 'full_name' %>

- -


-<%= text_field 'problem', 'full_score' %>

- -


-<%= date_select 'problem', 'date_added' %>

- -<% -# TODO: these should be put in model Problem, but I can't think of -# nice default values for them. These values look fine only -# in this case (of lazily adding new problems). -@problem.available = true if @problem!=nil and @problem.available==nil -@problem.test_allowed = true if @problem!=nil and @problem.test_allowed==nil -@problem.output_only = false if @problem!=nil and @problem.output_only==nil -%> - -

- -<%= check_box :problem, :available %> - - -<%= check_box :problem, :test_allowed %> - - -<%= check_box :problem, :output_only %> -

- -<%= error_messages_for 'description' %> - -


-<%= text_area :description, :body, :rows => 10, :cols => 80 %>

- -

-<%= select "description", - "markdowned", - [['True',true],['False',false]], - {:selected => (@description) ? @description.markdowned : false } -%>

- -


-<%= text_field 'problem', 'url' %>

- - - diff --git a/app/views/problems/edit.html.erb b/app/views/problems/edit.html.erb new file mode 100644 --- /dev/null +++ b/app/views/problems/edit.html.erb @@ -0,0 +1,9 @@ +

Editing problem

+ +<%= form_tag :action => 'update', :id => @problem do %> + <%= render :partial => 'form' %> + <%= submit_tag 'Edit' %> +<% end %> + +<%= link_to 'Show', :action => 'show', :id => @problem %> | +<%= link_to 'Back', :action => 'list' %> diff --git a/app/views/problems/edit.rhtml b/app/views/problems/edit.rhtml deleted file mode 100644 --- a/app/views/problems/edit.rhtml +++ /dev/null @@ -1,9 +0,0 @@ -

Editing problem

- -<%= form_tag :action => 'update', :id => @problem do %> - <%= render :partial => 'form' %> - <%= submit_tag 'Edit' %> -<% end %> - -<%= link_to 'Show', :action => 'show', :id => @problem %> | -<%= link_to 'Back', :action => 'list' %> diff --git a/app/views/problems/list.html.erb b/app/views/problems/list.html.erb new file mode 100644 --- /dev/null +++ b/app/views/problems/list.html.erb @@ -0,0 +1,67 @@ +<% content_for :head do %> + <%= stylesheet_link_tag 'problems' %> + <%= javascript_include_tag :defaults %> +<% end %> + +

Listing problems

+ +

+<%= link_to '[New problem]', :action => 'new' %> +<%= link_to '[Manage problems]', :action => 'manage' %> +<%= link_to '[Import problems]', :action => 'import' %> +<%= link_to '[Turn off all problems]', :action => 'turn_all_off' %> +<%= link_to '[Turn on all problems]', :action => 'turn_all_on' %> +

+ +
+ <%= form_tag :action => 'quick_create' do %> + Quick New: + + <%= text_field 'problem', 'name' %> | + + <%= text_field 'problem', 'full_name' %> + <%= submit_tag "Create" %> + <% end %> +
+ + + + + + + + + + <% if GraderConfiguration.multicontests? %> + + <% end %> + + +<% for problem in @problems %> + "> + <% @problem=problem %> + + + + + + + + <% if GraderConfiguration.multicontests? %> + + <% end %> + + + + + + + +<% end %> +
NameFull nameFull scoreDate addedAvail?Test?Contests
<%= in_place_editor_field :problem, :name, {}, :rows=>1 %><%= in_place_editor_field :problem, :full_name, {}, :rows=>1 %><%= in_place_editor_field :problem, :full_score, {}, :rows=>1 %><%= problem.date_added %><%= problem.available %><%= problem.test_allowed %> + <%= problem.contests.collect { |c| c.name }.join(', ') %> + <%= link_to_remote '[Toggle]', :url => {:action => 'toggle', :id => problem.id } %><%= link_to '[Stat]', :action => 'stat', :id => problem.id %><%= link_to '[Show]', :action => 'show', :id => problem %><%= link_to '[Edit]', :action => 'edit', :id => problem %><%= link_to '[Destroy]', { :action => 'destroy', :id => problem }, :confirm => 'Are you sure?', :method => :post %>
+ +
+ +<%= link_to '[New problem]', :action => 'new' %> diff --git a/app/views/problems/list.rhtml b/app/views/problems/list.rhtml deleted file mode 100644 --- a/app/views/problems/list.rhtml +++ /dev/null @@ -1,67 +0,0 @@ -<% content_for :head do %> - <%= stylesheet_link_tag 'problems' %> - <%= javascript_include_tag :defaults %> -<% end %> - -

Listing problems

- -

-<%= link_to '[New problem]', :action => 'new' %> -<%= link_to '[Manage problems]', :action => 'manage' %> -<%= link_to '[Import problems]', :action => 'import' %> -<%= link_to '[Turn off all problems]', :action => 'turn_all_off' %> -<%= link_to '[Turn on all problems]', :action => 'turn_all_on' %> -

- -
- <%= form_tag :action => 'quick_create' do %> - Quick New: - - <%= text_field 'problem', 'name' %> | - - <%= text_field 'problem', 'full_name' %> - <%= submit_tag "Create" %> - <% end %> -
- - - - - - - - - - <% if Configuration.multicontests? %> - - <% end %> - - -<% for problem in @problems %> - "> - <% @problem=problem %> - - - - - - - - <% if Configuration.multicontests? %> - - <% end %> - - - - - - - -<% end %> -
NameFull nameFull scoreDate addedAvail?Test?Contests
<%= in_place_editor_field :problem, :name, {}, :rows=>1 %><%= in_place_editor_field :problem, :full_name, {}, :rows=>1 %><%= in_place_editor_field :problem, :full_score, {}, :rows=>1 %><%= problem.date_added %><%= problem.available %><%= problem.test_allowed %> - <%= problem.contests.collect { |c| c.name }.join(', ') %> - <%= link_to_remote '[Toggle]', :url => {:action => 'toggle', :id => problem.id } %><%= link_to '[Stat]', :action => 'stat', :id => problem.id %><%= link_to '[Show]', :action => 'show', :id => problem %><%= link_to '[Edit]', :action => 'edit', :id => problem %><%= link_to '[Destroy]', { :action => 'destroy', :id => problem }, :confirm => 'Are you sure?', :method => :post %>
- -
- -<%= link_to '[New problem]', :action => 'new' %> diff --git a/app/views/problems/manage.html.haml b/app/views/problems/manage.html.haml --- a/app/views/problems/manage.html.haml +++ b/app/views/problems/manage.html.haml @@ -17,7 +17,7 @@     = submit_tag 'Change', :name => 'change_date_added' - - if Configuration.multicontests? + - if GraderConfiguration.multicontests? %li Add to = select("contest","id",Contest.all.collect {|c| [c.title, c.id]}) @@ -29,7 +29,7 @@ %th Name %th Full name %th Date added - - if Configuration.multicontests? + - if GraderConfiguration.multicontests? %th Contests - for problem in @problems @@ -38,7 +38,7 @@ %td= problem.name %td= problem.full_name %td= problem.date_added - - if Configuration.multicontests? + - if GraderConfiguration.multicontests? %td - problem.contests.each do |contest| = "(#{contest.name} [#{link_to 'x', :action => 'remove_contest', :id => problem.id, :contest_id => contest.id }])" diff --git a/app/views/problems/new.html.erb b/app/views/problems/new.html.erb new file mode 100644 --- /dev/null +++ b/app/views/problems/new.html.erb @@ -0,0 +1,8 @@ +

New problem

+ +<%= form_tag :action => 'create' do %> + <%= render :partial => 'form' %> + <%= submit_tag "Create" %> +<% end %> + +<%= link_to 'Back', :action => 'list' %> diff --git a/app/views/problems/new.rhtml b/app/views/problems/new.rhtml deleted file mode 100644 --- a/app/views/problems/new.rhtml +++ /dev/null @@ -1,8 +0,0 @@ -

New problem

- -<%= form_tag :action => 'create' do %> - <%= render :partial => 'form' %> - <%= submit_tag "Create" %> -<% end %> - -<%= link_to 'Back', :action => 'list' %> diff --git a/app/views/problems/stat.html.erb b/app/views/problems/stat.html.erb new file mode 100644 --- /dev/null +++ b/app/views/problems/stat.html.erb @@ -0,0 +1,28 @@ +

Problem stat: <%= @problem.name %>

+ +This is just a hack. Really not efficient.

+ +<% if @submissions!=nil %> + + + + + + + + + <% count = 0 %> + <% @submissions.each do |sub| %> + "> + + + + + + + <% count += 1 %> + <% end %> +
loginnamesubmitted_atpointscomment
<%= sub.user.login %><%= sub.user.full_name if sub.user %><%= sub.submitted_at.to_s %><%= sub.points %>
<%= sub.grader_comment %>
+<% else %> +No submission +<% end %> diff --git a/app/views/problems/stat.rhtml b/app/views/problems/stat.rhtml deleted file mode 100644 --- a/app/views/problems/stat.rhtml +++ /dev/null @@ -1,28 +0,0 @@ -

Problem stat: <%= @problem.name %>

- -This is just a hack. Really not efficient.

- -<% if @submissions!=nil %> - - - - - - - - - <% count = 0 %> - <% @submissions.each do |sub| %> - "> - - - - - - - <% count += 1 %> - <% end %> -
loginnamesubmitted_atpointscomment
<%= sub.user.login %><%= sub.user.full_name if sub.user %><%= sub.submitted_at.to_s %><%= sub.points %>
<%= sub.grader_comment %>
-<% else %> -No submission -<% end %> diff --git a/app/views/test/index.html.erb b/app/views/test/index.html.erb --- a/app/views/test/index.html.erb +++ b/app/views/test/index.html.erb @@ -4,7 +4,7 @@
<%=t 'test.intro' %>
- <% if Configuration['contest.test_request.early_timeout'] %> + <% if GraderConfiguration['contest.test_request.early_timeout'] %> <%=t 'test.disabled_at_end_announcement' %> <% end %>
@@ -37,7 +37,7 @@ } -<% if Configuration.show_submitbox_to?(@user) and Configuration.allow_test_request(@user) %> +<% if GraderConfiguration.show_submitbox_to?(@user) and GraderConfiguration.allow_test_request(@user) %>
<%= error_messages_for 'submitted_test_request' %> <% form_for :test_request, nil, diff --git a/app/views/user_admin/_form.html.erb b/app/views/user_admin/_form.html.erb new file mode 100644 --- /dev/null +++ b/app/views/user_admin/_form.html.erb @@ -0,0 +1,22 @@ +<%= error_messages_for 'user' %> + + +


+<%= text_field 'user', 'login' %>

+ +


+<%= text_field 'user', 'full_name' %>

+ +


+<%= password_field 'user', 'password' %>

+ +


+<%= password_field 'user', 'password_confirmation' %>

+ +


+<%= text_field 'user', 'email' %>

+ +


+<%= text_field 'user', 'alias' %>

+ + diff --git a/app/views/user_admin/_form.rhtml b/app/views/user_admin/_form.rhtml deleted file mode 100644 --- a/app/views/user_admin/_form.rhtml +++ /dev/null @@ -1,22 +0,0 @@ -<%= error_messages_for 'user' %> - - -


-<%= text_field 'user', 'login' %>

- -


-<%= text_field 'user', 'full_name' %>

- -


-<%= password_field 'user', 'password' %>

- -


-<%= password_field 'user', 'password_confirmation' %>

- -


-<%= text_field 'user', 'email' %>

- -


-<%= text_field 'user', 'alias' %>

- - diff --git a/app/views/user_admin/contests.html.erb b/app/views/user_admin/contests.html.erb --- a/app/views/user_admin/contests.html.erb +++ b/app/views/user_admin/contests.html.erb @@ -5,7 +5,7 @@
<%= link_to '[View all users]', :action => 'list' %> - <% if Configuration.multicontests? %> + <% if GraderConfiguration.multicontests? %> <%= link_to '[Manage bulk users in contests]', :action => 'contest_management' %>
View users in: @@ -32,7 +32,7 @@ - <% if Configuration.multicontests? %> + <% if GraderConfiguration.multicontests? %> Contests Other enabled contests <% end %> @@ -47,7 +47,7 @@ <%= link_to 'Show', :action => 'show', :id => user %> <%= link_to 'Edit', :action => 'edit', :id => user %> <%= link_to 'Destroy', { :action => 'destroy', :id => user }, :confirm => 'Are you sure?', :method => :post %> - <% if Configuration.multicontests? %> + <% if GraderConfiguration.multicontests? %> <% user.contests.each do |contest| %> <%= contest.name %> [<%= link_to 'x', :action => 'remove_from_contest', :id => user.id, :contest_id => contest.id %>] diff --git a/app/views/user_admin/edit.html.erb b/app/views/user_admin/edit.html.erb new file mode 100644 --- /dev/null +++ b/app/views/user_admin/edit.html.erb @@ -0,0 +1,9 @@ +

Editing user

+ +<%= form_tag :action => 'update', :id => @user do %> + <%= render :partial => 'form' %> + <%= submit_tag 'Edit' %> +<% end %> + +<%= link_to 'Show', :action => 'show', :id => @user %> | +<%= link_to 'Back', :action => 'list' %> diff --git a/app/views/user_admin/edit.rhtml b/app/views/user_admin/edit.rhtml deleted file mode 100644 --- a/app/views/user_admin/edit.rhtml +++ /dev/null @@ -1,9 +0,0 @@ -

Editing user

- -<%= form_tag :action => 'update', :id => @user do %> - <%= render :partial => 'form' %> - <%= submit_tag 'Edit' %> -<% end %> - -<%= link_to 'Show', :action => 'show', :id => @user %> | -<%= link_to 'Back', :action => 'list' %> diff --git a/app/views/user_admin/list.html.erb b/app/views/user_admin/list.html.erb new file mode 100644 --- /dev/null +++ b/app/views/user_admin/list.html.erb @@ -0,0 +1,86 @@ +

Listing users

+ +
+ Quick add + <%= form_tag :action => 'create' do %> + + + + + + + + + + + + + + + + +
<%= text_field 'user', 'login', :size => 10 %><%= text_field 'user', 'full_name', :size => 30 %><%= password_field 'user', 'password', :size => 10 %><%= password_field 'user', 'password_confirmation', :size => 10 %><%= text_field 'user', 'email', :size => 15 %><%= submit_tag "Create" %>
+ <% end %> +
+ Import from site management + <%= form_tag({:action => 'import'}, :multipart => true) do %> + File: <%= file_field_tag 'file' %> <%= submit_tag 'Import' %> + <% end %> +
+ What else: + <%= link_to '[New user]', :action => 'new' %> + <%= link_to '[New list of users]', :action => 'new_list' %> + <%= link_to '[View administrators]', :action => 'admin' %> + <%= link_to '[Random passwords]', :action => 'random_all_passwords' %> + <%= link_to '[View active users]', :action => 'active' %> + <%= link_to '[Mass mailing]', :action => 'mass_mailing' %> + <% if GraderConfiguration.multicontests? %> +
Multi-contest: + <%= link_to '[Manage bulk users in contests]', :action => 'contest_management' %> + View users in: + <% @contests.each do |contest| %> + <%= link_to "[#{contest.name}]", :action => 'contests', :id => contest.id %> + <% end %> + <%= link_to "[no contest]", :action => 'contests', :id => 'none' %> + <% end %> +
+ +Total <%= @user_count %> users | +<% if !@paginated %> + Display all users. + <%= link_to '[show in pages]', :action => 'list', :page => '1' %> +<% else %> + Display in pages. + <%= link_to '[display all]', :action => 'list', :page => 'all' %> | + <%= will_paginate @users, :container => false %> +<% end %> + + + <% for column in User.content_columns %> + <% if !@hidden_columns.index(column.name) %> + + <% end %> + <% end %> + + + + + +<% for user in @users %> + "> + <% for column in User.content_columns %> + <% if !@hidden_columns.index(column.name) %> + + <% end %> + <% end %> + + + + +<% end %> +
<%= column.human_name %>
<%=h user.send(column.name) %><%= link_to 'Show', :action => 'show', :id => user %><%= link_to 'Edit', :action => 'edit', :id => user %><%= link_to 'Destroy', { :action => 'destroy', :id => user }, :confirm => 'Are you sure?', :method => :post %>
+ +
+ +<%= link_to '[New user]', :action => 'new' %> +<%= link_to '[New list of users]', :action => 'new_list' %> diff --git a/app/views/user_admin/list.rhtml b/app/views/user_admin/list.rhtml deleted file mode 100644 --- a/app/views/user_admin/list.rhtml +++ /dev/null @@ -1,86 +0,0 @@ -

Listing users

- -
- Quick add - <%= form_tag :action => 'create' do %> - - - - - - - - - - - - - - - - -
<%= text_field 'user', 'login', :size => 10 %><%= text_field 'user', 'full_name', :size => 30 %><%= password_field 'user', 'password', :size => 10 %><%= password_field 'user', 'password_confirmation', :size => 10 %><%= text_field 'user', 'email', :size => 15 %><%= submit_tag "Create" %>
- <% end %> -
- Import from site management - <%= form_tag({:action => 'import'}, :multipart => true) do %> - File: <%= file_field_tag 'file' %> <%= submit_tag 'Import' %> - <% end %> -
- What else: - <%= link_to '[New user]', :action => 'new' %> - <%= link_to '[New list of users]', :action => 'new_list' %> - <%= link_to '[View administrators]', :action => 'admin' %> - <%= link_to '[Random passwords]', :action => 'random_all_passwords' %> - <%= link_to '[View active users]', :action => 'active' %> - <%= link_to '[Mass mailing]', :action => 'mass_mailing' %> - <% if Configuration.multicontests? %> -
Multi-contest: - <%= link_to '[Manage bulk users in contests]', :action => 'contest_management' %> - View users in: - <% @contests.each do |contest| %> - <%= link_to "[#{contest.name}]", :action => 'contests', :id => contest.id %> - <% end %> - <%= link_to "[no contest]", :action => 'contests', :id => 'none' %> - <% end %> -
- -Total <%= @user_count %> users | -<% if !@paginated %> - Display all users. - <%= link_to '[show in pages]', :action => 'list', :page => '1' %> -<% else %> - Display in pages. - <%= link_to '[display all]', :action => 'list', :page => 'all' %> | - <%= will_paginate @users, :container => false %> -<% end %> - - - <% for column in User.content_columns %> - <% if !@hidden_columns.index(column.name) %> - - <% end %> - <% end %> - - - - - -<% for user in @users %> - "> - <% for column in User.content_columns %> - <% if !@hidden_columns.index(column.name) %> - - <% end %> - <% end %> - - - - -<% end %> -
<%= column.human_name %>
<%=h user.send(column.name) %><%= link_to 'Show', :action => 'show', :id => user %><%= link_to 'Edit', :action => 'edit', :id => user %><%= link_to 'Destroy', { :action => 'destroy', :id => user }, :confirm => 'Are you sure?', :method => :post %>
- -
- -<%= link_to '[New user]', :action => 'new' %> -<%= link_to '[New list of users]', :action => 'new_list' %> diff --git a/app/views/user_admin/new.html.erb b/app/views/user_admin/new.html.erb new file mode 100644 --- /dev/null +++ b/app/views/user_admin/new.html.erb @@ -0,0 +1,8 @@ +

New user

+ +<%= form_tag :action => 'create' do %> + <%= render :partial => 'form' %> + <%= submit_tag "Create" %> +<% end %> + +<%= link_to 'Back', :action => 'list' %> diff --git a/app/views/user_admin/new.rhtml b/app/views/user_admin/new.rhtml deleted file mode 100644 --- a/app/views/user_admin/new.rhtml +++ /dev/null @@ -1,8 +0,0 @@ -

New user

- -<%= form_tag :action => 'create' do %> - <%= render :partial => 'form' %> - <%= submit_tag "Create" %> -<% end %> - -<%= link_to 'Back', :action => 'list' %> diff --git a/app/views/user_admin/new_list.html.erb b/app/views/user_admin/new_list.html.erb new file mode 100644 --- /dev/null +++ b/app/views/user_admin/new_list.html.erb @@ -0,0 +1,8 @@ +

Adding list of users

+ +<%= form_tag :action => 'create_from_list' do %> +<%= submit_tag 'create users' %>
+List of user information in this format: user_id,name(,passwd(,alias))
+Note that passwd and alias is optional.
+<%= text_area_tag 'user_list', nil, :rows => 50, :cols => 80 %> +<% end %> diff --git a/app/views/user_admin/new_list.rhtml b/app/views/user_admin/new_list.rhtml deleted file mode 100644 --- a/app/views/user_admin/new_list.rhtml +++ /dev/null @@ -1,8 +0,0 @@ -

Adding list of users

- -<%= form_tag :action => 'create_from_list' do %> -<%= submit_tag 'create users' %>
-List of user information in this format: user_id,name(,passwd(,alias))
-Note that passwd and alias is optional.
-<%= text_area_tag 'user_list', nil, :rows => 50, :cols => 80 %> -<% end %> diff --git a/app/views/user_admin/show.html.erb b/app/views/user_admin/show.html.erb new file mode 100644 --- /dev/null +++ b/app/views/user_admin/show.html.erb @@ -0,0 +1,10 @@ +

User information

+ +<% for column in User.content_columns %> +

+ <%= column.human_name %>: <%=h @user.send(column.name) %> +

+<% end %> + +<%= link_to 'Edit', :action => 'edit', :id => @user %> | +<%= link_to 'Back', :action => 'list' %> diff --git a/app/views/user_admin/show.rhtml b/app/views/user_admin/show.rhtml deleted file mode 100644 --- a/app/views/user_admin/show.rhtml +++ /dev/null @@ -1,10 +0,0 @@ -

User information

- -<% for column in User.content_columns %> -

- <%= column.human_name %>: <%=h @user.send(column.name) %> -

-<% end %> - -<%= link_to 'Edit', :action => 'edit', :id => @user %> | -<%= link_to 'Back', :action => 'list' %> diff --git a/app/views/user_admin/user_stat.html.erb b/app/views/user_admin/user_stat.html.erb new file mode 100644 --- /dev/null +++ b/app/views/user_admin/user_stat.html.erb @@ -0,0 +1,43 @@ +

User grading results

+ + + + + + + + +<% @problems.each do |p| %> + +<% end %> + + + +<% counter = 0 %> +<% @scorearray.each do |sc| %> + "> + <% total = 0 %> + <% num_passed = 0 %> + <% sc.each_index do |i| %> + <% if i==0 %> + + + + + + <% else %> + + <% total += sc[i][0] %> + <% num_passed += 1 if sc[i][1] %> + <% end %> + <% end %> + + + + <% counter += 1 %> +<% end %> +
UserNameActivated?Logged inContest(s)<%= p.name %>TotalPassed
<%= sc[i].login %><%= sc[i].full_name %><%= sc[i].activated %> + <%= sc[i].try(:contest_stat).try(:started_at)!=nil ? 'yes' : 'no' %> + + <%= sc[i].contests.collect {|c| c.name}.join(', ') %> + <%= sc[i][0] %><%= total %><%= num_passed %>
diff --git a/app/views/user_admin/user_stat.rhtml b/app/views/user_admin/user_stat.rhtml deleted file mode 100644 --- a/app/views/user_admin/user_stat.rhtml +++ /dev/null @@ -1,43 +0,0 @@ -

User grading results

- - - - - - - - -<% @problems.each do |p| %> - -<% end %> - - - -<% counter = 0 %> -<% @scorearray.each do |sc| %> - "> - <% total = 0 %> - <% num_passed = 0 %> - <% sc.each_index do |i| %> - <% if i==0 %> - - - - - - <% else %> - - <% total += sc[i][0] %> - <% num_passed += 1 if sc[i][1] %> - <% end %> - <% end %> - - - - <% counter += 1 %> -<% end %> -
UserNameActivated?Logged inContest(s)<%= p.name %>TotalPassed
<%= sc[i].login %><%= sc[i].full_name %><%= sc[i].activated %> - <%= sc[i].try(:contest_stat).try(:started_at)!=nil ? 'yes' : 'no' %> - - <%= sc[i].contests.collect {|c| c.name}.join(', ') %> - <%= sc[i][0] %><%= total %><%= num_passed %>
diff --git a/app/views/users/forget.html.haml b/app/views/users/forget.html.haml --- a/app/views/users/forget.html.haml +++ b/app/views/users/forget.html.haml @@ -1,6 +1,6 @@ .contest-title %h1 - = "#{Configuration['contest.name']}: #{t 'registration.password_retrieval.header'}" + = "#{GraderConfiguration['contest.name']}: #{t 'registration.password_retrieval.header'}" - if flash[:notice] %hr/ diff --git a/app/views/users/new.html.haml b/app/views/users/new.html.haml --- a/app/views/users/new.html.haml +++ b/app/views/users/new.html.haml @@ -1,6 +1,6 @@ .contest-title %h1 - = "#{Configuration['contest.name']}: #{t 'registration.title'}" + = "#{GraderConfiguration['contest.name']}: #{t 'registration.title'}" .registration-desc =t 'registration.description' diff --git a/config/application.rb b/config/application.rb --- a/config/application.rb +++ b/config/application.rb @@ -54,7 +54,7 @@ config.active_record.whitelist_attributes = true # Enable the asset pipeline - config.assets.enabled = true + config.assets.enabled = false # Version of your assets, change this if you want to expire all your assets config.assets.version = '1.0' diff --git a/db/migrate/20121001033508_rename_configurations_to_grader_configurations.rb b/db/migrate/20121001033508_rename_configurations_to_grader_configurations.rb new file mode 100644 --- /dev/null +++ b/db/migrate/20121001033508_rename_configurations_to_grader_configurations.rb @@ -0,0 +1,5 @@ +class RenameConfigurationsToGraderConfigurations < ActiveRecord::Migration + def change + rename_table 'configurations', 'grader_configurations' + end +end diff --git a/db/schema.rb b/db/schema.rb --- a/db/schema.rb +++ b/db/schema.rb @@ -1,15 +1,17 @@ -# This file is auto-generated from the current state of the database. Instead of editing this file, -# please use the migrations feature of Active Record to incrementally modify your database, and -# then regenerate this schema definition. +# encoding: UTF-8 +# This file is auto-generated from the current state of the database. Instead +# of editing this file, please use the migrations feature of Active Record to +# incrementally modify your database, and then regenerate this schema definition. # -# Note that this schema.rb definition is the authoritative source for your database schema. If you need -# to create the application database on another system, you should be using db:schema:load, not running -# all the migrations from scratch. The latter is a flawed and unsustainable approach (the more migrations +# Note that this schema.rb definition is the authoritative source for your +# database schema. If you need to create the application database on another +# system, you should be using db:schema:load, not running all the migrations +# from scratch. The latter is a flawed and unsustainable approach (the more migrations # you'll amass, the slower it'll run and the greater likelihood for issues). # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20100506163112) do +ActiveRecord::Schema.define(:version => 20121001033508) do create_table "announcements", :force => true do |t| t.string "author" @@ -23,13 +25,12 @@ t.string "notes" end - create_table "configurations", :force => true do |t| - t.string "key" - t.string "value_type" - t.string "value" + create_table "codejom_statuses", :force => true do |t| + t.integer "user_id" + t.boolean "alive" + t.integer "num_problems_passed" t.datetime "created_at" t.datetime "updated_at" - t.text "description" end create_table "contests", :force => true do |t| @@ -63,6 +64,15 @@ t.datetime "updated_at" end + create_table "grader_configurations", :force => true do |t| + t.string "key" + t.string "value_type" + t.string "value" + t.datetime "created_at" + t.datetime "updated_at" + t.text "description" + end + create_table "grader_processes", :force => true do |t| t.string "host", :limit => 20 t.integer "pid" @@ -95,16 +105,18 @@ end create_table "problems", :force => true do |t| - t.string "name", :limit => 30 - t.string "full_name" - t.integer "full_score" - t.date "date_added" - t.boolean "available" - t.string "url" - t.integer "description_id" - t.boolean "test_allowed" - t.boolean "output_only" - t.string "description_filename" + t.string "name", :limit => 30 + t.string "full_name" + t.integer "full_score" + t.date "date_added" + t.boolean "available" + t.string "url" + t.integer "description_id" + t.boolean "test_allowed" + t.boolean "output_only" + t.integer "level", :default => 0 + t.datetime "updated_at" + t.string "description_filename" end create_table "rights", :force => true do |t| @@ -150,6 +162,15 @@ t.string "password" end + create_table "submission_statuses", :force => true do |t| + t.integer "user_id" + t.integer "problem_id" + t.boolean "passed" + t.integer "submission_count" + t.datetime "created_at" + t.datetime "updated_at" + end + create_table "submissions", :force => true do |t| t.integer "user_id" t.integer "problem_id" @@ -176,12 +197,24 @@ t.datetime "updated_at" end + create_table "test_pair_assignments", :force => true do |t| + t.integer "user_id" + t.integer "problem_id" + t.integer "test_pair_id" + t.integer "test_pair_number" + t.integer "request_number" + t.datetime "created_at" + t.datetime "updated_at" + t.boolean "submitted" + end + create_table "test_pairs", :force => true do |t| t.integer "problem_id" t.text "input", :limit => 16777215 t.text "solution", :limit => 16777215 t.datetime "created_at" t.datetime "updated_at" + t.integer "number" end create_table "test_requests", :force => true do |t| @@ -215,17 +248,24 @@ end create_table "users", :force => true do |t| - t.string "login", :limit => 50 + t.string "login", :limit => 50 t.string "full_name" t.string "hashed_password" - t.string "salt", :limit => 5 + t.string "salt", :limit => 5 t.string "alias" t.string "email" t.integer "site_id" t.integer "country_id" - t.boolean "activated", :default => false + t.boolean "activated", :default => false t.datetime "created_at" t.datetime "updated_at" + t.string "member1_full_name" + t.string "member2_full_name" + t.string "member3_full_name" + t.boolean "high_school" + t.string "member1_school_name" + t.string "member2_school_name" + t.string "member3_school_name" end add_index "users", ["login"], :name => "index_users_on_login", :unique => true diff --git a/db/seeds.rb b/db/seeds.rb --- a/db/seeds.rb +++ b/db/seeds.rb @@ -123,8 +123,8 @@ value_type, default_value, description='') - conf = (Configuration.find_by_key(key) || - Configuration.new(:key => key, + conf = (GraderConfiguration.find_by_key(key) || + GraderConfiguration.new(:key => key, :value_type => value_type, :value => default_value)) conf.description = description