Description:
fixed msg grammar git-svn-id: http://theory.cpe.ku.ac.th/grader/web/trunk@293 6386c4cd-e34a-4fa8-8920-d93eb39b512e
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r154:3580f3e3f91b - - 2 files changed: 2 inserted, 2 deleted

@@ -32,193 +32,193
32 32 @country_select = @countries.collect { |c| [c.name, c.id] }
33 33
34 34 @country_select_with_all = [['Any',0]]
35 35 @countries.each do |country|
36 36 @country_select_with_all << [country.name, country.id]
37 37 end
38 38
39 39 @site_select = []
40 40 @countries.each do |country|
41 41 country.sites.each do |site|
42 42 @site_select << ["#{site.name}, #{country.name}", site.id]
43 43 end
44 44 end
45 45
46 46 @announcements = Announcement.find_for_frontpage
47 47 render :action => 'login', :layout => 'empty'
48 48 end
49 49
50 50 def list
51 51 prepare_list_information
52 52 end
53 53
54 54 def help
55 55 @user = User.find(session[:user_id])
56 56 end
57 57
58 58 def submit
59 59 user = User.find(session[:user_id])
60 60
61 61 @submission = Submission.new(params[:submission])
62 62 @submission.user = user
63 63 @submission.language_id = 0
64 64 if params['file']!=''
65 65 @submission.source = params['file'].read
66 66 @submission.source_filename = params['file'].original_filename
67 67 end
68 68 @submission.submitted_at = Time.new.gmtime
69 69
70 70 if Configuration[SYSTEM_MODE_CONF_KEY]=='contest' and
71 71 user.site!=nil and user.site.finished?
72 72 @submission.errors.add_to_base "The contest is over."
73 73 prepare_list_information
74 74 render :action => 'list' and return
75 75 end
76 76
77 77 if @submission.valid?
78 78 if @submission.save == false
79 79 flash[:notice] = 'Error saving your submission'
80 80 elsif Task.create(:submission_id => @submission.id,
81 81 :status => Task::STATUS_INQUEUE) == false
82 82 flash[:notice] = 'Error adding your submission to task queue'
83 83 end
84 84 else
85 85 prepare_list_information
86 86 render :action => 'list' and return
87 87 end
88 88 redirect_to :action => 'list'
89 89 end
90 90
91 91 def source
92 92 submission = Submission.find(params[:id])
93 93 if submission.user_id == session[:user_id]
94 94 if submission.problem.output_only
95 95 fname = submission.source_filename
96 96 else
97 97 fname = submission.problem.name + '.' + submission.language.ext
98 98 end
99 99 send_data(submission.source,
100 100 {:filename => fname,
101 101 :type => 'text/plain'})
102 102 else
103 103 flash[:notice] = 'Error viewing source'
104 104 redirect_to :action => 'list'
105 105 end
106 106 end
107 107
108 108 def compiler_msg
109 109 @submission = Submission.find(params[:id])
110 110 if @submission.user_id == session[:user_id]
111 111 render :action => 'compiler_msg', :layout => 'empty'
112 112 else
113 113 flash[:notice] = 'Error viewing source'
114 114 redirect_to :action => 'list'
115 115 end
116 116 end
117 117
118 118 def submission
119 119 @user = User.find(session[:user_id])
120 120 @problems = Problem.find_available_problems
121 121 if params[:id]==nil
122 122 @problem = nil
123 123 @submissions = nil
124 124 else
125 125 @problem = Problem.find_by_name(params[:id])
126 126 if not @problem.available
127 127 redirect_to :action => 'list'
128 - flash[:notice] = 'Error: submissions for that problem is not available'
128 + flash[:notice] = 'Error: submissions for that problem are not viewable.'
129 129 return
130 130 end
131 131 @submissions = Submission.find_all_by_user_problem(@user.id, @problem.id)
132 132 end
133 133 end
134 134
135 135 def result
136 136 if !Configuration.show_grading_result
137 137 redirect_to :action => 'list' and return
138 138 end
139 139 @user = User.find(session[:user_id])
140 140 @submission = Submission.find(params[:id])
141 141 if @submission.user!=@user
142 142 flash[:notice] = 'You are not allowed to view result of other users.'
143 143 redirect_to :action => 'list' and return
144 144 end
145 145 prepare_grading_result(@submission)
146 146 end
147 147
148 148 def load_output
149 149 if !Configuration.show_grading_result or params[:num]==nil
150 150 redirect_to :action => 'list' and return
151 151 end
152 152 @user = User.find(session[:user_id])
153 153 @submission = Submission.find(params[:id])
154 154 if @submission.user!=@user
155 155 flash[:notice] = 'You are not allowed to view result of other users.'
156 156 redirect_to :action => 'list' and return
157 157 end
158 158 case_num = params[:num].to_i
159 159 out_filename = output_filename(@user.login,
160 160 @submission.problem.name,
161 161 @submission.id,
162 162 case_num)
163 163 if !FileTest.exists?(out_filename)
164 164 flash[:notice] = 'Output not found.'
165 165 redirect_to :action => 'list' and return
166 166 end
167 167
168 168 response.headers['Content-Type'] = "application/force-download"
169 169 response.headers['Content-Disposition'] = "attachment; filename=\"output-#{case_num}.txt\""
170 170 response.headers["X-Sendfile"] = out_filename
171 171 response.headers['Content-length'] = File.size(out_filename)
172 172 render :nothing => true
173 173 end
174 174
175 175 def error
176 176 @user = User.find(session[:user_id])
177 177 end
178 178
179 179 protected
180 180 def prepare_list_information
181 181 @problems = Problem.find_available_problems
182 182 @prob_submissions = Array.new
183 183 @user = User.find(session[:user_id])
184 184 @problems.each do |p|
185 185 sub = Submission.find_last_by_user_and_problem(@user.id,p.id)
186 186 if sub!=nil
187 187 @prob_submissions << { :count => sub.number, :submission => sub }
188 188 else
189 189 @prob_submissions << { :count => 0, :submission => nil }
190 190 end
191 191 end
192 192 @announcements = Announcement.find_published
193 193 end
194 194
195 195 def check_viewability
196 196 @user = User.find(session[:user_id])
197 197 if (!Configuration.show_tasks_to?(@user)) and
198 198 ((action_name=='submission') or (action_name=='submit'))
199 199 redirect_to :action => 'list' and return
200 200 end
201 201 end
202 202
203 203 def prepare_grading_result(submission)
204 204 grading_info = Configuration.task_grading_info[submission.problem.name]
205 205 @test_runs = []
206 206 if grading_info['testruns'].is_a? Integer
207 207 trun_count = grading_info['testruns']
208 208 trun_count.times do |i|
209 209 @test_runs << [ read_grading_result(@user.login,
210 210 submission.problem.name,
211 211 submission.id,
212 212 i+1) ]
213 213 end
214 214 else
215 215 grading_info['testruns'].keys.sort.each do |num|
216 216 run = []
217 217 testrun = grading_info['testruns'][num]
218 218 testrun.each do |c|
219 219 run << read_grading_result(@user.login,
220 220 submission.problem.name,
221 221 submission.id,
222 222 c)
223 223 end
224 224 @test_runs << run
@@ -1,9 +1,9
1 1 class Problem < ActiveRecord::Base
2 2
3 3 belongs_to :description
4 4
5 5 def self.find_available_problems
6 - find(:all, :conditions => {:available => true})
6 + find(:all, :conditions => {:available => true}, :order => "date_added DESC")
7 7 end
8 8
9 9 end
You need to be logged in to leave comments. Login now