Description:
renamed model Configuration to GraderConfiguration, renamed rhtml views to erb, fixed other small errors
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r320:c31111f6e4b5 - - 61 files changed: 710 inserted, 654 deleted

@@ -0,0 +1,176
1 + require 'yaml'
2 +
3 + #
4 + # This class also contains various login of the system.
5 + #
6 + class GraderConfiguration < ActiveRecord::Base
7 +
8 + SYSTEM_MODE_CONF_KEY = 'system.mode'
9 + TEST_REQUEST_EARLY_TIMEOUT_KEY = 'contest.test_request.early_timeout'
10 + MULTICONTESTS_KEY = 'system.multicontests'
11 + CONTEST_TIME_LIMIT_KEY = 'contest.time_limit'
12 +
13 + cattr_accessor :config_cache
14 + cattr_accessor :task_grading_info_cache
15 + cattr_accessor :contest_time_str
16 + cattr_accessor :contest_time
17 +
18 + GraderConfiguration.config_cache = nil
19 + GraderConfiguration.task_grading_info_cache = nil
20 +
21 + def self.config_cached?
22 + (defined? CONFIGURATION_CACHE_ENABLED) and (CONFIGURATION_CACHE_ENABLED)
23 + end
24 +
25 + def self.get(key)
26 + if GraderConfiguration.config_cached?
27 + if GraderConfiguration.config_cache == nil
28 + self.read_config
29 + end
30 + return GraderConfiguration.config_cache[key]
31 + else
32 + return GraderConfiguration.read_one_key(key)
33 + end
34 + end
35 +
36 + def self.[](key)
37 + self.get(key)
38 + end
39 +
40 + def self.reload
41 + self.read_config
42 + end
43 +
44 + def self.clear
45 + GraderConfiguration.config_cache = nil
46 + end
47 +
48 + #
49 + # View decision
50 + #
51 + def self.show_submitbox_to?(user)
52 + mode = get(SYSTEM_MODE_CONF_KEY)
53 + return false if mode=='analysis'
54 + if (mode=='contest')
55 + return false if (user.site!=nil) and
56 + ((user.site.started!=true) or (user.site.finished?))
57 + end
58 + return true
59 + end
60 +
61 + def self.show_tasks_to?(user)
62 + if time_limit_mode?
63 + return false if not user.contest_started?
64 + end
65 + return true
66 + end
67 +
68 + def self.show_grading_result
69 + return (get(SYSTEM_MODE_CONF_KEY)=='analysis')
70 + end
71 +
72 + def self.allow_test_request(user)
73 + mode = get(SYSTEM_MODE_CONF_KEY)
74 + early_timeout = get(TEST_REQUEST_EARLY_TIMEOUT_KEY)
75 + if (mode=='contest')
76 + return false if ((user.site!=nil) and
77 + ((user.site.started!=true) or
78 + (early_timeout and (user.site.time_left < 30.minutes))))
79 + end
80 + return false if mode=='analysis'
81 + return true
82 + end
83 +
84 + def self.task_grading_info
85 + if GraderConfiguration.task_grading_info_cache==nil
86 + read_grading_info
87 + end
88 + return GraderConfiguration.task_grading_info_cache
89 + end
90 +
91 + def self.standard_mode?
92 + return get(SYSTEM_MODE_CONF_KEY) == 'standard'
93 + end
94 +
95 + def self.contest_mode?
96 + return get(SYSTEM_MODE_CONF_KEY) == 'contest'
97 + end
98 +
99 + def self.indv_contest_mode?
100 + return get(SYSTEM_MODE_CONF_KEY) == 'indv-contest'
101 + end
102 +
103 + def self.multicontests?
104 + return get(MULTICONTESTS_KEY) == true
105 + end
106 +
107 + def self.time_limit_mode?
108 + mode = get(SYSTEM_MODE_CONF_KEY)
109 + return ((mode == 'contest') or (mode == 'indv-contest'))
110 + end
111 +
112 + def self.analysis_mode?
113 + return get(SYSTEM_MODE_CONF_KEY) == 'analysis'
114 + end
115 +
116 + def self.contest_time_limit
117 + contest_time_str = GraderConfiguration[CONTEST_TIME_LIMIT_KEY]
118 +
119 + if not defined? GraderConfiguration.contest_time_str
120 + GraderConfiguration.contest_time_str = nil
121 + end
122 +
123 + if GraderConfiguration.contest_time_str != contest_time_str
124 + GraderConfiguration.contest_time_str = contest_time_str
125 + if tmatch = /(\d+):(\d+)/.match(contest_time_str)
126 + h = tmatch[1].to_i
127 + m = tmatch[2].to_i
128 +
129 + GraderConfiguration.contest_time = h.hour + m.minute
130 + else
131 + GraderConfiguration.contest_time = nil
132 + end
133 + end
134 + return GraderConfiguration.contest_time
135 + end
136 +
137 + protected
138 +
139 + def self.convert_type(val,type)
140 + case type
141 + when 'string'
142 + return val
143 +
144 + when 'integer'
145 + return val.to_i
146 +
147 + when 'boolean'
148 + return (val=='true')
149 + end
150 + end
151 +
152 + def self.read_config
153 + GraderConfiguration.config_cache = {}
154 + GraderConfiguration.find(:all).each do |conf|
155 + key = conf.key
156 + val = conf.value
157 + GraderConfiguration.config_cache[key] = GraderConfiguration.convert_type(val,conf.value_type)
158 + end
159 + end
160 +
161 + def self.read_one_key(key)
162 + conf = GraderConfiguration.find_by_key(key)
163 + if conf
164 + return GraderConfiguration.convert_type(conf.value,conf.value_type)
165 + else
166 + return nil
167 + end
168 + end
169 +
170 + def self.read_grading_info
171 + f = File.open(TASK_GRADING_INFO_FILENAME)
172 + GraderConfiguration.task_grading_info_cache = YAML.load(f)
173 + f.close
174 + end
175 +
176 + end
@@ -0,0 +1,52
1 + <%= error_messages_for 'problem' %>
2 +
3 + <!--[form:problem]-->
4 + <p><label for="problem_name">Name</label><br/>
5 + <%= text_field 'problem', 'name' %></p>
6 +
7 + <p><label for="problem_full_name">Full name</label><br/>
8 + <%= text_field 'problem', 'full_name' %></p>
9 +
10 + <p><label for="problem_full_score">Full score</label><br/>
11 + <%= text_field 'problem', 'full_score' %></p>
12 +
13 + <p><label for="problem_date_added">Date added</label><br/>
14 + <%= date_select 'problem', 'date_added' %></p>
15 +
16 + <%
17 + # TODO: these should be put in model Problem, but I can't think of
18 + # nice default values for them. These values look fine only
19 + # in this case (of lazily adding new problems).
20 + @problem.available = true if @problem!=nil and @problem.available==nil
21 + @problem.test_allowed = true if @problem!=nil and @problem.test_allowed==nil
22 + @problem.output_only = false if @problem!=nil and @problem.output_only==nil
23 + %>
24 +
25 + <p>
26 + <label for="problem_available">Available?</label>
27 + <%= check_box :problem, :available %>
28 +
29 + <label for="problem_test_allowed">Test allowed?</label>
30 + <%= check_box :problem, :test_allowed %>
31 +
32 + <label for="problem_output_only">Output only?</label>
33 + <%= check_box :problem, :output_only %>
34 + </p>
35 +
36 + <%= error_messages_for 'description' %>
37 +
38 + <p><label for="description_body">Description</label><br/>
39 + <%= text_area :description, :body, :rows => 10, :cols => 80 %></p>
40 +
41 + <p><label for="description_markdowned">Markdowned?</label>
42 + <%= select "description",
43 + "markdowned",
44 + [['True',true],['False',false]],
45 + {:selected => (@description) ? @description.markdowned : false }
46 + %></p>
47 +
48 + <p><label for="problem_url">URL</label><br/>
49 + <%= text_field 'problem', 'url' %></p>
50 +
51 +
52 + <!--[eoform:problem]-->
@@ -0,0 +1,9
1 + <h1>Editing problem</h1>
2 +
3 + <%= form_tag :action => 'update', :id => @problem do %>
4 + <%= render :partial => 'form' %>
5 + <%= submit_tag 'Edit' %>
6 + <% end %>
7 +
8 + <%= link_to 'Show', :action => 'show', :id => @problem %> |
9 + <%= link_to 'Back', :action => 'list' %>
@@ -0,0 +1,67
1 + <% content_for :head do %>
2 + <%= stylesheet_link_tag 'problems' %>
3 + <%= javascript_include_tag :defaults %>
4 + <% end %>
5 +
6 + <h1>Listing problems</h1>
7 +
8 + <p>
9 + <%= link_to '[New problem]', :action => 'new' %>
10 + <%= link_to '[Manage problems]', :action => 'manage' %>
11 + <%= link_to '[Import problems]', :action => 'import' %>
12 + <%= link_to '[Turn off all problems]', :action => 'turn_all_off' %>
13 + <%= link_to '[Turn on all problems]', :action => 'turn_all_on' %>
14 + </p>
15 +
16 + <div class="submitbox">
17 + <%= form_tag :action => 'quick_create' do %>
18 + <b>Quick New:</b>
19 + <label for="problem_name">Name</label>
20 + <%= text_field 'problem', 'name' %> |
21 + <label for="problem_full_name">Full name</label>
22 + <%= text_field 'problem', 'full_name' %>
23 + <%= submit_tag "Create" %>
24 + <% end %>
25 + </div>
26 +
27 + <table>
28 + <tr>
29 + <th>Name</th>
30 + <th>Full name</th>
31 + <th>Full score</th>
32 + <th>Date added</th>
33 + <th>Avail?</th>
34 + <th>Test?</th>
35 + <% if GraderConfiguration.multicontests? %>
36 + <th>Contests</th>
37 + <% end %>
38 + </tr>
39 +
40 + <% for problem in @problems %>
41 + <tr id="prob-<%= problem.id %>" name="prob-<%= problem.id %>" class="<%= (problem.available) ? "available" : "not-available" %>">
42 + <% @problem=problem %>
43 + <td><%= in_place_editor_field :problem, :name, {}, :rows=>1 %></td>
44 + <td><%= in_place_editor_field :problem, :full_name, {}, :rows=>1 %></td>
45 + <td><%= in_place_editor_field :problem, :full_score, {}, :rows=>1 %></td>
46 + <td><%= problem.date_added %></td>
47 + <td id="prob-<%= problem.id %>-avail"><%= problem.available %></td>
48 + <td><%= problem.test_allowed %></td>
49 +
50 + <% if GraderConfiguration.multicontests? %>
51 + <td>
52 + <%= problem.contests.collect { |c| c.name }.join(', ') %>
53 + </td>
54 + <% end %>
55 +
56 + <td><%= link_to_remote '[Toggle]', :url => {:action => 'toggle', :id => problem.id } %></td>
57 + <td><%= link_to '[Stat]', :action => 'stat', :id => problem.id %></td>
58 + <td><%= link_to '[Show]', :action => 'show', :id => problem %></td>
59 + <td><%= link_to '[Edit]', :action => 'edit', :id => problem %></td>
60 + <td><%= link_to '[Destroy]', { :action => 'destroy', :id => problem }, :confirm => 'Are you sure?', :method => :post %></td>
61 + </tr>
62 + <% end %>
63 + </table>
64 +
65 + <br />
66 +
67 + <%= link_to '[New problem]', :action => 'new' %>
@@ -0,0 +1,8
1 + <h1>New problem</h1>
2 +
3 + <%= form_tag :action => 'create' do %>
4 + <%= render :partial => 'form' %>
5 + <%= submit_tag "Create" %>
6 + <% end %>
7 +
8 + <%= link_to 'Back', :action => 'list' %>
@@ -0,0 +1,28
1 + <h1>Problem stat: <%= @problem.name %></h1>
2 +
3 + <i>This is just a hack. Really not efficient.</i><br/><br/>
4 +
5 + <% if @submissions!=nil %>
6 + <table class="info">
7 + <tr class="info-head">
8 + <th>login</th>
9 + <th>name</th>
10 + <th>submitted_at</th>
11 + <th>points</th>
12 + <th>comment</th>
13 + </tr>
14 + <% count = 0 %>
15 + <% @submissions.each do |sub| %>
16 + <tr class="<%= (count % 2 ==0) ? "info-even" : "info-odd" %>">
17 + <td><%= sub.user.login %></td>
18 + <td><%= sub.user.full_name if sub.user %></td>
19 + <td><%= sub.submitted_at.to_s %></td>
20 + <td><%= sub.points %></td>
21 + <td><div style="font-family: monospace"><%= sub.grader_comment %></div></td>
22 + </tr>
23 + <% count += 1 %>
24 + <% end %>
25 + </table>
26 + <% else %>
27 + No submission
28 + <% end %>
@@ -0,0 +1,22
1 + <%= error_messages_for 'user' %>
2 +
3 + <!--[form:user]-->
4 + <p><label for="user_name">Login</label><br/>
5 + <%= text_field 'user', 'login' %></p>
6 +
7 + <p><label for="user_name">Full name</label><br/>
8 + <%= text_field 'user', 'full_name' %></p>
9 +
10 + <p><label for="password">Password</label><br/>
11 + <%= password_field 'user', 'password' %></p>
12 +
13 + <p><label for="password_confirmation">Password (confirm)</label><br/>
14 + <%= password_field 'user', 'password_confirmation' %></p>
15 +
16 + <p><label for="user_email">E-mail</label><br/>
17 + <%= text_field 'user', 'email' %></p>
18 +
19 + <p><label for="user_alias">Alias</label><br/>
20 + <%= text_field 'user', 'alias' %></p>
21 + <!--[eoform:user]-->
22 +
@@ -0,0 +1,9
1 + <h1>Editing user</h1>
2 +
3 + <%= form_tag :action => 'update', :id => @user do %>
4 + <%= render :partial => 'form' %>
5 + <%= submit_tag 'Edit' %>
6 + <% end %>
7 +
8 + <%= link_to 'Show', :action => 'show', :id => @user %> |
9 + <%= link_to 'Back', :action => 'list' %>
@@ -0,0 +1,86
1 + <h1>Listing users</h1>
2 +
3 + <div class="submitbox">
4 + <b>Quick add</b>
5 + <%= form_tag :action => 'create' do %>
6 + <table border="0">
7 + <tr>
8 + <td><label for="user_login">Login</label></td>
9 + <td><label for="user_full_name">Full name</label></td>
10 + <td><label for="user_password">Password</label></td>
11 + <td><label for="user_password_confirmation">Confirm</label></td>
12 + <td><label for="user_email">Email</label></td>
13 + </tr>
14 + <tr>
15 + <td><%= text_field 'user', 'login', :size => 10 %></td>
16 + <td><%= text_field 'user', 'full_name', :size => 30 %></td>
17 + <td><%= password_field 'user', 'password', :size => 10 %></td>
18 + <td><%= password_field 'user', 'password_confirmation', :size => 10 %></td>
19 + <td><%= text_field 'user', 'email', :size => 15 %></td>
20 + <td><%= submit_tag "Create" %></td>
21 + </tr>
22 + </table>
23 + <% end %>
24 + <br/>
25 + <b>Import from site management</b>
26 + <%= form_tag({:action => 'import'}, :multipart => true) do %>
27 + File: <%= file_field_tag 'file' %> <%= submit_tag 'Import' %>
28 + <% end %>
29 + <br/>
30 + <b>What else: </b>
31 + <%= link_to '[New user]', :action => 'new' %>
32 + <%= link_to '[New list of users]', :action => 'new_list' %>
33 + <%= link_to '[View administrators]', :action => 'admin' %>
34 + <%= link_to '[Random passwords]', :action => 'random_all_passwords' %>
35 + <%= link_to '[View active users]', :action => 'active' %>
36 + <%= link_to '[Mass mailing]', :action => 'mass_mailing' %>
37 + <% if GraderConfiguration.multicontests? %>
38 + <br/><b>Multi-contest:</b>
39 + <%= link_to '[Manage bulk users in contests]', :action => 'contest_management' %>
40 + View users in:
41 + <% @contests.each do |contest| %>
42 + <%= link_to "[#{contest.name}]", :action => 'contests', :id => contest.id %>
43 + <% end %>
44 + <%= link_to "[no contest]", :action => 'contests', :id => 'none' %>
45 + <% end %>
46 + </div>
47 +
48 + Total <%= @user_count %> users |
49 + <% if !@paginated %>
50 + Display all users.
51 + <%= link_to '[show in pages]', :action => 'list', :page => '1' %>
52 + <% else %>
53 + Display in pages.
54 + <%= link_to '[display all]', :action => 'list', :page => 'all' %> |
55 + <%= will_paginate @users, :container => false %>
56 + <% end %>
57 + <table class="info">
58 + <tr class="info-head">
59 + <% for column in User.content_columns %>
60 + <% if !@hidden_columns.index(column.name) %>
61 + <th><%= column.human_name %></th>
62 + <% end %>
63 + <% end %>
64 + <th></th>
65 + <th></th>
66 + <th></th>
67 + </tr>
68 +
69 + <% for user in @users %>
70 + <tr class="info-<%= cycle("odd","even") %>">
71 + <% for column in User.content_columns %>
72 + <% if !@hidden_columns.index(column.name) %>
73 + <td><%=h user.send(column.name) %></td>
74 + <% end %>
75 + <% end %>
76 + <td><%= link_to 'Show', :action => 'show', :id => user %></td>
77 + <td><%= link_to 'Edit', :action => 'edit', :id => user %></td>
78 + <td><%= link_to 'Destroy', { :action => 'destroy', :id => user }, :confirm => 'Are you sure?', :method => :post %></td>
79 + </tr>
80 + <% end %>
81 + </table>
82 +
83 + <br />
84 +
85 + <%= link_to '[New user]', :action => 'new' %>
86 + <%= link_to '[New list of users]', :action => 'new_list' %>
@@ -0,0 +1,8
1 + <h1>New user</h1>
2 +
3 + <%= form_tag :action => 'create' do %>
4 + <%= render :partial => 'form' %>
5 + <%= submit_tag "Create" %>
6 + <% end %>
7 +
8 + <%= link_to 'Back', :action => 'list' %>
@@ -0,0 +1,8
1 + <h1>Adding list of users</h1>
2 +
3 + <%= form_tag :action => 'create_from_list' do %>
4 + <%= submit_tag 'create users' %><br/>
5 + List of user information in this format: <tt>user_id,name(,passwd(,alias))</tt><br/>
6 + Note that <tt>passwd</tt> and <tt>alias</tt> is optional.<br/>
7 + <%= text_area_tag 'user_list', nil, :rows => 50, :cols => 80 %>
8 + <% end %>
@@ -0,0 +1,10
1 + <h1>User information</h1>
2 +
3 + <% for column in User.content_columns %>
4 + <p>
5 + <b><%= column.human_name %>:</b> <%=h @user.send(column.name) %>
6 + </p>
7 + <% end %>
8 +
9 + <%= link_to 'Edit', :action => 'edit', :id => @user %> |
10 + <%= link_to 'Back', :action => 'list' %>
@@ -0,0 +1,43
1 + <h1>User grading results</h1>
2 +
3 + <table class="info">
4 + <tr class="info-head">
5 + <th>User</th>
6 + <th>Name</th>
7 + <th>Activated?</th>
8 + <th>Logged in</th>
9 + <th>Contest(s)</th>
10 + <% @problems.each do |p| %>
11 + <th><%= p.name %></th>
12 + <% end %>
13 + <th>Total</th>
14 + <th>Passed</th>
15 + </tr>
16 + <% counter = 0 %>
17 + <% @scorearray.each do |sc| %>
18 + <tr class="<%= (counter %2 ==0) ? "info-even" : "info-odd" %>">
19 + <% total = 0 %>
20 + <% num_passed = 0 %>
21 + <% sc.each_index do |i| %>
22 + <% if i==0 %>
23 + <td><%= sc[i].login %></td>
24 + <td><%= sc[i].full_name %></td>
25 + <td><%= sc[i].activated %></td>
26 + <td>
27 + <%= sc[i].try(:contest_stat).try(:started_at)!=nil ? 'yes' : 'no' %>
28 + </td>
29 + <td>
30 + <%= sc[i].contests.collect {|c| c.name}.join(', ') %>
31 + </td>
32 + <% else %>
33 + <td><%= sc[i][0] %></td>
34 + <% total += sc[i][0] %>
35 + <% num_passed += 1 if sc[i][1] %>
36 + <% end %>
37 + <% end %>
38 + <td><%= total %></td>
39 + <td><%= num_passed %></td>
40 + </tr>
41 + <% counter += 1 %>
42 + <% end %>
43 + </table>
@@ -0,0 +1,5
1 + class RenameConfigurationsToGraderConfigurations < ActiveRecord::Migration
2 + def change
3 + rename_table 'configurations', 'grader_configurations'
4 + end
5 + end
@@ -38,10 +38,11
38
38
39 gem "haml"
39 gem "haml"
40 gem "tmail"
40 gem "tmail"
41 gem "rdiscount", :require => "rdiscount"
41 gem "rdiscount", :require => "rdiscount"
42 gem "test-unit"
42 gem "test-unit"
43 gem 'will_paginate', '~> 3.0.0'
43 gem 'will_paginate', '~> 3.0.0'
44 + gem 'dynamic_form'
44
45
45 group :test, :development do
46 group :test, :development do
46 gem "rspec-rails", "~> 2.0"
47 gem "rspec-rails", "~> 2.0"
47 end
48 end
@@ -35,12 +35,13
35 railties (~> 3.2.0)
35 railties (~> 3.2.0)
36 coffee-script (2.2.0)
36 coffee-script (2.2.0)
37 coffee-script-source
37 coffee-script-source
38 execjs
38 execjs
39 coffee-script-source (1.3.3)
39 coffee-script-source (1.3.3)
40 diff-lcs (1.1.3)
40 diff-lcs (1.1.3)
41 + dynamic_form (1.1.4)
41 erubis (2.7.0)
42 erubis (2.7.0)
42 execjs (1.4.0)
43 execjs (1.4.0)
43 multi_json (~> 1.0)
44 multi_json (~> 1.0)
44 haml (3.1.7)
45 haml (3.1.7)
45 hike (1.2.1)
46 hike (1.2.1)
46 i18n (0.6.1)
47 i18n (0.6.1)
@@ -119,12 +120,13
119
120
120 PLATFORMS
121 PLATFORMS
121 ruby
122 ruby
122
123
123 DEPENDENCIES
124 DEPENDENCIES
124 coffee-rails (~> 3.2.1)
125 coffee-rails (~> 3.2.1)
126 + dynamic_form
125 haml
127 haml
126 mysql2
128 mysql2
127 prototype-rails
129 prototype-rails
128 rails (= 3.2.8)
130 rails (= 3.2.8)
129 rdiscount
131 rdiscount
130 rspec-rails (~> 2.0)
132 rspec-rails (~> 2.0)
@@ -25,23 +25,23
25 unless session[:user_id]
25 unless session[:user_id]
26 redirect_to :controller => 'main', :action => 'login'
26 redirect_to :controller => 'main', :action => 'login'
27 return false
27 return false
28 end
28 end
29
29
30 # check if run in single user mode
30 # check if run in single user mode
31 - if Configuration[SINGLE_USER_MODE_CONF_KEY]
31 + if GraderConfiguration[SINGLE_USER_MODE_CONF_KEY]
32 user = User.find(session[:user_id])
32 user = User.find(session[:user_id])
33 if user==nil or (not user.admin?)
33 if user==nil or (not user.admin?)
34 flash[:notice] = 'You cannot log in at this time'
34 flash[:notice] = 'You cannot log in at this time'
35 redirect_to :controller => 'main', :action => 'login'
35 redirect_to :controller => 'main', :action => 'login'
36 return false
36 return false
37 end
37 end
38 return true
38 return true
39 end
39 end
40
40
41 - if Configuration.multicontests?
41 + if GraderConfiguration.multicontests?
42 user = User.find(session[:user_id])
42 user = User.find(session[:user_id])
43 return true if user.admin?
43 return true if user.admin?
44 begin
44 begin
45 if user.contest_stat(true).forced_logout
45 if user.contest_stat(true).forced_logout
46 flash[:notice] = 'You have been automatically logged out.'
46 flash[:notice] = 'You have been automatically logged out.'
47 redirect_to :controller => 'main', :action => 'index'
47 redirect_to :controller => 'main', :action => 'index'
@@ -5,16 +5,16
5
5
6 in_place_edit_for :configuration, :key
6 in_place_edit_for :configuration, :key
7 in_place_edit_for :configuration, :type
7 in_place_edit_for :configuration, :type
8 in_place_edit_for :configuration, :value
8 in_place_edit_for :configuration, :value
9
9
10 def index
10 def index
11 - @configurations = Configuration.find(:all,
11 + @configurations = GraderConfiguration.find(:all,
12 :order => '`key`')
12 :order => '`key`')
13 end
13 end
14
14
15 def reload
15 def reload
16 - Configuration.reload
16 + GraderConfiguration.reload
17 redirect_to :action => 'index'
17 redirect_to :action => 'index'
18 end
18 end
19
19
20 end
20 end
@@ -4,13 +4,13
4
4
5 def index
5 def index
6 @num_contests = Contest.count()
6 @num_contests = Contest.count()
7 end
7 end
8
8
9 def user_stat
9 def user_stat
10 - if not Configuration.indv_contest_mode?
10 + if not GraderConfiguration.indv_contest_mode?
11 redirect_to :action => 'index' and return
11 redirect_to :action => 'index' and return
12 end
12 end
13
13
14 @users = User.find(:all)
14 @users = User.find(:all)
15 @start_times = {}
15 @start_times = {}
16 UserContestStat.find(:all).each do |stat|
16 UserContestStat.find(:all).each do |stat|
@@ -24,24 +24,24
24 user.contest_stat.destroy
24 user.contest_stat.destroy
25 end
25 end
26 redirect_to :action => 'user_stat'
26 redirect_to :action => 'user_stat'
27 end
27 end
28
28
29 def clear_all_stat
29 def clear_all_stat
30 - if not Configuration.indv_contest_mode?
30 + if not GraderConfiguration.indv_contest_mode?
31 redirect_to :action => 'index' and return
31 redirect_to :action => 'index' and return
32 end
32 end
33
33
34 UserContestStat.delete_all()
34 UserContestStat.delete_all()
35 flash[:notice] = 'All start time statistic cleared.'
35 flash[:notice] = 'All start time statistic cleared.'
36 redirect_to :action => 'index'
36 redirect_to :action => 'index'
37 end
37 end
38
38
39 def change_contest_mode
39 def change_contest_mode
40 if ['standard', 'contest', 'indv-contest'].include? params[:id]
40 if ['standard', 'contest', 'indv-contest'].include? params[:id]
41 - config = Configuration.find_by_key('system.mode')
41 + config = GraderConfiguration.find_by_key('system.mode')
42 config.value = params[:id]
42 config.value = params[:id]
43 config.save
43 config.save
44 else
44 else
45 flash[:notice] = 'Wrong contest mode value'
45 flash[:notice] = 'Wrong contest mode value'
46 end
46 end
47 redirect_to :action => 'index'
47 redirect_to :action => 'index'
@@ -9,13 +9,13
9 def login
9 def login
10 if user = User.authenticate(params[:login], params[:password])
10 if user = User.authenticate(params[:login], params[:password])
11 session[:user_id] = user.id
11 session[:user_id] = user.id
12 session[:admin] = user.admin?
12 session[:admin] = user.admin?
13
13
14 # clear forced logout flag for multicontests contest change
14 # clear forced logout flag for multicontests contest change
15 - if Configuration.multicontests?
15 + if GraderConfiguration.multicontests?
16 contest_stat = user.contest_stat
16 contest_stat = user.contest_stat
17 if contest_stat.respond_to? :forced_logout
17 if contest_stat.respond_to? :forced_logout
18 if contest_stat.forced_logout
18 if contest_stat.forced_logout
19 contest_stat.forced_logout = false
19 contest_stat.forced_logout = false
20 contest_stat.save
20 contest_stat.save
21 end
21 end
@@ -35,13 +35,13
35
35
36 # EXPERIMENT:
36 # EXPERIMENT:
37 # Hide login if in single user mode and the url does not
37 # Hide login if in single user mode and the url does not
38 # explicitly specify /login
38 # explicitly specify /login
39 #
39 #
40 # logger.info "PATH: #{request.path}"
40 # logger.info "PATH: #{request.path}"
41 - # if Configuration['system.single_user_mode'] and
41 + # if GraderConfiguration['system.single_user_mode'] and
42 # request.path!='/main/login'
42 # request.path!='/main/login'
43 # @hidelogin = true
43 # @hidelogin = true
44 # end
44 # end
45
45
46 @announcements = Announcement.find_for_frontpage
46 @announcements = Announcement.find_for_frontpage
47 render :action => 'login', :layout => 'empty'
47 render :action => 'login', :layout => 'empty'
@@ -64,13 +64,13
64 if (params['file']) and (params['file']!='')
64 if (params['file']) and (params['file']!='')
65 @submission.source = params['file'].read
65 @submission.source = params['file'].read
66 @submission.source_filename = params['file'].original_filename
66 @submission.source_filename = params['file'].original_filename
67 end
67 end
68 @submission.submitted_at = Time.new.gmtime
68 @submission.submitted_at = Time.new.gmtime
69
69
70 - if Configuration.time_limit_mode? and user.contest_finished?
70 + if GraderConfiguration.time_limit_mode? and user.contest_finished?
71 @submission.errors.add_to_base "The contest is over."
71 @submission.errors.add_to_base "The contest is over."
72 prepare_list_information
72 prepare_list_information
73 render :action => 'list' and return
73 render :action => 'list' and return
74 end
74 end
75
75
76 if @submission.valid?
76 if @submission.valid?
@@ -126,26 +126,26
126 end
126 end
127 @submissions = Submission.find_all_by_user_problem(@user.id, @problem.id)
127 @submissions = Submission.find_all_by_user_problem(@user.id, @problem.id)
128 end
128 end
129 end
129 end
130
130
131 def result
131 def result
132 - if !Configuration.show_grading_result
132 + if !GraderConfiguration.show_grading_result
133 redirect_to :action => 'list' and return
133 redirect_to :action => 'list' and return
134 end
134 end
135 @user = User.find(session[:user_id])
135 @user = User.find(session[:user_id])
136 @submission = Submission.find(params[:id])
136 @submission = Submission.find(params[:id])
137 if @submission.user!=@user
137 if @submission.user!=@user
138 flash[:notice] = 'You are not allowed to view result of other users.'
138 flash[:notice] = 'You are not allowed to view result of other users.'
139 redirect_to :action => 'list' and return
139 redirect_to :action => 'list' and return
140 end
140 end
141 prepare_grading_result(@submission)
141 prepare_grading_result(@submission)
142 end
142 end
143
143
144 def load_output
144 def load_output
145 - if !Configuration.show_grading_result or params[:num]==nil
145 + if !GraderConfiguration.show_grading_result or params[:num]==nil
146 redirect_to :action => 'list' and return
146 redirect_to :action => 'list' and return
147 end
147 end
148 @user = User.find(session[:user_id])
148 @user = User.find(session[:user_id])
149 @submission = Submission.find(params[:id])
149 @submission = Submission.find(params[:id])
150 if @submission.user!=@user
150 if @submission.user!=@user
151 flash[:notice] = 'You are not allowed to view result of other users.'
151 flash[:notice] = 'You are not allowed to view result of other users.'
@@ -200,26 +200,26
200 end
200 end
201 end
201 end
202
202
203 protected
203 protected
204
204
205 def prepare_announcements(recent=nil)
205 def prepare_announcements(recent=nil)
206 - if Configuration.show_tasks_to?(@user)
206 + if GraderConfiguration.show_tasks_to?(@user)
207 @announcements = Announcement.find_published(true)
207 @announcements = Announcement.find_published(true)
208 else
208 else
209 @announcements = Announcement.find_published
209 @announcements = Announcement.find_published
210 end
210 end
211 if recent!=nil
211 if recent!=nil
212 recent_id = recent.to_i
212 recent_id = recent.to_i
213 @announcements = @announcements.find_all { |a| a.id > recent_id }
213 @announcements = @announcements.find_all { |a| a.id > recent_id }
214 end
214 end
215 end
215 end
216
216
217 def prepare_list_information
217 def prepare_list_information
218 @user = User.find(session[:user_id])
218 @user = User.find(session[:user_id])
219 - if not Configuration.multicontests?
219 + if not GraderConfiguration.multicontests?
220 @problems = @user.available_problems
220 @problems = @user.available_problems
221 else
221 else
222 @contest_problems = @user.available_problems_group_by_contests
222 @contest_problems = @user.available_problems_group_by_contests
223 @problems = @user.available_problems
223 @problems = @user.available_problems
224 end
224 end
225 @prob_submissions = {}
225 @prob_submissions = {}
@@ -233,21 +233,21
233 end
233 end
234 prepare_announcements
234 prepare_announcements
235 end
235 end
236
236
237 def check_viewability
237 def check_viewability
238 @user = User.find(session[:user_id])
238 @user = User.find(session[:user_id])
239 - if (!Configuration.show_tasks_to?(@user)) and
239 + if (!GraderConfiguration.show_tasks_to?(@user)) and
240 ((action_name=='submission') or (action_name=='submit'))
240 ((action_name=='submission') or (action_name=='submit'))
241 redirect_to :action => 'list' and return
241 redirect_to :action => 'list' and return
242 end
242 end
243 end
243 end
244
244
245 def prepare_grading_result(submission)
245 def prepare_grading_result(submission)
246 - if Configuration.task_grading_info.has_key? submission.problem.name
246 + if GraderConfiguration.task_grading_info.has_key? submission.problem.name
247 - grading_info = Configuration.task_grading_info[submission.problem.name]
247 + grading_info = GraderConfiguration.task_grading_info[submission.problem.name]
248 else
248 else
249 # guess task info from problem.full_score
249 # guess task info from problem.full_score
250 cases = submission.problem.full_score / 10
250 cases = submission.problem.full_score / 10
251 grading_info = {
251 grading_info = {
252 'testruns' => cases,
252 'testruns' => cases,
253 'testcases' => cases
253 'testcases' => cases
@@ -350,28 +350,28
350 :memory_usage => memory_used
350 :memory_usage => memory_used
351 }
351 }
352 end
352 end
353
353
354 def confirm_and_update_start_time
354 def confirm_and_update_start_time
355 user = User.find(session[:user_id])
355 user = User.find(session[:user_id])
356 - if (Configuration.indv_contest_mode? and
356 + if (GraderConfiguration.indv_contest_mode? and
357 - Configuration['contest.confirm_indv_contest_start'] and
357 + GraderConfiguration['contest.confirm_indv_contest_start'] and
358 !user.contest_started?)
358 !user.contest_started?)
359 redirect_to :action => 'confirm_contest_start' and return
359 redirect_to :action => 'confirm_contest_start' and return
360 end
360 end
361 - if not Configuration.analysis_mode?
361 + if not GraderConfiguration.analysis_mode?
362 user.update_start_time
362 user.update_start_time
363 end
363 end
364 end
364 end
365
365
366 def reject_announcement_refresh_when_logged_out
366 def reject_announcement_refresh_when_logged_out
367 if not session[:user_id]
367 if not session[:user_id]
368 render :text => 'Access forbidden', :status => 403
368 render :text => 'Access forbidden', :status => 403
369 end
369 end
370
370
371 - if Configuration.multicontests?
371 + if GraderConfiguration.multicontests?
372 user = User.find(session[:user_id])
372 user = User.find(session[:user_id])
373 if user.contest_stat.forced_logout
373 if user.contest_stat.forced_logout
374 render :text => 'Access forbidden', :status => 403
374 render :text => 'Access forbidden', :status => 403
375 end
375 end
376 end
376 end
377 end
377 end
@@ -16,13 +16,13
16 @countries.each do |country|
16 @countries.each do |country|
17 country.sites.each do |site|
17 country.sites.each do |site|
18 @site_select << ["#{site.name}, #{country.name}", site.id]
18 @site_select << ["#{site.name}, #{country.name}", site.id]
19 end
19 end
20 end
20 end
21
21
22 - @default_site = Site.first if !Configuration['contest.multisites']
22 + @default_site = Site.first if !GraderConfiguration['contest.multisites']
23
23
24 render :action => 'login', :layout => 'empty'
24 render :action => 'login', :layout => 'empty'
25 end
25 end
26
26
27 def index
27 def index
28 if @site.started
28 if @site.started
@@ -63,13 +63,13
63 send_file filename, :stream => false, :filename => base_filename, :type => content_type
63 send_file filename, :stream => false, :filename => base_filename, :type => content_type
64 end
64 end
65 end
65 end
66
66
67 def check_viewability
67 def check_viewability
68 @user = User.find(session[:user_id])
68 @user = User.find(session[:user_id])
69 - if @user==nil or !Configuration.show_tasks_to?(@user)
69 + if @user==nil or !GraderConfiguration.show_tasks_to?(@user)
70 redirect_to :controller => 'main', :action => 'list'
70 redirect_to :controller => 'main', :action => 'list'
71 return false
71 return false
72 end
72 end
73 end
73 end
74
74
75 end
75 end
@@ -21,20 +21,20
21
21
22 if @submitted_test_request.errors.length != 0
22 if @submitted_test_request.errors.length != 0
23 prepare_index_information
23 prepare_index_information
24 render :action => 'index' and return
24 render :action => 'index' and return
25 end
25 end
26
26
27 - if Configuration.time_limit_mode?
27 + if GraderConfiguration.time_limit_mode?
28 if @user.contest_finished?
28 if @user.contest_finished?
29 @submitted_test_request.errors.add_to_base('Contest is over.')
29 @submitted_test_request.errors.add_to_base('Contest is over.')
30 prepare_index_information
30 prepare_index_information
31 render :action => 'index' and return
31 render :action => 'index' and return
32 end
32 end
33
33
34 - if !Configuration.allow_test_request(@user)
34 + if !GraderConfiguration.allow_test_request(@user)
35 prepare_index_information
35 prepare_index_information
36 flash[:notice] = 'Test request is not allowed during the last 30 minutes'
36 flash[:notice] = 'Test request is not allowed during the last 30 minutes'
37 redirect_to :action => 'index' and return
37 redirect_to :action => 'index' and return
38 end
38 end
39 end
39 end
40
40
@@ -104,15 +104,15
104 end
104 end
105 end
105 end
106 end
106 end
107
107
108 def check_viewability
108 def check_viewability
109 user = User.find(session[:user_id])
109 user = User.find(session[:user_id])
110 - if !Configuration.show_tasks_to?(user)
110 + if !GraderConfiguration.show_tasks_to?(user)
111 redirect_to :controller => 'main', :action => 'list'
111 redirect_to :controller => 'main', :action => 'list'
112 end
112 end
113 - if (!Configuration.show_submitbox_to?(user)) and (action_name=='submit')
113 + if (!GraderConfiguration.show_submitbox_to?(user)) and (action_name=='submit')
114 redirect_to :controller => 'test', :action => 'index'
114 redirect_to :controller => 'test', :action => 'index'
115 end
115 end
116 end
116 end
117
117
118 end
118 end
@@ -1,26 +1,26
1 class UserAdminController < ApplicationController
1 class UserAdminController < ApplicationController
2
2
3 - include MailHelperMethods
3 + #include MailHelperMethods
4
4
5 before_filter :admin_authorization
5 before_filter :admin_authorization
6
6
7 - def index
8 - list
9 - render :action => 'list'
10 - end
11 -
12 # GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html)
7 # GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html)
13 verify :method => :post, :only => [ :destroy,
8 verify :method => :post, :only => [ :destroy,
14 :create, :create_from_list,
9 :create, :create_from_list,
15 :update,
10 :update,
16 :manage_contest,
11 :manage_contest,
17 :bulk_mail
12 :bulk_mail
18 ],
13 ],
19 :redirect_to => { :action => :list }
14 :redirect_to => { :action => :list }
20
15
16 + def index
17 + list
18 + render :action => 'list'
19 + end
20 +
21 def list
21 def list
22 @user_count = User.count
22 @user_count = User.count
23 if params[:page] == 'all'
23 if params[:page] == 'all'
24 @users = User.all
24 @users = User.all
25 @paginated = false
25 @paginated = false
26 else
26 else
@@ -421,13 +421,13
421 contest_stat.save
421 contest_stat.save
422 end
422 end
423 end
423 end
424 end
424 end
425
425
426 def send_contest_update_notification_email(user, contest)
426 def send_contest_update_notification_email(user, contest)
427 - contest_title_name = Configuration['contest.name']
427 + contest_title_name = GraderConfiguration['contest.name']
428 contest_name = contest.name
428 contest_name = contest.name
429 subject = t('contest.notification.email_subject', {
429 subject = t('contest.notification.email_subject', {
430 :contest_title_name => contest_title_name,
430 :contest_title_name => contest_title_name,
431 :contest_name => contest_name })
431 :contest_name => contest_name })
432 body = t('contest.notification.email_body', {
432 body = t('contest.notification.email_body', {
433 :full_name => user.full_name,
433 :full_name => user.full_name,
@@ -1,12 +1,12
1 require 'tmail'
1 require 'tmail'
2 require 'net/smtp'
2 require 'net/smtp'
3
3
4 class UsersController < ApplicationController
4 class UsersController < ApplicationController
5
5
6 - include MailHelperMethods
6 + #include MailHelperMethods
7
7
8 before_filter :authenticate, :except => [:new,
8 before_filter :authenticate, :except => [:new,
9 :register,
9 :register,
10 :confirm,
10 :confirm,
11 :forget,
11 :forget,
12 :retrieve_password]
12 :retrieve_password]
@@ -20,13 +20,13
20 :redirect_to => { :action => :index }
20 :redirect_to => { :action => :index }
21
21
22 #in_place_edit_for :user, :alias_for_editing
22 #in_place_edit_for :user, :alias_for_editing
23 #in_place_edit_for :user, :email_for_editing
23 #in_place_edit_for :user, :email_for_editing
24
24
25 def index
25 def index
26 - if !Configuration['system.user_setting_enabled']
26 + if !GraderConfiguration['system.user_setting_enabled']
27 redirect_to :controller => 'main', :action => 'list'
27 redirect_to :controller => 'main', :action => 'list'
28 else
28 else
29 @user = User.find(session[:user_id])
29 @user = User.find(session[:user_id])
30 end
30 end
31 end
31 end
32
32
@@ -56,13 +56,13
56 @user.password_confirmation = @user.password = User.random_password
56 @user.password_confirmation = @user.password = User.random_password
57 @user.activated = false
57 @user.activated = false
58 if (@user.valid?) and (@user.save)
58 if (@user.valid?) and (@user.save)
59 if send_confirmation_email(@user)
59 if send_confirmation_email(@user)
60 render :action => 'new_splash', :layout => 'empty'
60 render :action => 'new_splash', :layout => 'empty'
61 else
61 else
62 - @admin_email = Configuration['system.admin_email']
62 + @admin_email = GraderConfiguration['system.admin_email']
63 render :action => 'email_error', :layout => 'empty'
63 render :action => 'email_error', :layout => 'empty'
64 end
64 end
65 else
65 else
66 @user.errors.add_to_base("Email cannot be blank") if @user.email==''
66 @user.errors.add_to_base("Email cannot be blank") if @user.email==''
67 render :action => 'new', :layout => 'empty'
67 render :action => 'new', :layout => 'empty'
68 end
68 end
@@ -109,20 +109,20
109 redirect_to :action => 'forget'
109 redirect_to :action => 'forget'
110 end
110 end
111
111
112 protected
112 protected
113
113
114 def verify_online_registration
114 def verify_online_registration
115 - if !Configuration['system.online_registration']
115 + if !GraderConfiguration['system.online_registration']
116 redirect_to :controller => 'main', :action => 'login'
116 redirect_to :controller => 'main', :action => 'login'
117 end
117 end
118 end
118 end
119
119
120 def send_confirmation_email(user)
120 def send_confirmation_email(user)
121 - contest_name = Configuration['contest.name']
121 + contest_name = GraderConfiguration['contest.name']
122 - admin_email = Configuration['system.admin_email']
122 + admin_email = GraderConfiguration['system.admin_email']
123 activation_url = url_for(:action => 'confirm',
123 activation_url = url_for(:action => 'confirm',
124 :login => user.login,
124 :login => user.login,
125 :activation => user.activation_key)
125 :activation => user.activation_key)
126 home_url = url_for(:controller => 'main', :action => 'index')
126 home_url = url_for(:controller => 'main', :action => 'index')
127 subject = "[#{contest_name}] Confirmation"
127 subject = "[#{contest_name}] Confirmation"
128 body = t('registration.email_body', {
128 body = t('registration.email_body', {
@@ -137,14 +137,14
137 logger.info body
137 logger.info body
138
138
139 send_mail(user.email, subject, body)
139 send_mail(user.email, subject, body)
140 end
140 end
141
141
142 def send_new_password_email(user)
142 def send_new_password_email(user)
143 - contest_name = Configuration['contest.name']
143 + contest_name = GraderConfiguration['contest.name']
144 - admin_email = Configuration['system.admin_email']
144 + admin_email = GraderConfiguration['system.admin_email']
145 subject = "[#{contest_name}] Password recovery"
145 subject = "[#{contest_name}] Password recovery"
146 body = t('registration.password_retrieval.email_body', {
146 body = t('registration.password_retrieval.email_body', {
147 :full_name => user.full_name,
147 :full_name => user.full_name,
148 :contest_name => contest_name,
148 :contest_name => contest_name,
149 :login => user.login,
149 :login => user.login,
150 :password => user.password,
150 :password => user.password,
@@ -21,25 +21,25
21 end
21 end
22
22
23 # main page
23 # main page
24 append_to menu_items, "[#{I18n.t 'menu.main'}]", 'main', 'list'
24 append_to menu_items, "[#{I18n.t 'menu.main'}]", 'main', 'list'
25 append_to menu_items, "[#{I18n.t 'menu.messages'}]", 'messages', 'list'
25 append_to menu_items, "[#{I18n.t 'menu.messages'}]", 'messages', 'list'
26
26
27 - if (user!=nil) and (Configuration.show_tasks_to?(user))
27 + if (user!=nil) and (GraderConfiguration.show_tasks_to?(user))
28 append_to menu_items, "[#{I18n.t 'menu.tasks'}]", 'tasks', 'list'
28 append_to menu_items, "[#{I18n.t 'menu.tasks'}]", 'tasks', 'list'
29 append_to menu_items, "[#{I18n.t 'menu.submissions'}]", 'main', 'submission'
29 append_to menu_items, "[#{I18n.t 'menu.submissions'}]", 'main', 'submission'
30 append_to menu_items, "[#{I18n.t 'menu.test'}]", 'test', 'index'
30 append_to menu_items, "[#{I18n.t 'menu.test'}]", 'test', 'index'
31 end
31 end
32 append_to menu_items, "[#{I18n.t 'menu.help'}]", 'main', 'help'
32 append_to menu_items, "[#{I18n.t 'menu.help'}]", 'main', 'help'
33
33
34 - if Configuration['system.user_setting_enabled']
34 + if GraderConfiguration['system.user_setting_enabled']
35 append_to menu_items, "[#{I18n.t 'menu.settings'}]", 'users', 'index'
35 append_to menu_items, "[#{I18n.t 'menu.settings'}]", 'users', 'index'
36 end
36 end
37 append_to menu_items, "[#{I18n.t 'menu.log_out'}]", 'main', 'login'
37 append_to menu_items, "[#{I18n.t 'menu.log_out'}]", 'main', 'login'
38
38
39 - menu_items
39 + menu_items.html_safe
40 end
40 end
41
41
42 def append_to(option,label, controller, action)
42 def append_to(option,label, controller, action)
43 option << ' ' if option!=''
43 option << ' ' if option!=''
44 option << link_to_unless_current(label,
44 option << link_to_unless_current(label,
45 :controller => controller,
45 :controller => controller,
@@ -73,13 +73,13
73 def user_title_bar(user)
73 def user_title_bar(user)
74 header = ''
74 header = ''
75 time_left = ''
75 time_left = ''
76
76
77 #
77 #
78 # if the contest is over
78 # if the contest is over
79 - if Configuration.time_limit_mode?
79 + if GraderConfiguration.time_limit_mode?
80 if user.contest_finished?
80 if user.contest_finished?
81 header = <<CONTEST_OVER
81 header = <<CONTEST_OVER
82 <tr><td colspan="2" align="center">
82 <tr><td colspan="2" align="center">
83 <span class="contest-over-msg">THE CONTEST IS OVER</span>
83 <span class="contest-over-msg">THE CONTEST IS OVER</span>
84 </td></tr>
84 </td></tr>
85 CONTEST_OVER
85 CONTEST_OVER
@@ -91,25 +91,25
91 " #{format_short_duration(user.contest_time_left)}"
91 " #{format_short_duration(user.contest_time_left)}"
92 end
92 end
93 end
93 end
94
94
95 #
95 #
96 # if the contest is in the anaysis mode
96 # if the contest is in the anaysis mode
97 - if Configuration.analysis_mode?
97 + if GraderConfiguration.analysis_mode?
98 header = <<ANALYSISMODE
98 header = <<ANALYSISMODE
99 <tr><td colspan="2" align="center">
99 <tr><td colspan="2" align="center">
100 <span class="contest-over-msg">ANALYSIS MODE</span>
100 <span class="contest-over-msg">ANALYSIS MODE</span>
101 </td></tr>
101 </td></tr>
102 ANALYSISMODE
102 ANALYSISMODE
103 end
103 end
104
104
105 - contest_name = Configuration['contest.name']
105 + contest_name = GraderConfiguration['contest.name']
106
106
107 #
107 #
108 # build real title bar
108 # build real title bar
109 - <<TITLEBAR
109 + result = <<TITLEBAR
110 <div class="title">
110 <div class="title">
111 <table>
111 <table>
112 #{header}
112 #{header}
113 <tr>
113 <tr>
114 <td class="left-col">
114 <td class="left-col">
115 #{user.full_name}<br/>
115 #{user.full_name}<br/>
@@ -119,9 +119,10
119 </td>
119 </td>
120 <td class="right-col">#{contest_name}</td>
120 <td class="right-col">#{contest_name}</td>
121 </tr>
121 </tr>
122 </table>
122 </table>
123 </div>
123 </div>
124 TITLEBAR
124 TITLEBAR
125 + result.html_safe
125 end
126 end
126
127
127 end
128 end
@@ -7,13 +7,13
7 if !self.started
7 if !self.started
8 self.start_time = nil
8 self.start_time = nil
9 end
9 end
10 end
10 end
11
11
12 def time_left
12 def time_left
13 - contest_time = Configuration.contest_time_limit
13 + contest_time = GraderConfiguration.contest_time_limit
14
14
15 return nil if contest_time == nil
15 return nil if contest_time == nil
16
16
17 return contest_time if !self.started
17 return contest_time if !self.started
18
18
19 current_time = Time.now.gmtime
19 current_time = Time.now.gmtime
@@ -32,13 +32,13
32
32
33 def finished?
33 def finished?
34 if !self.started
34 if !self.started
35 return false
35 return false
36 end
36 end
37
37
38 - contest_time = Configuration.contest_time_limit
38 + contest_time = GraderConfiguration.contest_time_limit
39 if contest_time!=nil
39 if contest_time!=nil
40 return Time.now.gmtime > (self.start_time + contest_time)
40 return Time.now.gmtime > (self.start_time + contest_time)
41 else
41 else
42 false
42 false
43 end
43 end
44 end
44 end
@@ -133,17 +133,17
133 users = User.find(:all)
133 users = User.find(:all)
134 return users.find_all { |u| u.contests.length == 0 }
134 return users.find_all { |u| u.contests.length == 0 }
135 end
135 end
136
136
137
137
138 def contest_time_left
138 def contest_time_left
139 - if Configuration.contest_mode?
139 + if GraderConfiguration.contest_mode?
140 return nil if site==nil
140 return nil if site==nil
141 return site.time_left
141 return site.time_left
142 - elsif Configuration.indv_contest_mode?
142 + elsif GraderConfiguration.indv_contest_mode?
143 - time_limit = Configuration.contest_time_limit
143 + time_limit = GraderConfiguration.contest_time_limit
144 if time_limit == nil
144 if time_limit == nil
145 return nil
145 return nil
146 end
146 end
147 if contest_stat==nil or contest_stat.started_at==nil
147 if contest_stat==nil or contest_stat.started_at==nil
148 return (Time.now.gmtime + time_limit) - Time.now.gmtime
148 return (Time.now.gmtime + time_limit) - Time.now.gmtime
149 else
149 else
@@ -158,28 +158,28
158 else
158 else
159 return nil
159 return nil
160 end
160 end
161 end
161 end
162
162
163 def contest_finished?
163 def contest_finished?
164 - if Configuration.contest_mode?
164 + if GraderConfiguration.contest_mode?
165 return false if site==nil
165 return false if site==nil
166 return site.finished?
166 return site.finished?
167 - elsif Configuration.indv_contest_mode?
167 + elsif GraderConfiguration.indv_contest_mode?
168 return false if self.contest_stat(true)==nil
168 return false if self.contest_stat(true)==nil
169 return contest_time_left == 0
169 return contest_time_left == 0
170 else
170 else
171 return false
171 return false
172 end
172 end
173 end
173 end
174
174
175 def contest_started?
175 def contest_started?
176 - if Configuration.indv_contest_mode?
176 + if GraderConfiguration.indv_contest_mode?
177 stat = self.contest_stat
177 stat = self.contest_stat
178 return ((stat != nil) and (stat.started_at != nil))
178 return ((stat != nil) and (stat.started_at != nil))
179 - elsif Configuration.contest_mode?
179 + elsif GraderConfiguration.contest_mode?
180 return true if site==nil
180 return true if site==nil
181 return site.started
181 return site.started
182 else
182 else
183 return true
183 return true
184 end
184 end
185 end
185 end
@@ -225,13 +225,13
225 :problems => other_avaiable_problems
225 :problems => other_avaiable_problems
226 }
226 }
227 return contest_problems
227 return contest_problems
228 end
228 end
229
229
230 def available_problems
230 def available_problems
231 - if not Configuration.multicontests?
231 + if not GraderConfiguration.multicontests?
232 return Problem.find_available_problems
232 return Problem.find_available_problems
233 else
233 else
234 contest_problems = []
234 contest_problems = []
235 pin = {}
235 pin = {}
236 contests.enabled.each do |contest|
236 contests.enabled.each do |contest|
237 contest.problems.available.each do |problem|
237 contest.problems.available.each do |problem|
@@ -244,13 +244,13
244 other_avaiable_problems = Problem.available.find_all {|p| pin[p.id]==nil and p.contests.length==0}
244 other_avaiable_problems = Problem.available.find_all {|p| pin[p.id]==nil and p.contests.length==0}
245 return contest_problems + other_avaiable_problems
245 return contest_problems + other_avaiable_problems
246 end
246 end
247 end
247 end
248
248
249 def can_view_problem?(problem)
249 def can_view_problem?(problem)
250 - if not Configuration.multicontests?
250 + if not GraderConfiguration.multicontests?
251 return problem.available
251 return problem.available
252 else
252 else
253 return problem_in_user_contests? problem
253 return problem_in_user_contests? problem
254 end
254 end
255 end
255 end
256
256
@@ -275,13 +275,13
275 end
275 end
276
276
277 def assign_default_contest
277 def assign_default_contest
278 # have to catch error when migrating (because self.site is not available).
278 # have to catch error when migrating (because self.site is not available).
279 begin
279 begin
280 if self.contests.length == 0
280 if self.contests.length == 0
281 - default_contest = Contest.find_by_name(Configuration['contest.default_contest_name'])
281 + default_contest = Contest.find_by_name(GraderConfiguration['contest.default_contest_name'])
282 if default_contest
282 if default_contest
283 self.contests = [default_contest]
283 self.contests = [default_contest]
284 end
284 end
285 end
285 end
286 rescue
286 rescue
287 end
287 end
@@ -17,13 +17,13
17 %td
17 %td
18 = in_place_editor_field :configuration, :value_type, {}, :rows=>1
18 = in_place_editor_field :configuration, :value_type, {}, :rows=>1
19 %td
19 %td
20 = in_place_editor_field :configuration, :value, {}, :rows=>1
20 = in_place_editor_field :configuration, :value, {}, :rows=>1
21 %td= conf.description
21 %td= conf.description
22
22
23 - - if Configuration.config_cached?
23 + - if GraderConfiguration.config_cached?
24 %br/
24 %br/
25 Your config is saved, but it does not automatically take effect.
25 Your config is saved, but it does not automatically take effect.
26 %br/
26 %br/
27 If you have one mongrel process running, you can
27 If you have one mongrel process running, you can
28 = link_to '[click]', :action => 'reload'
28 = link_to '[click]', :action => 'reload'
29 here to reload.
29 here to reload.
@@ -8,24 +8,24
8 - else
8 - else
9 %b Single contest:
9 %b Single contest:
10 = "[#{link_to 'Add/remove contests', :controller => 'contests', :action => 'index'}]"
10 = "[#{link_to 'Add/remove contests', :controller => 'contests', :action => 'index'}]"
11
11
12 .infobox
12 .infobox
13 %b Web interface mode:
13 %b Web interface mode:
14 - - if (not Configuration.contest_mode?) and (not Configuration.indv_contest_mode?)
14 + - if (not GraderConfiguration.contest_mode?) and (not GraderConfiguration.indv_contest_mode?)
15 standard mode
15 standard mode
16 - - elsif Configuration.contest_mode?
16 + - elsif GraderConfiguration.contest_mode?
17 normal contest mode.
17 normal contest mode.
18 - else
18 - else
19 individual contest mode.
19 individual contest mode.
20
20
21 %br/
21 %br/
22 Change mode to:
22 Change mode to:
23 = "[#{link_to 'standard', :action => 'change_contest_mode', :id => 'standard'}]"
23 = "[#{link_to 'standard', :action => 'change_contest_mode', :id => 'standard'}]"
24 = "[#{link_to 'contest', :action => 'change_contest_mode', :id => 'contest'}]"
24 = "[#{link_to 'contest', :action => 'change_contest_mode', :id => 'contest'}]"
25 = "[#{link_to 'individual contest', :action => 'change_contest_mode', :id => 'indv-contest'}]"
25 = "[#{link_to 'individual contest', :action => 'change_contest_mode', :id => 'indv-contest'}]"
26
26
27 - - if Configuration.indv_contest_mode?
27 + - if GraderConfiguration.indv_contest_mode?
28 = render :partial => 'indv_contest_mode_index'
28 = render :partial => 'indv_contest_mode_index'
29
29
30 %br/
30 %br/
31
31
@@ -1,14 +1,21
1 <!DOCTYPE html>
1 <!DOCTYPE html>
2 <html>
2 <html>
3 <head>
3 <head>
4 - <title>CafeGraderWeb</title>
4 + <title><%= GraderConfiguration['contest.name'] %></title>
5 - <%= stylesheet_link_tag "application", :media => "all" %>
5 + <%= stylesheet_link_tag "application", :media => "all" %>
6 <%= javascript_include_tag "application" %>
6 <%= javascript_include_tag "application" %>
7 <%= csrf_meta_tags %>
7 <%= csrf_meta_tags %>
8 + <%= yield :head %>
8 </head>
9 </head>
9 <body>
10 <body>
10
11
12 + <div class="userbar">
13 + <%= user_header %>
14 + </div>
15 +
16 + <%= content_tag(:p,flash[:notice],:style => "color:green") if flash[:notice]!=nil %>
17 +
11 <%= yield %>
18 <%= yield %>
12
19
13 </body>
20 </body>
14 </html>
21 </html>
@@ -1,13 +1,13
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
3
4 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5 <head>
5 <head>
6 <meta http-equiv="content-type" content="text/html;charset=UTF-8" />
6 <meta http-equiv="content-type" content="text/html;charset=UTF-8" />
7 - <title><%= Configuration['contest.name'] %></title>
7 + <title><%= GraderConfiguration['contest.name'] %></title>
8 <%= stylesheet_link_tag 'application' %>
8 <%= stylesheet_link_tag 'application' %>
9 </head>
9 </head>
10 <body>
10 <body>
11
11
12 <%= yield %>
12 <%= yield %>
13
13
@@ -1,7 +1,7
1 - %b= Configuration['ui.front.welcome_message']
1 + %b= GraderConfiguration['ui.front.welcome_message']
2 %br/
2 %br/
3
3
4 - if !@hidelogin
4 - if !@hidelogin
5 =t 'login.message'
5 =t 'login.message'
6 %br/
6 %br/
7 %br/
7 %br/
@@ -22,13 +22,13
22 %td{:align => "right"}
22 %td{:align => "right"}
23 ="#{t 'password_label'}:"
23 ="#{t 'password_label'}:"
24 %td= password_field_tag
24 %td= password_field_tag
25 = submit_tag t('login.login_submit')
25 = submit_tag t('login.login_submit')
26 %br/
26 %br/
27
27
28 - - if Configuration['system.online_registration']
28 + - if GraderConfiguration['system.online_registration']
29 =t 'login.participation'
29 =t 'login.participation'
30 %b
30 %b
31 = "#{t 'login.please'} "
31 = "#{t 'login.please'} "
32 = link_to "#{t 'login.register'}", :controller => :users, :action => :new
32 = link_to "#{t 'login.register'}", :controller => :users, :action => :new
33 %br/
33 %br/
34 = link_to "#{t 'login.forget_password'}", :controller => :users, :action => :forget
34 = link_to "#{t 'login.forget_password'}", :controller => :users, :action => :forget
@@ -6,13 +6,13
6 %td.info{:align => "center"}
6 %td.info{:align => "center"}
7 = link_to('[load]',{:action => 'source', :id => submission.id})
7 = link_to('[load]',{:action => 'source', :id => submission.id})
8 %td.info
8 %td.info
9 - if submission.graded_at!=nil
9 - if submission.graded_at!=nil
10 = "Graded at #{format_short_time(submission.graded_at)}."
10 = "Graded at #{format_short_time(submission.graded_at)}."
11 %br/
11 %br/
12 - = "Score: #{(submission.points*100/submission.problem.full_score).to_i} " if Configuration['ui.show_score']
12 + = "Score: #{(submission.points*100/submission.problem.full_score).to_i} " if GraderConfiguration['ui.show_score']
13 = " ["
13 = " ["
14 %tt
14 %tt
15 = submission.grader_comment
15 = submission.grader_comment
16 = "]"
16 = "]"
17 %td.info
17 %td.info
18 = render :partial => 'compiler_message', :locals => {:compiler_message => submission.compiler_message }
18 = render :partial => 'compiler_message', :locals => {:compiler_message => submission.compiler_message }
@@ -5,20 +5,20
5 - if submission.graded_at==nil
5 - if submission.graded_at==nil
6 =t 'main.submitted_at'
6 =t 'main.submitted_at'
7 = format_short_time(submission.submitted_at.localtime)
7 = format_short_time(submission.submitted_at.localtime)
8 - else
8 - else
9 = t 'main.graded_at'
9 = t 'main.graded_at'
10 = "#{format_short_time(submission.graded_at.localtime)}, "
10 = "#{format_short_time(submission.graded_at.localtime)}, "
11 - - if Configuration['ui.show_score']
11 + - if GraderConfiguration['ui.show_score']
12 = t 'main.score'
12 = t 'main.score'
13 = "#{(submission.points*100/submission.problem.full_score).to_i} "
13 = "#{(submission.points*100/submission.problem.full_score).to_i} "
14 = " ["
14 = " ["
15 %tt
15 %tt
16 = submission.grader_comment
16 = submission.grader_comment
17 = "]"
17 = "]"
18 - - if Configuration.show_grading_result
18 + - if GraderConfiguration.show_grading_result
19 = " | "
19 = " | "
20 = link_to '[detailed result]', :action => 'result', :id => submission.id
20 = link_to '[detailed result]', :action => 'result', :id => submission.id
21 = " | "
21 = " | "
22 = link_to("[#{t 'main.cmp_msg'}]", {:action => 'compiler_msg', :id => submission.id}, {:popup => true})
22 = link_to("[#{t 'main.cmp_msg'}]", {:action => 'compiler_msg', :id => submission.id}, {:popup => true})
23 = " | "
23 = " | "
24 = link_to("[#{t 'main.src_link'}]",{:action => 'source', :id => submission.id})
24 = link_to("[#{t 'main.src_link'}]",{:action => 'source', :id => submission.id})
@@ -1,47 +1,47
1 = user_title_bar(@user)
1 = user_title_bar(@user)
2
2
3 .announcementbox
3 .announcementbox
4 %span{:class => 'title'}
4 %span{:class => 'title'}
5 - =t 'help.how_to_submit'
5 + =raw t 'help.how_to_submit'
6 .announcement
6 .announcement
7 %p
7 %p
8 - =t 'help.must_specify_language'
8 + =raw t 'help.must_specify_language'
9
9
10 %p
10 %p
11 - =t 'help.list_available_language'
11 + =raw t 'help.list_available_language'
12
12
13 %table{:border => '1'}
13 %table{:border => '1'}
14 %tr
14 %tr
15 %th{:width => '150px'} C
15 %th{:width => '150px'} C
16 %th{:width => '150px'} C++
16 %th{:width => '150px'} C++
17 %th{:width => '150px'} Pascal
17 %th{:width => '150px'} Pascal
18 %tr
18 %tr
19 - %td= "<tt>/*<br/>LANG: C<br/>*/</tt>"
19 + %td=raw "<tt>/*<br/>LANG: C<br/>*/</tt>"
20 - %td= "<tt>/*<br/>LANG: C++<br/>*/</tt>"
20 + %td=raw "<tt>/*<br/>LANG: C++<br/>*/</tt>"
21 - %td= "<tt>{<br/>LANG: Pascal<br/>}</tt>"
21 + %td=raw "<tt>{<br/>LANG: Pascal<br/>}</tt>"
22
22
23 %p
23 %p
24 - =t 'help.accept_only_language_specified'
24 + =raw t 'help.accept_only_language_specified'
25
25
26 %p
26 %p
27 - =t 'help.specifying_task'
27 + =raw t 'help.specifying_task'
28
28
29 %p
29 %p
30 - =t 'help.example_cpp'
30 + =raw t 'help.example_cpp'
31
31
32 %table{:border => '1'}
32 %table{:border => '1'}
33 %tr
33 %tr
34 %td{:width => '300px'}
34 %td{:width => '300px'}
35 %tt <tt>/*<br/>LANG: C++<br/>TASK: mobiles<br/>*/</tt>
35 %tt <tt>/*<br/>LANG: C++<br/>TASK: mobiles<br/>*/</tt>
36
36
37 %p
37 %p
38 - =t 'help.example_pas'
38 + =raw t 'help.example_pas'
39
39
40 %table{:border => '1'}
40 %table{:border => '1'}
41 %tr
41 %tr
42 %td{:width => '300px'}
42 %td{:width => '300px'}
43 %tt <tt>{<br/>LANG: Pascal<br/>TASK: mobiles<br/>}</tt>
43 %tt <tt>{<br/>LANG: Pascal<br/>TASK: mobiles<br/>}</tt>
44
44
45 %p
45 %p
46 - = (t('help.ask_questions_at_messages',:message_link_name => (t 'menu.messages'),:url => url_for(:controller => 'messages', :action => 'list')))
46 + = raw(t('help.ask_questions_at_messages',:message_link_name => (t 'menu.messages'),:url => url_for(:controller => 'messages', :action => 'list')))
47
47
@@ -7,25 +7,25
7 .announcementbox{:style => (@announcements.length==0 ? "display:none" : "")}
7 .announcementbox{:style => (@announcements.length==0 ? "display:none" : "")}
8 %span{:class => 'title'}
8 %span{:class => 'title'}
9 Announcements
9 Announcements
10 #announcementbox-body
10 #announcementbox-body
11 = render :partial => 'announcement', :collection => @announcements
11 = render :partial => 'announcement', :collection => @announcements
12
12
13 - - if Configuration.show_submitbox_to?(@user)
13 + - if GraderConfiguration.show_submitbox_to?(@user)
14 .submitbox
14 .submitbox
15 = error_messages_for 'submission'
15 = error_messages_for 'submission'
16 = render :partial => 'submission_box'
16 = render :partial => 'submission_box'
17
17
18
18
19 %hr/
19 %hr/
20
20
21 - - if (Configuration.contest_mode?) and (@user.site!=nil) and (@user.site.started!=true)
21 + - if (GraderConfiguration.contest_mode?) and (@user.site!=nil) and (@user.site.started!=true)
22 %p=t 'main.start_soon'
22 %p=t 'main.start_soon'
23
23
24 - - if Configuration.show_tasks_to?(@user)
24 + - if GraderConfiguration.show_tasks_to?(@user)
25 - - if not Configuration.multicontests?
25 + - if not GraderConfiguration.multicontests?
26 %table.info
26 %table.info
27 %tr.info-head
27 %tr.info-head
28 %th
28 %th
29 %th Tasks
29 %th Tasks
30 %th # of sub(s)
30 %th # of sub(s)
31 %th Results
31 %th Results
@@ -1,7 +1,7
1 - %h1= Configuration['ui.front.title']
1 + %h1= GraderConfiguration['ui.front.title']
2
2
3 %table
3 %table
4 %tr
4 %tr
5 %td
5 %td
6 - if @announcements.length!=0
6 - if @announcements.length!=0
7 .announcementbox{:style => 'margin-top: 0px'}
7 .announcementbox{:style => 'margin-top: 0px'}
@@ -8,13 +8,13
8 = "Submission: #{@submission.number}"
8 = "Submission: #{@submission.number}"
9 %br/
9 %br/
10 = "Submitted at: #{format_short_time(@submission.submitted_at)}"
10 = "Submitted at: #{format_short_time(@submission.submitted_at)}"
11 %br/
11 %br/
12 = "Graded at #{format_short_time(@submission.graded_at)} "
12 = "Graded at #{format_short_time(@submission.graded_at)} "
13 %br/
13 %br/
14 - = "score: #{(@submission.points*100/@submission.problem.full_score).to_i} " if Configuration['ui.show_score']
14 + = "score: #{(@submission.points*100/@submission.problem.full_score).to_i} " if GraderConfiguration['ui.show_score']
15 = " ["
15 = " ["
16 %tt
16 %tt
17 = @submission.grader_comment
17 = @submission.grader_comment
18 = "]"
18 = "]"
19
19
20 %table.info
20 %table.info
@@ -14,31 +14,31
14 %li
14 %li
15 Change date added to
15 Change date added to
16 = select_date Date.current, :prefix => 'date_added'
16 = select_date Date.current, :prefix => 'date_added'
17 &nbsp;&nbsp;&nbsp;
17 &nbsp;&nbsp;&nbsp;
18 = submit_tag 'Change', :name => 'change_date_added'
18 = submit_tag 'Change', :name => 'change_date_added'
19
19
20 - - if Configuration.multicontests?
20 + - if GraderConfiguration.multicontests?
21 %li
21 %li
22 Add to
22 Add to
23 = select("contest","id",Contest.all.collect {|c| [c.title, c.id]})
23 = select("contest","id",Contest.all.collect {|c| [c.title, c.id]})
24 = submit_tag 'Add', :name => 'add_to_contest'
24 = submit_tag 'Add', :name => 'add_to_contest'
25
25
26 %table
26 %table
27 %tr
27 %tr
28 %th/
28 %th/
29 %th Name
29 %th Name
30 %th Full name
30 %th Full name
31 %th Date added
31 %th Date added
32 - - if Configuration.multicontests?
32 + - if GraderConfiguration.multicontests?
33 %th Contests
33 %th Contests
34
34
35 - for problem in @problems
35 - for problem in @problems
36 %tr{:id => "row-prob-#{problem.id}", :name=> "prob-#{problem.id}"}
36 %tr{:id => "row-prob-#{problem.id}", :name=> "prob-#{problem.id}"}
37 %td= check_box_tag "prob-#{problem.id}"
37 %td= check_box_tag "prob-#{problem.id}"
38 %td= problem.name
38 %td= problem.name
39 %td= problem.full_name
39 %td= problem.full_name
40 %td= problem.date_added
40 %td= problem.date_added
41 - - if Configuration.multicontests?
41 + - if GraderConfiguration.multicontests?
42 %td
42 %td
43 - problem.contests.each do |contest|
43 - problem.contests.each do |contest|
44 = "(#{contest.name} [#{link_to 'x', :action => 'remove_contest', :id => problem.id, :contest_id => contest.id }])"
44 = "(#{contest.name} [#{link_to 'x', :action => 'remove_contest', :id => problem.id, :contest_id => contest.id }])"
@@ -1,13 +1,13
1 <%= user_title_bar(@user) %>
1 <%= user_title_bar(@user) %>
2
2
3 <h2><%=t 'test.title' %></h2>
3 <h2><%=t 'test.title' %></h2>
4
4
5 <div class="test-desc">
5 <div class="test-desc">
6 <%=t 'test.intro' %><br/>
6 <%=t 'test.intro' %><br/>
7 - <% if Configuration['contest.test_request.early_timeout'] %>
7 + <% if GraderConfiguration['contest.test_request.early_timeout'] %>
8 <%=t 'test.disabled_at_end_announcement' %>
8 <%=t 'test.disabled_at_end_announcement' %>
9 <% end %>
9 <% end %>
10 </div>
10 </div>
11
11
12 <% if @problems.length==0 %>
12 <% if @problems.length==0 %>
13 There is no submission
13 There is no submission
@@ -34,13 +34,13
34 submissionSelect.add(new Option(""+i,""+i,false,false));
34 submissionSelect.add(new Option(""+i,""+i,false,false));
35 }
35 }
36 }
36 }
37 }
37 }
38 </script>
38 </script>
39
39
40 - <% if Configuration.show_submitbox_to?(@user) and Configuration.allow_test_request(@user) %>
40 + <% if GraderConfiguration.show_submitbox_to?(@user) and GraderConfiguration.allow_test_request(@user) %>
41 <div class="submitbox">
41 <div class="submitbox">
42 <%= error_messages_for 'submitted_test_request' %>
42 <%= error_messages_for 'submitted_test_request' %>
43 <% form_for :test_request, nil,
43 <% form_for :test_request, nil,
44 :url => { :action => 'submit'},
44 :url => { :action => 'submit'},
45 :html => { :multipart => true } do |f| %>
45 :html => { :multipart => true } do |f| %>
46 <table>
46 <table>
@@ -2,13 +2,13
2 List users in <% if @contest %><%= @contest.title %>
2 List users in <% if @contest %><%= @contest.title %>
3 <% else %>Users not in any contests<% end %>
3 <% else %>Users not in any contests<% end %>
4 </h1>
4 </h1>
5
5
6 <div class="submitbox">
6 <div class="submitbox">
7 <%= link_to '[View all users]', :action => 'list' %>
7 <%= link_to '[View all users]', :action => 'list' %>
8 - <% if Configuration.multicontests? %>
8 + <% if GraderConfiguration.multicontests? %>
9 <%= link_to '[Manage bulk users in contests]', :action => 'contest_management' %>
9 <%= link_to '[Manage bulk users in contests]', :action => 'contest_management' %>
10 <br/>
10 <br/>
11 View users in:
11 View users in:
12 <% @contests.each do |contest| %>
12 <% @contests.each do |contest| %>
13 <%= link_to "[#{contest.name}]", :action => 'contests', :id => contest.id %>
13 <%= link_to "[#{contest.name}]", :action => 'contests', :id => contest.id %>
14 <% end %>
14 <% end %>
@@ -29,13 +29,13
29 <th>Full name</th>
29 <th>Full name</th>
30 <th>Email</th>
30 <th>Email</th>
31 <th>Activated?</th>
31 <th>Activated?</th>
32 <th></th>
32 <th></th>
33 <th></th>
33 <th></th>
34 <th></th>
34 <th></th>
35 - <% if Configuration.multicontests? %>
35 + <% if GraderConfiguration.multicontests? %>
36 <th>Contests</th>
36 <th>Contests</th>
37 <th>Other enabled contests</th>
37 <th>Other enabled contests</th>
38 <% end %>
38 <% end %>
39 </tr>
39 </tr>
40
40
41 <% for user in @users %>
41 <% for user in @users %>
@@ -44,13 +44,13
44 <td><%=h user.full_name %></td>
44 <td><%=h user.full_name %></td>
45 <td><%=h user.email %></td>
45 <td><%=h user.email %></td>
46 <td><%=h user.activated %></td>
46 <td><%=h user.activated %></td>
47 <td><%= link_to 'Show', :action => 'show', :id => user %></td>
47 <td><%= link_to 'Show', :action => 'show', :id => user %></td>
48 <td><%= link_to 'Edit', :action => 'edit', :id => user %></td>
48 <td><%= link_to 'Edit', :action => 'edit', :id => user %></td>
49 <td><%= link_to 'Destroy', { :action => 'destroy', :id => user }, :confirm => 'Are you sure?', :method => :post %></td>
49 <td><%= link_to 'Destroy', { :action => 'destroy', :id => user }, :confirm => 'Are you sure?', :method => :post %></td>
50 - <% if Configuration.multicontests? %>
50 + <% if GraderConfiguration.multicontests? %>
51 <td>
51 <td>
52 <% user.contests.each do |contest| %>
52 <% user.contests.each do |contest| %>
53 <%= contest.name %> [<%= link_to 'x', :action => 'remove_from_contest', :id => user.id, :contest_id => contest.id %>]
53 <%= contest.name %> [<%= link_to 'x', :action => 'remove_from_contest', :id => user.id, :contest_id => contest.id %>]
54 <% end %>
54 <% end %>
55 </td>
55 </td>
56 <td>
56 <td>
@@ -1,9 +1,9
1 .contest-title
1 .contest-title
2 %h1
2 %h1
3 - = "#{Configuration['contest.name']}: #{t 'registration.password_retrieval.header'}"
3 + = "#{GraderConfiguration['contest.name']}: #{t 'registration.password_retrieval.header'}"
4
4
5 - if flash[:notice]
5 - if flash[:notice]
6 %hr/
6 %hr/
7 %b= flash[:notice]
7 %b= flash[:notice]
8 %hr/
8 %hr/
9
9
@@ -1,9 +1,9
1 .contest-title
1 .contest-title
2 %h1
2 %h1
3 - = "#{Configuration['contest.name']}: #{t 'registration.title'}"
3 + = "#{GraderConfiguration['contest.name']}: #{t 'registration.title'}"
4
4
5 .registration-desc
5 .registration-desc
6 =t 'registration.description'
6 =t 'registration.description'
7
7
8 = error_messages_for :user, :header_message => (t 'registration.errors.header')
8 = error_messages_for :user, :header_message => (t 'registration.errors.header')
9
9
@@ -51,12 +51,12
51 # This will create an empty whitelist of attributes available for mass-assignment for all models
51 # This will create an empty whitelist of attributes available for mass-assignment for all models
52 # in your app. As such, your models will need to explicitly whitelist or blacklist accessible
52 # in your app. As such, your models will need to explicitly whitelist or blacklist accessible
53 # parameters by using an attr_accessible or attr_protected declaration.
53 # parameters by using an attr_accessible or attr_protected declaration.
54 config.active_record.whitelist_attributes = true
54 config.active_record.whitelist_attributes = true
55
55
56 # Enable the asset pipeline
56 # Enable the asset pipeline
57 - config.assets.enabled = true
57 + config.assets.enabled = false
58
58
59 # Version of your assets, change this if you want to expire all your assets
59 # Version of your assets, change this if you want to expire all your assets
60 config.assets.version = '1.0'
60 config.assets.version = '1.0'
61 end
61 end
62 end
62 end
@@ -1,18 +1,20
1 - # This file is auto-generated from the current state of the database. Instead of editing this file,
1 + # encoding: UTF-8
2 - # please use the migrations feature of Active Record to incrementally modify your database, and
2 + # This file is auto-generated from the current state of the database. Instead
3 - # then regenerate this schema definition.
3 + # of editing this file, please use the migrations feature of Active Record to
4 + # incrementally modify your database, and then regenerate this schema definition.
4 #
5 #
5 - # Note that this schema.rb definition is the authoritative source for your database schema. If you need
6 + # Note that this schema.rb definition is the authoritative source for your
6 - # to create the application database on another system, you should be using db:schema:load, not running
7 + # database schema. If you need to create the application database on another
7 - # all the migrations from scratch. The latter is a flawed and unsustainable approach (the more migrations
8 + # system, you should be using db:schema:load, not running all the migrations
9 + # from scratch. The latter is a flawed and unsustainable approach (the more migrations
8 # you'll amass, the slower it'll run and the greater likelihood for issues).
10 # you'll amass, the slower it'll run and the greater likelihood for issues).
9 #
11 #
10 # It's strongly recommended to check this file into your version control system.
12 # It's strongly recommended to check this file into your version control system.
11
13
12 - ActiveRecord::Schema.define(:version => 20100506163112) do
14 + ActiveRecord::Schema.define(:version => 20121001033508) do
13
15
14 create_table "announcements", :force => true do |t|
16 create_table "announcements", :force => true do |t|
15 t.string "author"
17 t.string "author"
16 t.text "body"
18 t.text "body"
17 t.boolean "published"
19 t.boolean "published"
18 t.datetime "created_at"
20 t.datetime "created_at"
@@ -20,19 +22,18
20 t.boolean "frontpage", :default => false
22 t.boolean "frontpage", :default => false
21 t.boolean "contest_only", :default => false
23 t.boolean "contest_only", :default => false
22 t.string "title"
24 t.string "title"
23 t.string "notes"
25 t.string "notes"
24 end
26 end
25
27
26 - create_table "configurations", :force => true do |t|
28 + create_table "codejom_statuses", :force => true do |t|
27 - t.string "key"
29 + t.integer "user_id"
28 - t.string "value_type"
30 + t.boolean "alive"
29 - t.string "value"
31 + t.integer "num_problems_passed"
30 t.datetime "created_at"
32 t.datetime "created_at"
31 t.datetime "updated_at"
33 t.datetime "updated_at"
32 - t.text "description"
33 end
34 end
34
35
35 create_table "contests", :force => true do |t|
36 create_table "contests", :force => true do |t|
36 t.string "title"
37 t.string "title"
37 t.boolean "enabled"
38 t.boolean "enabled"
38 t.datetime "created_at"
39 t.datetime "created_at"
@@ -60,12 +61,21
60 t.text "body"
61 t.text "body"
61 t.boolean "markdowned"
62 t.boolean "markdowned"
62 t.datetime "created_at"
63 t.datetime "created_at"
63 t.datetime "updated_at"
64 t.datetime "updated_at"
64 end
65 end
65
66
67 + create_table "grader_configurations", :force => true do |t|
68 + t.string "key"
69 + t.string "value_type"
70 + t.string "value"
71 + t.datetime "created_at"
72 + t.datetime "updated_at"
73 + t.text "description"
74 + end
75 +
66 create_table "grader_processes", :force => true do |t|
76 create_table "grader_processes", :force => true do |t|
67 t.string "host", :limit => 20
77 t.string "host", :limit => 20
68 t.integer "pid"
78 t.integer "pid"
69 t.string "mode"
79 t.string "mode"
70 t.boolean "active"
80 t.boolean "active"
71 t.datetime "created_at"
81 t.datetime "created_at"
@@ -92,22 +102,24
92 t.boolean "replied"
102 t.boolean "replied"
93 t.datetime "created_at"
103 t.datetime "created_at"
94 t.datetime "updated_at"
104 t.datetime "updated_at"
95 end
105 end
96
106
97 create_table "problems", :force => true do |t|
107 create_table "problems", :force => true do |t|
98 - t.string "name", :limit => 30
108 + t.string "name", :limit => 30
99 - t.string "full_name"
109 + t.string "full_name"
100 - t.integer "full_score"
110 + t.integer "full_score"
101 - t.date "date_added"
111 + t.date "date_added"
102 - t.boolean "available"
112 + t.boolean "available"
103 - t.string "url"
113 + t.string "url"
104 - t.integer "description_id"
114 + t.integer "description_id"
105 - t.boolean "test_allowed"
115 + t.boolean "test_allowed"
106 - t.boolean "output_only"
116 + t.boolean "output_only"
107 - t.string "description_filename"
117 + t.integer "level", :default => 0
118 + t.datetime "updated_at"
119 + t.string "description_filename"
108 end
120 end
109
121
110 create_table "rights", :force => true do |t|
122 create_table "rights", :force => true do |t|
111 t.string "name"
123 t.string "name"
112 t.string "controller"
124 t.string "controller"
113 t.string "action"
125 t.string "action"
@@ -147,12 +159,21
147 t.datetime "created_at"
159 t.datetime "created_at"
148 t.datetime "updated_at"
160 t.datetime "updated_at"
149 t.integer "country_id"
161 t.integer "country_id"
150 t.string "password"
162 t.string "password"
151 end
163 end
152
164
165 + create_table "submission_statuses", :force => true do |t|
166 + t.integer "user_id"
167 + t.integer "problem_id"
168 + t.boolean "passed"
169 + t.integer "submission_count"
170 + t.datetime "created_at"
171 + t.datetime "updated_at"
172 + end
173 +
153 create_table "submissions", :force => true do |t|
174 create_table "submissions", :force => true do |t|
154 t.integer "user_id"
175 t.integer "user_id"
155 t.integer "problem_id"
176 t.integer "problem_id"
156 t.integer "language_id"
177 t.integer "language_id"
157 t.text "source"
178 t.text "source"
158 t.binary "binary"
179 t.binary "binary"
@@ -173,18 +194,30
173 t.integer "submission_id"
194 t.integer "submission_id"
174 t.datetime "created_at"
195 t.datetime "created_at"
175 t.integer "status"
196 t.integer "status"
176 t.datetime "updated_at"
197 t.datetime "updated_at"
177 end
198 end
178
199
200 + create_table "test_pair_assignments", :force => true do |t|
201 + t.integer "user_id"
202 + t.integer "problem_id"
203 + t.integer "test_pair_id"
204 + t.integer "test_pair_number"
205 + t.integer "request_number"
206 + t.datetime "created_at"
207 + t.datetime "updated_at"
208 + t.boolean "submitted"
209 + end
210 +
179 create_table "test_pairs", :force => true do |t|
211 create_table "test_pairs", :force => true do |t|
180 t.integer "problem_id"
212 t.integer "problem_id"
181 t.text "input", :limit => 16777215
213 t.text "input", :limit => 16777215
182 t.text "solution", :limit => 16777215
214 t.text "solution", :limit => 16777215
183 t.datetime "created_at"
215 t.datetime "created_at"
184 t.datetime "updated_at"
216 t.datetime "updated_at"
217 + t.integer "number"
185 end
218 end
186
219
187 create_table "test_requests", :force => true do |t|
220 create_table "test_requests", :force => true do |t|
188 t.integer "user_id"
221 t.integer "user_id"
189 t.integer "problem_id"
222 t.integer "problem_id"
190 t.integer "submission_id"
223 t.integer "submission_id"
@@ -212,22 +245,29
212 t.datetime "created_at"
245 t.datetime "created_at"
213 t.datetime "updated_at"
246 t.datetime "updated_at"
214 t.boolean "forced_logout"
247 t.boolean "forced_logout"
215 end
248 end
216
249
217 create_table "users", :force => true do |t|
250 create_table "users", :force => true do |t|
218 - t.string "login", :limit => 50
251 + t.string "login", :limit => 50
219 t.string "full_name"
252 t.string "full_name"
220 t.string "hashed_password"
253 t.string "hashed_password"
221 - t.string "salt", :limit => 5
254 + t.string "salt", :limit => 5
222 t.string "alias"
255 t.string "alias"
223 t.string "email"
256 t.string "email"
224 t.integer "site_id"
257 t.integer "site_id"
225 t.integer "country_id"
258 t.integer "country_id"
226 - t.boolean "activated", :default => false
259 + t.boolean "activated", :default => false
227 t.datetime "created_at"
260 t.datetime "created_at"
228 t.datetime "updated_at"
261 t.datetime "updated_at"
262 + t.string "member1_full_name"
263 + t.string "member2_full_name"
264 + t.string "member3_full_name"
265 + t.boolean "high_school"
266 + t.string "member1_school_name"
267 + t.string "member2_school_name"
268 + t.string "member3_school_name"
229 end
269 end
230
270
231 add_index "users", ["login"], :name => "index_users_on_login", :unique => true
271 add_index "users", ["login"], :name => "index_users_on_login", :unique => true
232
272
233 end
273 end
@@ -120,14 +120,14
120
120
121
121
122 def create_configuration_key(key,
122 def create_configuration_key(key,
123 value_type,
123 value_type,
124 default_value,
124 default_value,
125 description='')
125 description='')
126 - conf = (Configuration.find_by_key(key) ||
126 + conf = (GraderConfiguration.find_by_key(key) ||
127 - Configuration.new(:key => key,
127 + GraderConfiguration.new(:key => key,
128 :value_type => value_type,
128 :value_type => value_type,
129 :value => default_value))
129 :value => default_value))
130 conf.description = description
130 conf.description = description
131 conf.save
131 conf.save
132 end
132 end
133
133
deleted file
deleted file
deleted file
deleted file
deleted file
deleted file
deleted file
deleted file
deleted file
deleted file
deleted file
deleted file
deleted file
You need to be logged in to leave comments. Login now