Description:
MERGED changeset 404:406 from ytopc branch
git-svn-id: http://theory.cpe.ku.ac.th/grader/web/trunk@425 6386c4cd-e34a-4fa8-8920-d93eb39b512e
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r197:7e5cbcab36dd - - 3 files changed: 19 inserted, 3 deleted
new file 100644 | |||||
binary diff hidden |
@@ -169,97 +169,106 | |||||
|
169 | if params.has_key? 'recent' |
|
169 | if params.has_key? 'recent' |
|
170 | prepare_announcements(params[:recent]) |
|
170 | prepare_announcements(params[:recent]) |
|
171 | else |
|
171 | else |
|
172 | prepare_announcements |
|
172 | prepare_announcements |
|
173 | end |
|
173 | end |
|
174 | render(:partial => 'announcement', |
|
174 | render(:partial => 'announcement', |
|
175 | :collection => @announcements, |
|
175 | :collection => @announcements, |
|
176 | :locals => {:announcement_effect => true}) |
|
176 | :locals => {:announcement_effect => true}) |
|
177 | end |
|
177 | end |
|
178 |
|
178 | ||
|
179 | protected |
|
179 | protected |
|
180 |
|
180 | ||
|
181 | def prepare_announcements(recent=nil) |
|
181 | def prepare_announcements(recent=nil) |
|
182 | if Configuration.show_tasks_to?(@user) |
|
182 | if Configuration.show_tasks_to?(@user) |
|
183 | @announcements = Announcement.find_published(true) |
|
183 | @announcements = Announcement.find_published(true) |
|
184 | else |
|
184 | else |
|
185 | @announcements = Announcement.find_published |
|
185 | @announcements = Announcement.find_published |
|
186 | end |
|
186 | end |
|
187 | if recent!=nil |
|
187 | if recent!=nil |
|
188 | recent_id = recent.to_i |
|
188 | recent_id = recent.to_i |
|
189 | @announcements = @announcements.find_all { |a| a.id > recent_id } |
|
189 | @announcements = @announcements.find_all { |a| a.id > recent_id } |
|
190 | end |
|
190 | end |
|
191 | end |
|
191 | end |
|
192 |
|
192 | ||
|
193 | def prepare_list_information |
|
193 | def prepare_list_information |
|
194 | @problems = Problem.find_available_problems |
|
194 | @problems = Problem.find_available_problems |
|
195 | @prob_submissions = Array.new |
|
195 | @prob_submissions = Array.new |
|
196 | @user = User.find(session[:user_id]) |
|
196 | @user = User.find(session[:user_id]) |
|
197 | @problems.each do |p| |
|
197 | @problems.each do |p| |
|
198 | sub = Submission.find_last_by_user_and_problem(@user.id,p.id) |
|
198 | sub = Submission.find_last_by_user_and_problem(@user.id,p.id) |
|
199 | if sub!=nil |
|
199 | if sub!=nil |
|
200 | @prob_submissions << { :count => sub.number, :submission => sub } |
|
200 | @prob_submissions << { :count => sub.number, :submission => sub } |
|
201 | else |
|
201 | else |
|
202 | @prob_submissions << { :count => 0, :submission => nil } |
|
202 | @prob_submissions << { :count => 0, :submission => nil } |
|
203 | end |
|
203 | end |
|
204 | end |
|
204 | end |
|
205 | prepare_announcements |
|
205 | prepare_announcements |
|
206 | end |
|
206 | end |
|
207 |
|
207 | ||
|
208 | def check_viewability |
|
208 | def check_viewability |
|
209 | @user = User.find(session[:user_id]) |
|
209 | @user = User.find(session[:user_id]) |
|
210 | if (!Configuration.show_tasks_to?(@user)) and |
|
210 | if (!Configuration.show_tasks_to?(@user)) and |
|
211 | ((action_name=='submission') or (action_name=='submit')) |
|
211 | ((action_name=='submission') or (action_name=='submit')) |
|
212 | redirect_to :action => 'list' and return |
|
212 | redirect_to :action => 'list' and return |
|
213 | end |
|
213 | end |
|
214 | end |
|
214 | end |
|
215 |
|
215 | ||
|
216 | def prepare_grading_result(submission) |
|
216 | def prepare_grading_result(submission) |
|
|
217 | + if Configuration.task_grading_info.has_key? submission.problem.name | ||
|
217 | grading_info = Configuration.task_grading_info[submission.problem.name] |
|
218 | grading_info = Configuration.task_grading_info[submission.problem.name] |
|
|
219 | + else | ||
|
|
220 | + # guess task info from problem.full_score | ||
|
|
221 | + cases = submission.problem.full_score / 10 | ||
|
|
222 | + grading_info = { | ||
|
|
223 | + 'testruns' => cases, | ||
|
|
224 | + 'testcases' => cases | ||
|
|
225 | + } | ||
|
|
226 | + end | ||
|
218 | @test_runs = [] |
|
227 | @test_runs = [] |
|
219 | if grading_info['testruns'].is_a? Integer |
|
228 | if grading_info['testruns'].is_a? Integer |
|
220 | trun_count = grading_info['testruns'] |
|
229 | trun_count = grading_info['testruns'] |
|
221 | trun_count.times do |i| |
|
230 | trun_count.times do |i| |
|
222 | @test_runs << [ read_grading_result(@user.login, |
|
231 | @test_runs << [ read_grading_result(@user.login, |
|
223 | submission.problem.name, |
|
232 | submission.problem.name, |
|
224 | submission.id, |
|
233 | submission.id, |
|
225 | i+1) ] |
|
234 | i+1) ] |
|
226 | end |
|
235 | end |
|
227 | else |
|
236 | else |
|
228 | grading_info['testruns'].keys.sort.each do |num| |
|
237 | grading_info['testruns'].keys.sort.each do |num| |
|
229 | run = [] |
|
238 | run = [] |
|
230 | testrun = grading_info['testruns'][num] |
|
239 | testrun = grading_info['testruns'][num] |
|
231 | testrun.each do |c| |
|
240 | testrun.each do |c| |
|
232 | run << read_grading_result(@user.login, |
|
241 | run << read_grading_result(@user.login, |
|
233 | submission.problem.name, |
|
242 | submission.problem.name, |
|
234 | submission.id, |
|
243 | submission.id, |
|
235 | c) |
|
244 | c) |
|
236 | end |
|
245 | end |
|
237 | @test_runs << run |
|
246 | @test_runs << run |
|
238 | end |
|
247 | end |
|
239 | end |
|
248 | end |
|
240 | end |
|
249 | end |
|
241 |
|
250 | ||
|
242 | def grading_result_dir(user_name, problem_name, submission_id, case_num) |
|
251 | def grading_result_dir(user_name, problem_name, submission_id, case_num) |
|
243 | return "#{GRADING_RESULT_DIR}/#{user_name}/#{problem_name}/#{submission_id}/test-result/#{case_num}" |
|
252 | return "#{GRADING_RESULT_DIR}/#{user_name}/#{problem_name}/#{submission_id}/test-result/#{case_num}" |
|
244 | end |
|
253 | end |
|
245 |
|
254 | ||
|
246 | def output_filename(user_name, problem_name, submission_id, case_num) |
|
255 | def output_filename(user_name, problem_name, submission_id, case_num) |
|
247 | dir = grading_result_dir(user_name,problem_name, submission_id, case_num) |
|
256 | dir = grading_result_dir(user_name,problem_name, submission_id, case_num) |
|
248 | return "#{dir}/output.txt" |
|
257 | return "#{dir}/output.txt" |
|
249 | end |
|
258 | end |
|
250 |
|
259 | ||
|
251 | def read_grading_result(user_name, problem_name, submission_id, case_num) |
|
260 | def read_grading_result(user_name, problem_name, submission_id, case_num) |
|
252 | dir = grading_result_dir(user_name,problem_name, submission_id, case_num) |
|
261 | dir = grading_result_dir(user_name,problem_name, submission_id, case_num) |
|
253 | result_file_name = "#{dir}/result" |
|
262 | result_file_name = "#{dir}/result" |
|
254 | if !FileTest.exists?(result_file_name) |
|
263 | if !FileTest.exists?(result_file_name) |
|
255 | return {:num => case_num, :msg => 'program did not run'} |
|
264 | return {:num => case_num, :msg => 'program did not run'} |
|
256 | else |
|
265 | else |
|
257 | results = File.open(result_file_name).readlines |
|
266 | results = File.open(result_file_name).readlines |
|
258 | run_stat = extract_running_stat(results) |
|
267 | run_stat = extract_running_stat(results) |
|
259 | output_filename = "#{dir}/output.txt" |
|
268 | output_filename = "#{dir}/output.txt" |
|
260 | if FileTest.exists?(output_filename) |
|
269 | if FileTest.exists?(output_filename) |
|
261 | output_file = true |
|
270 | output_file = true |
|
262 | output_size = File.size(output_filename) |
|
271 | output_size = File.size(output_filename) |
|
263 | else |
|
272 | else |
|
264 | output_file = false |
|
273 | output_file = false |
|
265 | output_size = 0 |
|
274 | output_size = 0 |
@@ -1,184 +1,191 | |||||
|
1 | /* Main Default */ |
|
1 | /* Main Default */ |
|
2 | body { |
|
2 | body { |
|
3 | background: white url(../images/topbg.jpg) repeat-x top center; |
|
3 | background: white url(../images/topbg.jpg) repeat-x top center; |
|
4 | font-size: 13px; |
|
4 | font-size: 13px; |
|
5 | font-family: Tahoma, "sans-serif"; |
|
5 | font-family: Tahoma, "sans-serif"; |
|
6 | margin: 10px; |
|
6 | margin: 10px; |
|
7 | padding: 10px; |
|
7 | padding: 10px; |
|
8 | } |
|
8 | } |
|
9 |
|
9 | ||
|
10 | /* Form Font */ |
|
10 | /* Form Font */ |
|
11 | input { |
|
11 | input { |
|
12 | font-family: Tahoma, "sans-serif"; |
|
12 | font-family: Tahoma, "sans-serif"; |
|
13 | } |
|
13 | } |
|
14 |
|
14 | ||
|
15 |
- /* Heading 1 |
|
15 | + /* Heading 1&2 */ |
|
16 | h1 { |
|
16 | h1 { |
|
17 | font-size: 24px; |
|
17 | font-size: 24px; |
|
18 | color: #334488; |
|
18 | color: #334488; |
|
19 | line-height: 2em; |
|
19 | line-height: 2em; |
|
20 | } |
|
20 | } |
|
21 |
|
21 | ||
|
22 | h2 { |
|
22 | h2 { |
|
23 | font-size: 18px; |
|
23 | font-size: 18px; |
|
24 | color: #5566bb; |
|
24 | color: #5566bb; |
|
25 | line-height: 1.5em; |
|
25 | line-height: 1.5em; |
|
26 | } |
|
26 | } |
|
27 |
|
27 | ||
|
28 | /* Bar Line Color and Thickness */ |
|
28 | /* Bar Line Color and Thickness */ |
|
29 | hr { |
|
29 | hr { |
|
30 | border-top: 1px solid #dddddd; |
|
30 | border-top: 1px solid #dddddd; |
|
31 | border-bottom: 1px solid #eeeeee; |
|
31 | border-bottom: 1px solid #eeeeee; |
|
32 | } |
|
32 | } |
|
33 |
|
33 | ||
|
34 | /* Link + Anchor Color */ |
|
34 | /* Link + Anchor Color */ |
|
35 | a, a:link, a:visited { |
|
35 | a, a:link, a:visited { |
|
36 | color: #6666cc; |
|
36 | color: #6666cc; |
|
37 | text-decoration: none; |
|
37 | text-decoration: none; |
|
38 | } |
|
38 | } |
|
39 |
|
39 | ||
|
40 | a:hover, a:focus { |
|
40 | a:hover, a:focus { |
|
41 | color: #111166; |
|
41 | color: #111166; |
|
42 | text-decoration: none; |
|
42 | text-decoration: none; |
|
43 | } |
|
43 | } |
|
44 |
|
44 | ||
|
45 | /* This is the main menu bad*/ |
|
45 | /* This is the main menu bad*/ |
|
46 | div.userbar { |
|
46 | div.userbar { |
|
47 | line-height: 1.5em; |
|
47 | line-height: 1.5em; |
|
48 | text-align: right; |
|
48 | text-align: right; |
|
49 | font-size: 12px; |
|
49 | font-size: 12px; |
|
50 | } |
|
50 | } |
|
51 |
|
51 | ||
|
52 | /* This is the top bar, displaying user's full name */ |
|
52 | /* This is the top bar, displaying user's full name */ |
|
53 | div.title { |
|
53 | div.title { |
|
54 | // background: #ddddff; |
|
54 | // background: #ddddff; |
|
55 | // border: 1px dashed blue; |
|
55 | // border: 1px dashed blue; |
|
56 | padding: 10px 0px; |
|
56 | padding: 10px 0px; |
|
57 | line-height: 1.5em; |
|
57 | line-height: 1.5em; |
|
58 | font-size: 13px; |
|
58 | font-size: 13px; |
|
59 | } |
|
59 | } |
|
60 |
|
60 | ||
|
61 | div.title span.contest-over-msg { |
|
61 | div.title span.contest-over-msg { |
|
62 | font-size: 15px; |
|
62 | font-size: 15px; |
|
63 | color: red; |
|
63 | color: red; |
|
64 | } |
|
64 | } |
|
65 |
|
65 | ||
|
66 | div.title table { |
|
66 | div.title table { |
|
67 | width: 100%; |
|
67 | width: 100%; |
|
|
68 | + font-weight: bold; | ||
|
68 | } |
|
69 | } |
|
69 |
|
70 | ||
|
70 | div.title td.left-col { |
|
71 | div.title td.left-col { |
|
71 | text-align: left; |
|
72 | text-align: left; |
|
72 | vertical-align: top; |
|
73 | vertical-align: top; |
|
73 | color: #444444; |
|
74 | color: #444444; |
|
74 | } |
|
75 | } |
|
75 |
|
76 | ||
|
76 | div.title td.right-col { |
|
77 | div.title td.right-col { |
|
77 | text-align: right; |
|
78 | text-align: right; |
|
78 | vertical-align: top; |
|
79 | vertical-align: top; |
|
79 |
- font-size: 1 |
|
80 | + font-size: 18px; |
|
80 | - font-weight: bold; |
|
||
|
81 | color: #116699; |
|
81 | color: #116699; |
|
82 | } |
|
82 | } |
|
83 |
|
83 | ||
|
84 | /* Standard table with header and rows with alternating background */ |
|
84 | /* Standard table with header and rows with alternating background */ |
|
85 | table.info { |
|
85 | table.info { |
|
86 | margin: 10px 0; |
|
86 | margin: 10px 0; |
|
87 | border: 1px solid #666666; |
|
87 | border: 1px solid #666666; |
|
88 | border-collapse: collapse; |
|
88 | border-collapse: collapse; |
|
89 | font-size: 12px; |
|
89 | font-size: 12px; |
|
90 | } |
|
90 | } |
|
91 |
|
91 | ||
|
92 | table.info th { |
|
92 | table.info th { |
|
93 | border: 1px solid #666666; |
|
93 | border: 1px solid #666666; |
|
94 | line-height: 1.5em; |
|
94 | line-height: 1.5em; |
|
95 | padding: 0 0.5em; |
|
95 | padding: 0 0.5em; |
|
96 | } |
|
96 | } |
|
97 |
|
97 | ||
|
98 | table.info td { |
|
98 | table.info td { |
|
99 | border-left: 1px solid #666666; |
|
99 | border-left: 1px solid #666666; |
|
100 | border-right: 1px solid #666666; |
|
100 | border-right: 1px solid #666666; |
|
101 | line-height: 1.5em; |
|
101 | line-height: 1.5em; |
|
102 | padding: 0 0.5em; |
|
102 | padding: 0 0.5em; |
|
103 | } |
|
103 | } |
|
104 |
|
104 | ||
|
105 | tr.info-head { |
|
105 | tr.info-head { |
|
106 | background: #777777; |
|
106 | background: #777777; |
|
107 | color: white; |
|
107 | color: white; |
|
108 | } |
|
108 | } |
|
109 |
|
109 | ||
|
110 | tr.info-odd { |
|
110 | tr.info-odd { |
|
111 | background: #eeeeee; |
|
111 | background: #eeeeee; |
|
112 | } |
|
112 | } |
|
113 |
|
113 | ||
|
114 | tr.info-even { |
|
114 | tr.info-even { |
|
115 | background: #f9f9f9; |
|
115 | background: #f9f9f9; |
|
116 | } |
|
116 | } |
|
117 |
|
117 | ||
|
118 | /******************************* |
|
118 | /******************************* |
|
119 | [Main] |
|
119 | [Main] |
|
120 | ********************************/ |
|
120 | ********************************/ |
|
121 | div.submitbox { |
|
121 | div.submitbox { |
|
122 | background: #eeeeff; |
|
122 | background: #eeeeff; |
|
123 | border: 1px dotted #99aaee; |
|
123 | border: 1px dotted #99aaee; |
|
124 | padding: 5px; |
|
124 | padding: 5px; |
|
125 | margin: 10px 0px; |
|
125 | margin: 10px 0px; |
|
126 | color: black; |
|
126 | color: black; |
|
127 | font-weight: bold; |
|
127 | font-weight: bold; |
|
128 | font-size: 13px; |
|
128 | font-size: 13px; |
|
129 | } |
|
129 | } |
|
130 |
|
130 | ||
|
131 | div.errorExplanation { |
|
131 | div.errorExplanation { |
|
132 | border: 1px dotted gray; |
|
132 | border: 1px dotted gray; |
|
133 | color: #bb2222; |
|
133 | color: #bb2222; |
|
134 | padding: 5px 15px 5px 15px; |
|
134 | padding: 5px 15px 5px 15px; |
|
135 | margin-bottom: 5px; |
|
135 | margin-bottom: 5px; |
|
136 | background-color: white; |
|
136 | background-color: white; |
|
|
137 | + font-weight: normal; | ||
|
|
138 | + } | ||
|
|
139 | + | ||
|
|
140 | + | ||
|
|
141 | + div.errorExplanation h2 { | ||
|
|
142 | + color: #cc1111; | ||
|
|
143 | + font-weight: bold; | ||
|
137 | } |
|
144 | } |
|
138 |
|
145 | ||
|
139 | /******************************* |
|
146 | /******************************* |
|
140 | [Settings] |
|
147 | [Settings] |
|
141 | ********************************/ |
|
148 | ********************************/ |
|
142 | table.uinfo { |
|
149 | table.uinfo { |
|
143 | border-collapse: collapse; |
|
150 | border-collapse: collapse; |
|
144 | border: 1px solid black; |
|
151 | border: 1px solid black; |
|
145 | font-size: 13px; |
|
152 | font-size: 13px; |
|
146 | } |
|
153 | } |
|
147 |
|
154 | ||
|
148 | td.uinfo { |
|
155 | td.uinfo { |
|
149 | vertical-align: top; |
|
156 | vertical-align: top; |
|
150 | border: 1px solid black; |
|
157 | border: 1px solid black; |
|
151 | padding: 5px; |
|
158 | padding: 5px; |
|
152 | } |
|
159 | } |
|
153 |
|
160 | ||
|
154 | th.uinfo { |
|
161 | th.uinfo { |
|
155 | background: lightgreen; |
|
162 | background: lightgreen; |
|
156 | vertical-align: top; |
|
163 | vertical-align: top; |
|
157 | text-align: right; |
|
164 | text-align: right; |
|
158 | border: 1px solid black; |
|
165 | border: 1px solid black; |
|
159 | padding: 5px; |
|
166 | padding: 5px; |
|
160 | } |
|
167 | } |
|
161 |
|
168 | ||
|
162 | /******************************* |
|
169 | /******************************* |
|
163 | [Submission] |
|
170 | [Submission] |
|
164 | ********************************/ |
|
171 | ********************************/ |
|
165 | div.compilermsgbody { |
|
172 | div.compilermsgbody { |
|
166 | font-family: monospace; |
|
173 | font-family: monospace; |
|
167 | } |
|
174 | } |
|
168 |
|
175 | ||
|
169 | div.task-menu { |
|
176 | div.task-menu { |
|
170 | text-align: center; |
|
177 | text-align: center; |
|
171 | font-size: 13px; |
|
178 | font-size: 13px; |
|
172 | line-height: 1.75em; |
|
179 | line-height: 1.75em; |
|
173 | font-weight: bold; |
|
180 | font-weight: bold; |
|
174 | border-top: 1px dashed gray; |
|
181 | border-top: 1px dashed gray; |
|
175 | border-bottom: 1px dashed gray; |
|
182 | border-bottom: 1px dashed gray; |
|
176 | margin-top: 2px; |
|
183 | margin-top: 2px; |
|
177 | margin-bottom: 4px; |
|
184 | margin-bottom: 4px; |
|
178 | } |
|
185 | } |
|
179 |
|
186 | ||
|
180 | /******************************* |
|
187 | /******************************* |
|
181 | [Submission] |
|
188 | [Submission] |
|
182 | ********************************/ |
|
189 | ********************************/ |
|
183 | table.taskdesc { |
|
190 | table.taskdesc { |
|
184 | border: 2px solid #dddddd; |
|
191 | border: 2px solid #dddddd; |
You need to be logged in to leave comments.
Login now