Description:
renamed model Configuration to GraderConfiguration, renamed rhtml views to erb, fixed other small errors
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
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 |
@@ -32,16 +32,17 | |||||
|
32 |
|
32 | ||
|
33 | # Deploy with Capistrano |
|
33 | # Deploy with Capistrano |
|
34 | # gem 'capistrano' |
|
34 | # gem 'capistrano' |
|
35 |
|
35 | ||
|
36 | # To use debugger |
|
36 | # To use debugger |
|
37 | # gem 'debugger' |
|
37 | # gem 'debugger' |
|
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 |
@@ -29,24 +29,25 | |||||
|
29 | i18n (~> 0.6) |
|
29 | i18n (~> 0.6) |
|
30 | multi_json (~> 1.0) |
|
30 | multi_json (~> 1.0) |
|
31 | arel (3.0.2) |
|
31 | arel (3.0.2) |
|
32 | builder (3.0.3) |
|
32 | builder (3.0.3) |
|
33 | coffee-rails (3.2.2) |
|
33 | coffee-rails (3.2.2) |
|
34 | coffee-script (>= 2.2.0) |
|
34 | coffee-script (>= 2.2.0) |
|
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) |
|
47 | journey (1.0.4) |
|
48 | journey (1.0.4) |
|
48 | json (1.7.5) |
|
49 | json (1.7.5) |
|
49 | mail (2.4.4) |
|
50 | mail (2.4.4) |
|
50 | i18n (>= 0.4.0) |
|
51 | i18n (>= 0.4.0) |
|
51 | mime-types (~> 1.16) |
|
52 | mime-types (~> 1.16) |
|
52 | treetop (~> 1.4.8) |
|
53 | treetop (~> 1.4.8) |
@@ -113,23 +114,24 | |||||
|
113 | polyglot (>= 0.3.1) |
|
114 | polyglot (>= 0.3.1) |
|
114 | tzinfo (0.3.33) |
|
115 | tzinfo (0.3.33) |
|
115 | uglifier (1.3.0) |
|
116 | uglifier (1.3.0) |
|
116 | execjs (>= 0.3.0) |
|
117 | execjs (>= 0.3.0) |
|
117 | multi_json (~> 1.0, >= 1.0.2) |
|
118 | multi_json (~> 1.0, >= 1.0.2) |
|
118 | will_paginate (3.0.3) |
|
119 | will_paginate (3.0.3) |
|
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) |
|
131 | sass-rails (~> 3.2.3) |
|
133 | sass-rails (~> 3.2.3) |
|
132 | test-unit |
|
134 | test-unit |
|
133 | tmail |
|
135 | tmail |
|
134 | uglifier (>= 1.0.3) |
|
136 | uglifier (>= 1.0.3) |
|
135 | will_paginate (~> 3.0.0) |
|
137 | will_paginate (~> 3.0.0) |
@@ -19,35 +19,35 | |||||
|
19 | end |
|
19 | end |
|
20 | end |
|
20 | end |
|
21 |
|
21 | ||
|
22 | protected |
|
22 | protected |
|
23 |
|
23 | ||
|
24 | def authenticate |
|
24 | def authenticate |
|
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' |
|
48 | end |
|
48 | end |
|
49 | rescue |
|
49 | rescue |
|
50 | end |
|
50 | end |
|
51 | end |
|
51 | end |
|
52 | return true |
|
52 | return true |
|
53 | end |
|
53 | end |
@@ -1,20 +1,20 | |||||
|
1 | class ConfigurationsController < ApplicationController |
|
1 | class ConfigurationsController < ApplicationController |
|
2 |
|
2 | ||
|
3 | before_filter :authenticate |
|
3 | before_filter :authenticate |
|
4 | before_filter { |controller| controller.authorization_by_roles(['admin'])} |
|
4 | before_filter { |controller| controller.authorization_by_roles(['admin'])} |
|
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 |
@@ -1,50 +1,50 | |||||
|
1 | class ContestManagementController < ApplicationController |
|
1 | class ContestManagementController < ApplicationController |
|
2 |
|
2 | ||
|
3 | before_filter :admin_authorization |
|
3 | before_filter :admin_authorization |
|
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| |
|
17 | @start_times[stat.user_id] = stat.started_at |
|
17 | @start_times[stat.user_id] = stat.started_at |
|
18 | end |
|
18 | end |
|
19 | end |
|
19 | end |
|
20 |
|
20 | ||
|
21 | def clear_stat |
|
21 | def clear_stat |
|
22 | user = User.find(params[:id]) |
|
22 | user = User.find(params[:id]) |
|
23 | if user.contest_stat!=nil |
|
23 | if user.contest_stat!=nil |
|
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' |
|
48 | end |
|
48 | end |
|
49 |
|
49 | ||
|
50 | end |
|
50 | end |
@@ -3,25 +3,25 | |||||
|
3 | def index |
|
3 | def index |
|
4 | # show login screen |
|
4 | # show login screen |
|
5 | reset_session |
|
5 | reset_session |
|
6 | redirect_to :controller => 'main', :action => 'login' |
|
6 | redirect_to :controller => 'main', :action => 'login' |
|
7 | end |
|
7 | end |
|
8 |
|
8 | ||
|
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 |
|
22 | end |
|
22 | end |
|
23 | end |
|
23 | end |
|
24 |
|
24 | ||
|
25 | redirect_to :controller => 'main', :action => 'list' |
|
25 | redirect_to :controller => 'main', :action => 'list' |
|
26 | else |
|
26 | else |
|
27 | flash[:notice] = 'Wrong password' |
|
27 | flash[:notice] = 'Wrong password' |
@@ -29,25 +29,25 | |||||
|
29 | end |
|
29 | end |
|
30 |
|
30 | ||
|
31 | def login |
|
31 | def login |
|
32 | saved_notice = flash[:notice] |
|
32 | saved_notice = flash[:notice] |
|
33 | reset_session |
|
33 | reset_session |
|
34 | flash.now[:notice] = saved_notice |
|
34 | flash.now[:notice] = saved_notice |
|
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' |
|
48 | end |
|
48 | end |
|
49 |
|
49 | ||
|
50 | def list |
|
50 | def list |
|
51 | prepare_list_information |
|
51 | prepare_list_information |
|
52 | end |
|
52 | end |
|
53 |
|
53 | ||
@@ -58,25 +58,25 | |||||
|
58 | def submit |
|
58 | def submit |
|
59 | user = User.find(session[:user_id]) |
|
59 | user = User.find(session[:user_id]) |
|
60 |
|
60 | ||
|
61 | @submission = Submission.new(params[:submission]) |
|
61 | @submission = Submission.new(params[:submission]) |
|
62 | @submission.user = user |
|
62 | @submission.user = user |
|
63 | @submission.language_id = 0 |
|
63 | @submission.language_id = 0 |
|
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? |
|
77 | if @submission.save == false |
|
77 | if @submission.save == false |
|
78 | flash[:notice] = 'Error saving your submission' |
|
78 | flash[:notice] = 'Error saving your submission' |
|
79 | elsif Task.create(:submission_id => @submission.id, |
|
79 | elsif Task.create(:submission_id => @submission.id, |
|
80 | :status => Task::STATUS_INQUEUE) == false |
|
80 | :status => Task::STATUS_INQUEUE) == false |
|
81 | flash[:notice] = 'Error adding your submission to task queue' |
|
81 | flash[:notice] = 'Error adding your submission to task queue' |
|
82 | end |
|
82 | end |
@@ -120,38 +120,38 | |||||
|
120 | else |
|
120 | else |
|
121 | @problem = Problem.find_by_name(params[:id]) |
|
121 | @problem = Problem.find_by_name(params[:id]) |
|
122 | if not @problem.available |
|
122 | if not @problem.available |
|
123 | redirect_to :action => 'list' |
|
123 | redirect_to :action => 'list' |
|
124 | flash[:notice] = 'Error: submissions for that problem are not viewable.' |
|
124 | flash[:notice] = 'Error: submissions for that problem are not viewable.' |
|
125 | return |
|
125 | return |
|
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.' |
|
152 | redirect_to :action => 'list' and return |
|
152 | redirect_to :action => 'list' and return |
|
153 | end |
|
153 | end |
|
154 | case_num = params[:num].to_i |
|
154 | case_num = params[:num].to_i |
|
155 | out_filename = output_filename(@user.login, |
|
155 | out_filename = output_filename(@user.login, |
|
156 | @submission.problem.name, |
|
156 | @submission.problem.name, |
|
157 | @submission.id, |
|
157 | @submission.id, |
@@ -194,66 +194,66 | |||||
|
194 | if request.method == :post |
|
194 | if request.method == :post |
|
195 | user.update_start_time |
|
195 | user.update_start_time |
|
196 | redirect_to :action => 'list' |
|
196 | redirect_to :action => 'list' |
|
197 | else |
|
197 | else |
|
198 | @contests = user.contests |
|
198 | @contests = user.contests |
|
199 | @user = user |
|
199 | @user = user |
|
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 = {} |
|
226 | @problems.each do |p| |
|
226 | @problems.each do |p| |
|
227 | sub = Submission.find_last_by_user_and_problem(@user.id,p.id) |
|
227 | sub = Submission.find_last_by_user_and_problem(@user.id,p.id) |
|
228 | if sub!=nil |
|
228 | if sub!=nil |
|
229 | @prob_submissions[p.id] = { :count => sub.number, :submission => sub } |
|
229 | @prob_submissions[p.id] = { :count => sub.number, :submission => sub } |
|
230 | else |
|
230 | else |
|
231 | @prob_submissions[p.id] = { :count => 0, :submission => nil } |
|
231 | @prob_submissions[p.id] = { :count => 0, :submission => nil } |
|
232 | end |
|
232 | end |
|
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 |
|
254 | } |
|
254 | } |
|
255 | end |
|
255 | end |
|
256 | @test_runs = [] |
|
256 | @test_runs = [] |
|
257 | if grading_info['testruns'].is_a? Integer |
|
257 | if grading_info['testruns'].is_a? Integer |
|
258 | trun_count = grading_info['testruns'] |
|
258 | trun_count = grading_info['testruns'] |
|
259 | trun_count.times do |i| |
|
259 | trun_count.times do |i| |
@@ -344,37 +344,37 | |||||
|
344 | end |
|
344 | end |
|
345 |
|
345 | ||
|
346 | return { |
|
346 | return { |
|
347 | :msg => "#{run_stat}\n#{time_stat}", |
|
347 | :msg => "#{run_stat}\n#{time_stat}", |
|
348 | :running_time => seconds, |
|
348 | :running_time => seconds, |
|
349 | :exit_status => run_stat, |
|
349 | :exit_status => run_stat, |
|
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 |
|
378 |
|
378 | ||
|
379 | end |
|
379 | end |
|
380 |
|
380 |
@@ -10,25 +10,25 | |||||
|
10 | @country_select_with_all = [['Any',0]] |
|
10 | @country_select_with_all = [['Any',0]] |
|
11 | @countries.each do |country| |
|
11 | @countries.each do |country| |
|
12 | @country_select_with_all << [country.name, country.id] |
|
12 | @country_select_with_all << [country.name, country.id] |
|
13 | end |
|
13 | end |
|
14 |
|
14 | ||
|
15 | @site_select = [] |
|
15 | @site_select = [] |
|
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 |
|
29 | render :action => 'started', :layout => 'empty' |
|
29 | render :action => 'started', :layout => 'empty' |
|
30 | else |
|
30 | else |
|
31 | render :action => 'prompt', :layout => 'empty' |
|
31 | render :action => 'prompt', :layout => 'empty' |
|
32 | end |
|
32 | end |
|
33 | end |
|
33 | end |
|
34 |
|
34 |
@@ -57,19 +57,19 | |||||
|
57 | if params[:ext]=='pdf' |
|
57 | if params[:ext]=='pdf' |
|
58 | content_type = 'application/pdf' |
|
58 | content_type = 'application/pdf' |
|
59 | else |
|
59 | else |
|
60 | content_type = 'application/octet-stream' |
|
60 | content_type = 'application/octet-stream' |
|
61 | end |
|
61 | end |
|
62 |
|
62 | ||
|
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 |
@@ -15,32 +15,32 | |||||
|
15 | end |
|
15 | end |
|
16 |
|
16 | ||
|
17 | def submit |
|
17 | def submit |
|
18 | @user = User.find(session[:user_id]) |
|
18 | @user = User.find(session[:user_id]) |
|
19 |
|
19 | ||
|
20 | @submitted_test_request = TestRequest.new_from_form_params(@user,params[:test_request]) |
|
20 | @submitted_test_request = TestRequest.new_from_form_params(@user,params[:test_request]) |
|
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 | ||
|
41 | if @submitted_test_request.save |
|
41 | if @submitted_test_request.save |
|
42 | redirect_to :action => 'index' |
|
42 | redirect_to :action => 'index' |
|
43 | else |
|
43 | else |
|
44 | prepare_index_information |
|
44 | prepare_index_information |
|
45 | render :action => 'index' |
|
45 | render :action => 'index' |
|
46 | end |
|
46 | end |
@@ -98,21 +98,21 | |||||
|
98 | end |
|
98 | end |
|
99 | end |
|
99 | end |
|
100 | @test_requests = [] |
|
100 | @test_requests = [] |
|
101 | @user.test_requests.each do |ts| |
|
101 | @user.test_requests.each do |ts| |
|
102 | if ts.problem and ts.problem.available |
|
102 | if ts.problem and ts.problem.available |
|
103 | @test_requests << ts |
|
103 | @test_requests << ts |
|
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,32 +1,32 | |||||
|
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 |
|
27 | @users = User.paginate :page => params[:page] |
|
27 | @users = User.paginate :page => params[:page] |
|
28 | @paginated = true |
|
28 | @paginated = true |
|
29 | end |
|
29 | end |
|
30 | @hidden_columns = ['hashed_password', 'salt', 'created_at', 'updated_at'] |
|
30 | @hidden_columns = ['hashed_password', 'salt', 'created_at', 'updated_at'] |
|
31 | @contests = Contest.enabled |
|
31 | @contests = Contest.enabled |
|
32 | end |
|
32 | end |
@@ -415,25 +415,25 | |||||
|
415 |
|
415 | ||
|
416 | def logout_users(users) |
|
416 | def logout_users(users) |
|
417 | users.each do |user| |
|
417 | users.each do |user| |
|
418 | contest_stat = user.contest_stat(true) |
|
418 | contest_stat = user.contest_stat(true) |
|
419 | if contest_stat and !contest_stat.forced_logout |
|
419 | if contest_stat and !contest_stat.forced_logout |
|
420 | contest_stat.forced_logout = true |
|
420 | contest_stat.forced_logout = true |
|
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, |
|
434 | :contest_title_name => contest_title_name, |
|
434 | :contest_title_name => contest_title_name, |
|
435 | :contest_name => contest.name, |
|
435 | :contest_name => contest.name, |
|
436 | }) |
|
436 | }) |
|
437 |
|
437 | ||
|
438 | logger.info body |
|
438 | logger.info body |
|
439 | send_mail(user.email, subject, body) |
|
439 | send_mail(user.email, subject, body) |
@@ -1,38 +1,38 | |||||
|
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] |
|
13 |
|
13 | ||
|
14 | before_filter :verify_online_registration, :only => [:new, |
|
14 | before_filter :verify_online_registration, :only => [:new, |
|
15 | :register, |
|
15 | :register, |
|
16 | :forget, |
|
16 | :forget, |
|
17 | :retrieve_password] |
|
17 | :retrieve_password] |
|
18 |
|
18 | ||
|
19 | verify :method => :post, :only => [:chg_passwd], |
|
19 | verify :method => :post, :only => [:chg_passwd], |
|
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 | ||
|
33 | def chg_passwd |
|
33 | def chg_passwd |
|
34 | user = User.find(session[:user_id]) |
|
34 | user = User.find(session[:user_id]) |
|
35 | user.password = params[:passwd] |
|
35 | user.password = params[:passwd] |
|
36 | user.password_confirmation = params[:passwd_verify] |
|
36 | user.password_confirmation = params[:passwd_verify] |
|
37 | if user.save |
|
37 | if user.save |
|
38 | flash[:notice] = 'password changed' |
|
38 | flash[:notice] = 'password changed' |
@@ -50,25 +50,25 | |||||
|
50 | def register |
|
50 | def register |
|
51 | if(params[:cancel]) |
|
51 | if(params[:cancel]) |
|
52 | redirect_to :controller => 'main', :action => 'login' |
|
52 | redirect_to :controller => 'main', :action => 'login' |
|
53 | return |
|
53 | return |
|
54 | end |
|
54 | end |
|
55 | @user = User.new(params[:user]) |
|
55 | @user = User.new(params[:user]) |
|
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 |
|
69 | end |
|
69 | end |
|
70 |
|
70 | ||
|
71 | def confirm |
|
71 | def confirm |
|
72 | login = params[:login] |
|
72 | login = params[:login] |
|
73 | key = params[:activation] |
|
73 | key = params[:activation] |
|
74 | @user = User.find_by_login(login) |
|
74 | @user = User.find_by_login(login) |
@@ -103,54 +103,54 | |||||
|
103 | send_new_password_email(user) |
|
103 | send_new_password_email(user) |
|
104 | flash[:notice] = 'New password has been mailed to you.' |
|
104 | flash[:notice] = 'New password has been mailed to you.' |
|
105 | end |
|
105 | end |
|
106 | else |
|
106 | else |
|
107 | flash[:notice] = I18n.t 'registration.password_retrieval.no_email' |
|
107 | flash[:notice] = I18n.t 'registration.password_retrieval.no_email' |
|
108 | end |
|
108 | end |
|
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', { |
|
129 | :full_name => user.full_name, |
|
129 | :full_name => user.full_name, |
|
130 | :contest_name => contest_name, |
|
130 | :contest_name => contest_name, |
|
131 | :login => user.login, |
|
131 | :login => user.login, |
|
132 | :password => user.password, |
|
132 | :password => user.password, |
|
133 | :activation_url => activation_url, |
|
133 | :activation_url => activation_url, |
|
134 | :admin_email => admin_email |
|
134 | :admin_email => admin_email |
|
135 | }) |
|
135 | }) |
|
136 |
|
136 | ||
|
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, |
|
151 | :admin_email => admin_email |
|
151 | :admin_email => admin_email |
|
152 | }) |
|
152 | }) |
|
153 |
|
153 | ||
|
154 | logger.info body |
|
154 | logger.info body |
|
155 | send_mail(user.email, subject, body) |
|
155 | send_mail(user.email, subject, body) |
|
156 | end |
|
156 | end |
@@ -15,37 +15,37 | |||||
|
15 | append_to menu_items, '[Results]', 'user_admin', 'user_stat' |
|
15 | append_to menu_items, '[Results]', 'user_admin', 'user_stat' |
|
16 | append_to menu_items, '[Graders]', 'graders', 'list' |
|
16 | append_to menu_items, '[Graders]', 'graders', 'list' |
|
17 | append_to menu_items, '[Contests]', 'contest_management', 'index' |
|
17 | append_to menu_items, '[Contests]', 'contest_management', 'index' |
|
18 | append_to menu_items, '[Sites]', 'sites', 'index' |
|
18 | append_to menu_items, '[Sites]', 'sites', 'index' |
|
19 | append_to menu_items, '[System config]', 'configurations', 'index' |
|
19 | append_to menu_items, '[System config]', 'configurations', 'index' |
|
20 | menu_items << "<br/>" |
|
20 | menu_items << "<br/>" |
|
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, |
|
46 | :action => action) |
|
46 | :action => action) |
|
47 | end |
|
47 | end |
|
48 |
|
48 | ||
|
49 | def format_short_time(time) |
|
49 | def format_short_time(time) |
|
50 | now = Time.now.gmtime |
|
50 | now = Time.now.gmtime |
|
51 | st = '' |
|
51 | st = '' |
@@ -67,61 +67,62 | |||||
|
67 | File.open(fname).read(max_size) |
|
67 | File.open(fname).read(max_size) |
|
68 | rescue |
|
68 | rescue |
|
69 | nil |
|
69 | nil |
|
70 | end |
|
70 | end |
|
71 | end |
|
71 | end |
|
72 |
|
72 | ||
|
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 |
|
86 | end |
|
86 | end |
|
87 | if !user.contest_started? |
|
87 | if !user.contest_started? |
|
88 | time_left = " " + (t 'title_bar.contest_not_started') |
|
88 | time_left = " " + (t 'title_bar.contest_not_started') |
|
89 | else |
|
89 | else |
|
90 | time_left = " " + (t 'title_bar.remaining_time') + |
|
90 | time_left = " " + (t 'title_bar.remaining_time') + |
|
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/> |
|
116 | #{t 'title_bar.current_time'} #{format_short_time(Time.new)} |
|
116 | #{t 'title_bar.current_time'} #{format_short_time(Time.new)} |
|
117 | #{time_left} |
|
117 | #{time_left} |
|
118 | <br/> |
|
118 | <br/> |
|
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 |
|
|
126 | end |
|
126 |
|
127 | ||
|
127 | end |
|
128 | end |
@@ -1,46 +1,46 | |||||
|
1 | class Site < ActiveRecord::Base |
|
1 | class Site < ActiveRecord::Base |
|
2 |
|
2 | ||
|
3 | belongs_to :country |
|
3 | belongs_to :country |
|
4 | has_many :users |
|
4 | has_many :users |
|
5 |
|
5 | ||
|
6 | def clear_start_time_if_not_started |
|
6 | def clear_start_time_if_not_started |
|
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 |
|
20 | if self.start_time!=nil |
|
20 | if self.start_time!=nil |
|
21 | finish_time = self.start_time + contest_time |
|
21 | finish_time = self.start_time + contest_time |
|
22 | else |
|
22 | else |
|
23 | finish_time = current_time + contest_time |
|
23 | finish_time = current_time + contest_time |
|
24 | end |
|
24 | end |
|
25 |
|
25 | ||
|
26 | if current_time > finish_time |
|
26 | if current_time > finish_time |
|
27 | return current_time - current_time |
|
27 | return current_time - current_time |
|
28 | else |
|
28 | else |
|
29 | return finish_time - current_time |
|
29 | return finish_time - current_time |
|
30 | end |
|
30 | end |
|
31 | end |
|
31 | end |
|
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 |
|
45 |
|
45 | ||
|
46 | end |
|
46 | end |
@@ -127,65 +127,65 | |||||
|
127 | return users.find_all { |u| !(u.admin?) and u.login.index(prefix)==0 } |
|
127 | return users.find_all { |u| !(u.admin?) and u.login.index(prefix)==0 } |
|
128 | end |
|
128 | end |
|
129 |
|
129 | ||
|
130 | # Contest information |
|
130 | # Contest information |
|
131 |
|
131 | ||
|
132 | def self.find_users_with_no_contest() |
|
132 | def self.find_users_with_no_contest() |
|
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 |
|
150 | finish_time = contest_stat.started_at + time_limit |
|
150 | finish_time = contest_stat.started_at + time_limit |
|
151 | current_time = Time.now.gmtime |
|
151 | current_time = Time.now.gmtime |
|
152 | if current_time > finish_time |
|
152 | if current_time > finish_time |
|
153 | return 0 |
|
153 | return 0 |
|
154 | else |
|
154 | else |
|
155 | return finish_time - current_time |
|
155 | return finish_time - current_time |
|
156 | end |
|
156 | end |
|
157 | end |
|
157 | end |
|
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 |
|
186 |
|
186 | ||
|
187 | def update_start_time |
|
187 | def update_start_time |
|
188 | stat = self.contest_stat |
|
188 | stat = self.contest_stat |
|
189 | if stat == nil or stat.started_at == nil |
|
189 | if stat == nil or stat.started_at == nil |
|
190 | stat ||= UserContestStat.new(:user => self) |
|
190 | stat ||= UserContestStat.new(:user => self) |
|
191 | stat.started_at = Time.now.gmtime |
|
191 | stat.started_at = Time.now.gmtime |
@@ -219,44 +219,44 | |||||
|
219 | } |
|
219 | } |
|
220 | available_problems.each {|p| pin[p.id] = true} |
|
220 | available_problems.each {|p| pin[p.id] = true} |
|
221 | end |
|
221 | end |
|
222 | other_avaiable_problems = Problem.available.find_all {|p| pin[p.id]==nil and p.contests.length==0} |
|
222 | other_avaiable_problems = Problem.available.find_all {|p| pin[p.id]==nil and p.contests.length==0} |
|
223 | contest_problems << { |
|
223 | contest_problems << { |
|
224 | :contest => nil, |
|
224 | :contest => nil, |
|
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| |
|
238 | if not pin.has_key? problem.id |
|
238 | if not pin.has_key? problem.id |
|
239 | contest_problems << problem |
|
239 | contest_problems << problem |
|
240 | end |
|
240 | end |
|
241 | pin[problem.id] = true |
|
241 | pin[problem.id] = true |
|
242 | end |
|
242 | end |
|
243 | end |
|
243 | end |
|
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 | ||
|
257 | protected |
|
257 | protected |
|
258 | def encrypt_new_password |
|
258 | def encrypt_new_password |
|
259 | return if password.blank? |
|
259 | return if password.blank? |
|
260 | self.salt = (10+rand(90)).to_s |
|
260 | self.salt = (10+rand(90)).to_s |
|
261 | self.hashed_password = User.encrypt(self.password,self.salt) |
|
261 | self.hashed_password = User.encrypt(self.password,self.salt) |
|
262 | end |
|
262 | end |
@@ -269,25 +269,25 | |||||
|
269 | if self.site==nil |
|
269 | if self.site==nil |
|
270 | self.site = Site.find(1) # when 'default has be renamed' |
|
270 | self.site = Site.find(1) # when 'default has be renamed' |
|
271 | end |
|
271 | end |
|
272 | end |
|
272 | end |
|
273 | rescue |
|
273 | rescue |
|
274 | end |
|
274 | end |
|
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 |
|
288 | end |
|
288 | end |
|
289 |
|
289 | ||
|
290 | def password_required? |
|
290 | def password_required? |
|
291 | self.hashed_password.blank? || !self.password.blank? |
|
291 | self.hashed_password.blank? || !self.password.blank? |
|
292 | end |
|
292 | end |
|
293 |
|
293 |
@@ -11,22 +11,22 | |||||
|
11 | %th Description |
|
11 | %th Description |
|
12 | - @configurations.each do |conf| |
|
12 | - @configurations.each do |conf| |
|
13 | - @configuration = conf |
|
13 | - @configuration = conf |
|
14 | %tr{:class => cycle("info-odd", "info-even")} |
|
14 | %tr{:class => cycle("info-odd", "info-even")} |
|
15 | %td |
|
15 | %td |
|
16 | = in_place_editor_field :configuration, :key, {}, :rows=>1 |
|
16 | = in_place_editor_field :configuration, :key, {}, :rows=>1 |
|
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. |
|
30 | %br/ |
|
30 | %br/ |
|
31 | If you have more than one process running, you should restart |
|
31 | If you have more than one process running, you should restart |
|
32 | them manually. |
|
32 | them manually. |
@@ -2,30 +2,30 | |||||
|
2 |
|
2 | ||
|
3 | .infobox |
|
3 | .infobox |
|
4 |
|
4 | ||
|
5 | - if @num_contests>1 |
|
5 | - if @num_contests>1 |
|
6 | %b Multiple contests: |
|
6 | %b Multiple contests: |
|
7 | = "There are #{@num_contests} contests running." |
|
7 | = "There are #{@num_contests} contests running." |
|
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 |
|
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,15 +1,15 | |||||
|
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 | ||
|
14 | </body> |
|
14 | </body> |
|
15 | </html> |
|
15 | </html> |
@@ -1,13 +1,13 | |||||
|
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/ |
|
8 |
|
8 | ||
|
9 | - if flash[:notice] |
|
9 | - if flash[:notice] |
|
10 | %hr/ |
|
10 | %hr/ |
|
11 | %b= flash[:notice] |
|
11 | %b= flash[:notice] |
|
12 | %hr/ |
|
12 | %hr/ |
|
13 |
|
13 | ||
@@ -16,19 +16,19 | |||||
|
16 | %table |
|
16 | %table |
|
17 | %tr |
|
17 | %tr |
|
18 | %td{:align => "right"} |
|
18 | %td{:align => "right"} |
|
19 | ="#{t 'login_label'}:" |
|
19 | ="#{t 'login_label'}:" |
|
20 | %td= text_field_tag 'login' |
|
20 | %td= text_field_tag 'login' |
|
21 | %tr |
|
21 | %tr |
|
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 |
@@ -1,18 +1,18 | |||||
|
1 |
|
1 | ||
|
2 | %tr{:class => ((submission_counter%2==0) ? "info-even" : "info-odd")} |
|
2 | %tr{:class => ((submission_counter%2==0) ? "info-even" : "info-odd")} |
|
3 | %td.info{:align => "center"} |
|
3 | %td.info{:align => "center"} |
|
4 | = submission_counter+1 |
|
4 | = submission_counter+1 |
|
5 | %td.info= format_short_time(submission.submitted_at) |
|
5 | %td.info= format_short_time(submission.submitted_at) |
|
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 } |
@@ -1,26 +1,26 | |||||
|
1 |
|
1 | ||
|
2 | - if submission==nil |
|
2 | - if submission==nil |
|
3 | = "-" |
|
3 | = "-" |
|
4 | - else |
|
4 | - else |
|
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}) |
|
25 | = " | " |
|
25 | = " | " |
|
26 | = link_to "[#{t 'main.submissions_link'}]", :action => 'submission', :id => problem_name |
|
26 | = link_to "[#{t 'main.submissions_link'}]", :action => 'submission', :id => problem_name |
@@ -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 |
@@ -1,37 +1,37 | |||||
|
1 | - content_for :head do |
|
1 | - content_for :head do |
|
2 | = javascript_include_tag :defaults |
|
2 | = javascript_include_tag :defaults |
|
3 | = javascript_include_tag 'announcement_refresh.js' |
|
3 | = javascript_include_tag 'announcement_refresh.js' |
|
4 |
|
4 | ||
|
5 | = user_title_bar(@user) |
|
5 | = user_title_bar(@user) |
|
6 |
|
6 | ||
|
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 |
|
32 | = render :partial => 'problem', :collection => @problems |
|
32 | = render :partial => 'problem', :collection => @problems |
|
33 | - else |
|
33 | - else |
|
34 | - @contest_problems.each do |cp| |
|
34 | - @contest_problems.each do |cp| |
|
35 | - if cp[:problems].length > 0 |
|
35 | - if cp[:problems].length > 0 |
|
36 | %h2{:class =>'contest-title'} |
|
36 | %h2{:class =>'contest-title'} |
|
37 | = "#{cp[:contest] ? cp[:contest].title : 'Public problems'}" |
|
37 | = "#{cp[:contest] ? cp[:contest].title : 'Public problems'}" |
@@ -1,12 +1,12 | |||||
|
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 | %span{:class => 'title'} |
|
8 | %span{:class => 'title'} |
|
9 | Announcements |
|
9 | Announcements |
|
10 | = render :partial => 'announcement', :collection => @announcements |
|
10 | = render :partial => 'announcement', :collection => @announcements |
|
11 | %td{:style => 'vertical-align: top; width: 40%; padding-left: 20px;'} |
|
11 | %td{:style => 'vertical-align: top; width: 40%; padding-left: 20px;'} |
|
12 | = render :partial => 'login_box' |
|
12 | = render :partial => 'login_box' |
@@ -2,25 +2,25 | |||||
|
2 |
|
2 | ||
|
3 | %h2 |
|
3 | %h2 |
|
4 | Grading Result for Task |
|
4 | Grading Result for Task |
|
5 | = @submission.problem.full_name |
|
5 | = @submission.problem.full_name |
|
6 |
|
6 | ||
|
7 | %p |
|
7 | %p |
|
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 |
|
21 | %tr.info-head |
|
21 | %tr.info-head |
|
22 | %th Runs |
|
22 | %th Runs |
|
23 | %th Cases |
|
23 | %th Cases |
|
24 | %th Result |
|
24 | %th Result |
|
25 | %th Exit |
|
25 | %th Exit |
|
26 | %th Time (s) |
|
26 | %th Time (s) |
@@ -8,37 +8,37 | |||||
|
8 |
|
8 | ||
|
9 | - form_tag :action=>'do_manage' do |
|
9 | - form_tag :action=>'do_manage' do |
|
10 | .submitbox |
|
10 | .submitbox |
|
11 | What do you want to do? |
|
11 | What do you want to do? |
|
12 | %br/ |
|
12 | %br/ |
|
13 | %ul |
|
13 | %ul |
|
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 | |
|
17 | |
|
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,19 +1,19 | |||||
|
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 |
|
14 | <% else %> |
|
14 | <% else %> |
|
15 |
|
15 | ||
|
16 | <script type="text/javascript"> |
|
16 | <script type="text/javascript"> |
|
17 | var submissionCount = new Array(); |
|
17 | var submissionCount = new Array(); |
|
18 | <% @submissions.each do |submission| %> |
|
18 | <% @submissions.each do |submission| %> |
|
19 | submissionCount[<%= submission.problem_id %>]=<%= submission.number %>; |
|
19 | submissionCount[<%= submission.problem_id %>]=<%= submission.number %>; |
@@ -28,25 +28,25 | |||||
|
28 | for(i=0; i<old_len; i++) |
|
28 | for(i=0; i<old_len; i++) |
|
29 | submissionSelect.remove(0); |
|
29 | submissionSelect.remove(0); |
|
30 | for(i=count; i>=1; i--) { |
|
30 | for(i=count; i>=1; i--) { |
|
31 | try { |
|
31 | try { |
|
32 | submissionSelect.add(new Option(""+i,""+i,false,false),null); |
|
32 | submissionSelect.add(new Option(""+i,""+i,false,false),null); |
|
33 | } catch(ex) { |
|
33 | } catch(ex) { |
|
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> |
|
47 | <tr> |
|
47 | <tr> |
|
48 | <td>Task:</td> |
|
48 | <td>Task:</td> |
|
49 | <td> |
|
49 | <td> |
|
50 | <%= select(:test_request, |
|
50 | <%= select(:test_request, |
|
51 | :problem_id, |
|
51 | :problem_id, |
|
52 | @problems.collect {|p| [p.name, p.id]}, {}, |
|
52 | @problems.collect {|p| [p.name, p.id]}, {}, |
@@ -1,20 +1,20 | |||||
|
1 | <h1> |
|
1 | <h1> |
|
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 %> |
|
15 | <%= link_to "[no contest]", :action => 'contests', :id => 'none' %> |
|
15 | <%= link_to "[no contest]", :action => 'contests', :id => 'none' %> |
|
16 | <% end %> |
|
16 | <% end %> |
|
17 | <br/> |
|
17 | <br/> |
|
18 | <%= form_tag :action => 'assign_from_list' do %> |
|
18 | <%= form_tag :action => 'assign_from_list' do %> |
|
19 | <%= hidden_field_tag 'users_contest_id', (@contest ? @contest.id : 'none') %> |
|
19 | <%= hidden_field_tag 'users_contest_id', (@contest ? @contest.id : 'none') %> |
|
20 | Assign all to |
|
20 | Assign all to |
@@ -23,40 +23,40 | |||||
|
23 | <% end %> |
|
23 | <% end %> |
|
24 | </div> |
|
24 | </div> |
|
25 |
|
25 | ||
|
26 | <table class="info"> |
|
26 | <table class="info"> |
|
27 | <tr class="info-head"> |
|
27 | <tr class="info-head"> |
|
28 | <th>Login</th> |
|
28 | <th>Login</th> |
|
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 %> |
|
42 | <tr class="info-<%= cycle("odd","even") %>"> |
|
42 | <tr class="info-<%= cycle("odd","even") %>"> |
|
43 | <td><%=h user.login %></td> |
|
43 | <td><%=h user.login %></td> |
|
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> |
|
57 | <% @contests.each do |contest| %> |
|
57 | <% @contests.each do |contest| %> |
|
58 | <% if not user.contests.all.find {|c| c.id==contest.id } %> |
|
58 | <% if not user.contests.all.find {|c| c.id==contest.id } %> |
|
59 | <%= contest.name %> [<%= link_to '+', :action => 'add_to_contest', :id => user.id, :contest_id => contest.id %>] |
|
59 | <%= contest.name %> [<%= link_to '+', :action => 'add_to_contest', :id => user.id, :contest_id => contest.id %>] |
|
60 | <% end %> |
|
60 | <% end %> |
|
61 | <% end %> |
|
61 | <% end %> |
|
62 | </td> |
|
62 | </td> |
@@ -1,15 +1,15 | |||||
|
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 | ||
|
10 | %br/ |
|
10 | %br/ |
|
11 |
|
11 | ||
|
12 | - form_tag :action => 'retrieve_password' do |
|
12 | - form_tag :action => 'retrieve_password' do |
|
13 | =t 'registration.password_retrieval.instructions' |
|
13 | =t 'registration.password_retrieval.instructions' |
|
14 | = text_field 'email', nil, :size => 20 |
|
14 | = text_field 'email', nil, :size => 20 |
|
15 | %br/ |
|
15 | %br/ |
@@ -1,15 +1,15 | |||||
|
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 | ||
|
10 | %table |
|
10 | %table |
|
11 | - form_for :user, @user, :url => { :action => 'register' } do |f| |
|
11 | - form_for :user, @user, :url => { :action => 'register' } do |f| |
|
12 | %tr |
|
12 | %tr |
|
13 | %td{:align => "right"} |
|
13 | %td{:align => "right"} |
|
14 | = "#{t 'login_label'}:" |
|
14 | = "#{t 'login_label'}:" |
|
15 | %td= f.text_field :login |
|
15 | %td= f.text_field :login |
@@ -45,18 +45,18 | |||||
|
45 | # Use SQL instead of Active Record's schema dumper when creating the database. |
|
45 | # Use SQL instead of Active Record's schema dumper when creating the database. |
|
46 | # This is necessary if your schema can't be completely dumped by the schema dumper, |
|
46 | # This is necessary if your schema can't be completely dumped by the schema dumper, |
|
47 | # like if you have constraints or database-specific column types |
|
47 | # like if you have constraints or database-specific column types |
|
48 | # config.active_record.schema_format = :sql |
|
48 | # config.active_record.schema_format = :sql |
|
49 |
|
49 | ||
|
50 | # Enforce whitelist mode for mass assignment. |
|
50 | # Enforce whitelist mode for mass assignment. |
|
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 = |
|
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,44 +1,45 | |||||
|
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 |
|
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 => 201 |
|
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" |
|
19 | t.datetime "updated_at" |
|
21 | t.datetime "updated_at" |
|
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 "co |
|
28 | + create_table "codejom_statuses", :force => true do |t| |
|
27 |
- t. |
|
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" |
|
39 | t.datetime "updated_at" |
|
40 | t.datetime "updated_at" |
|
40 | t.string "name" |
|
41 | t.string "name" |
|
41 | end |
|
42 | end |
|
42 |
|
43 | ||
|
43 | create_table "contests_problems", :id => false, :force => true do |t| |
|
44 | create_table "contests_problems", :id => false, :force => true do |t| |
|
44 | t.integer "contest_id" |
|
45 | t.integer "contest_id" |
@@ -54,24 +55,33 | |||||
|
54 | t.string "name" |
|
55 | t.string "name" |
|
55 | t.datetime "created_at" |
|
56 | t.datetime "created_at" |
|
56 | t.datetime "updated_at" |
|
57 | t.datetime "updated_at" |
|
57 | end |
|
58 | end |
|
58 |
|
59 | ||
|
59 | create_table "descriptions", :force => true do |t| |
|
60 | create_table "descriptions", :force => true do |t| |
|
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" |
|
72 | t.datetime "updated_at" |
|
82 | t.datetime "updated_at" |
|
73 | t.integer "task_id" |
|
83 | t.integer "task_id" |
|
74 | t.string "task_type" |
|
84 | t.string "task_type" |
|
75 | t.boolean "terminated" |
|
85 | t.boolean "terminated" |
|
76 | end |
|
86 | end |
|
77 |
|
87 | ||
@@ -86,34 +96,36 | |||||
|
86 |
|
96 | ||
|
87 | create_table "messages", :force => true do |t| |
|
97 | create_table "messages", :force => true do |t| |
|
88 | t.integer "sender_id" |
|
98 | t.integer "sender_id" |
|
89 | t.integer "receiver_id" |
|
99 | t.integer "receiver_id" |
|
90 | t.integer "replying_message_id" |
|
100 | t.integer "replying_message_id" |
|
91 | t.text "body" |
|
101 | t.text "body" |
|
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" |
|
114 | end |
|
126 | end |
|
115 |
|
127 | ||
|
116 | create_table "rights_roles", :id => false, :force => true do |t| |
|
128 | create_table "rights_roles", :id => false, :force => true do |t| |
|
117 | t.integer "right_id" |
|
129 | t.integer "right_id" |
|
118 | t.integer "role_id" |
|
130 | t.integer "role_id" |
|
119 | end |
|
131 | end |
@@ -141,24 +153,33 | |||||
|
141 | add_index "sessions", ["updated_at"], :name => "index_sessions_on_updated_at" |
|
153 | add_index "sessions", ["updated_at"], :name => "index_sessions_on_updated_at" |
|
142 |
|
154 | ||
|
143 | create_table "sites", :force => true do |t| |
|
155 | create_table "sites", :force => true do |t| |
|
144 | t.string "name" |
|
156 | t.string "name" |
|
145 | t.boolean "started" |
|
157 | t.boolean "started" |
|
146 | t.datetime "start_time" |
|
158 | t.datetime "start_time" |
|
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" |
|
159 | t.datetime "submitted_at" |
|
180 | t.datetime "submitted_at" |
|
160 | t.datetime "compiled_at" |
|
181 | t.datetime "compiled_at" |
|
161 | t.text "compiler_message" |
|
182 | t.text "compiler_message" |
|
162 | t.datetime "graded_at" |
|
183 | t.datetime "graded_at" |
|
163 | t.integer "points" |
|
184 | t.integer "points" |
|
164 | t.text "grader_comment" |
|
185 | t.text "grader_comment" |
@@ -167,30 +188,42 | |||||
|
167 | end |
|
188 | end |
|
168 |
|
189 | ||
|
169 | add_index "submissions", ["user_id", "problem_id", "number"], :name => "index_submissions_on_user_id_and_problem_id_and_number", :unique => true |
|
190 | add_index "submissions", ["user_id", "problem_id", "number"], :name => "index_submissions_on_user_id_and_problem_id_and_number", :unique => true |
|
170 | add_index "submissions", ["user_id", "problem_id"], :name => "index_submissions_on_user_id_and_problem_id" |
|
191 | add_index "submissions", ["user_id", "problem_id"], :name => "index_submissions_on_user_id_and_problem_id" |
|
171 |
|
192 | ||
|
172 | create_table "tasks", :force => true do |t| |
|
193 | create_table "tasks", :force => true do |t| |
|
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" |
|
191 | t.string "input_file_name" |
|
224 | t.string "input_file_name" |
|
192 | t.string "output_file_name" |
|
225 | t.string "output_file_name" |
|
193 | t.string "running_stat" |
|
226 | t.string "running_stat" |
|
194 | t.integer "status" |
|
227 | t.integer "status" |
|
195 | t.datetime "updated_at" |
|
228 | t.datetime "updated_at" |
|
196 | t.datetime "submitted_at" |
|
229 | t.datetime "submitted_at" |
@@ -206,28 +239,35 | |||||
|
206 |
|
239 | ||
|
207 | add_index "test_requests", ["user_id", "problem_id"], :name => "index_test_requests_on_user_id_and_problem_id" |
|
240 | add_index "test_requests", ["user_id", "problem_id"], :name => "index_test_requests_on_user_id_and_problem_id" |
|
208 |
|
241 | ||
|
209 | create_table "user_contest_stats", :force => true do |t| |
|
242 | create_table "user_contest_stats", :force => true do |t| |
|
210 | t.integer "user_id" |
|
243 | t.integer "user_id" |
|
211 | t.datetime "started_at" |
|
244 | t.datetime "started_at" |
|
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 |
@@ -114,26 +114,26 | |||||
|
114 | :value_type => 'string', |
|
114 | :value_type => 'string', |
|
115 | :default_value => 'none', |
|
115 | :default_value => 'none', |
|
116 | :description => "New user will be assigned to this contest automatically, if it exists. Set to 'none' if there is no default contest." |
|
116 | :description => "New user will be assigned to this contest automatically, if it exists. Set to 'none' if there is no default contest." |
|
117 | } |
|
117 | } |
|
118 |
|
118 | ||
|
119 | ] |
|
119 | ] |
|
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 | ||
|
134 | def seed_config |
|
134 | def seed_config |
|
135 | CONFIGURATIONS.each do |conf| |
|
135 | CONFIGURATIONS.each do |conf| |
|
136 | if conf.has_key? :description |
|
136 | if conf.has_key? :description |
|
137 | desc = conf[:description] |
|
137 | desc = conf[:description] |
|
138 | else |
|
138 | else |
|
139 | desc = '' |
|
139 | desc = '' |
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