Description:
(previous) new way for default script files git-svn-id: http://theory.cpe.ku.ac.th/grader/cli/trunk/scripts@26 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

r13:f103b0ea2e2a - - 1 file changed: 1 inserted, 1 deleted

@@ -162,60 +162,60
162 if ARGV.length >= 1
162 if ARGV.length >= 1
163 GRADER_ENV = ARGV[0]
163 GRADER_ENV = ARGV[0]
164 if ARGV.length >=2
164 if ARGV.length >=2
165 grader_mode = ARGV[1]
165 grader_mode = ARGV[1]
166 end
166 end
167 else
167 else
168 GRADER_ENV = 'exam'
168 GRADER_ENV = 'exam'
169 end
169 end
170
170
171 puts "environment: #{GRADER_ENV}"
171 puts "environment: #{GRADER_ENV}"
172 require File.dirname(__FILE__) + "/environment.rb"
172 require File.dirname(__FILE__) + "/environment.rb"
173
173
174 #main program
174 #main program
175 talk 'Reading rails environment'
175 talk 'Reading rails environment'
176
176
177 RAILS_ENV = 'development'
177 RAILS_ENV = 'development'
178 require RAILS_APP_DIR + '/config/environment'
178 require RAILS_APP_DIR + '/config/environment'
179
179
180 case grader_mode
180 case grader_mode
181 when "queue"
181 when "queue"
182 talk 'Grader queue'
182 talk 'Grader queue'
183 while true
183 while true
184 if check_stopfile # created by calling grader stop
184 if check_stopfile # created by calling grader stop
185 clear_stopfile
185 clear_stopfile
186 puts "stopped"
186 puts "stopped"
187 exit(0)
187 exit(0)
188 end
188 end
189
189
190 task = Task.find(:first, :order => 'created_at')
190 task = Task.find(:first, :order => 'created_at')
191 if task!=nil
191 if task!=nil
192 grade(task.submission_id)
192 grade(task.submission_id)
193 task.destroy
193 task.destroy
194 else
194 else
195 sleep(1)
195 sleep(1)
196 end
196 end
197 end
197 end
198
198
199 when "prob"
199 when "prob"
200 prob = Problem.find_by_name(ARGV[2])
200 prob = Problem.find_by_name(ARGV[2])
201 if prob==nil
201 if prob==nil
202 puts "cannot find problem: #{ARGV[2]}"
202 puts "cannot find problem: #{ARGV[2]}"
203 exit(0)
203 exit(0)
204 end
204 end
205 users = User.find(:all)
205 users = User.find(:all)
206 users.each do |u|
206 users.each do |u|
207 puts "user: #{u.login}"
207 puts "user: #{u.login}"
208 last_sub = Submission.find(:first,
208 last_sub = Submission.find(:first,
209 :conditions => "user_id = #{u.id} and " +
209 :conditions => "user_id = #{u.id} and " +
210 - "problem_id = #{prob.id}",
210 + "problem_id = #{prob.id}",
211 :order => 'submitted_at DESC')
211 :order => 'submitted_at DESC')
212 if last_sub!=nil
212 if last_sub!=nil
213 grade(last_sub.id)
213 grade(last_sub.id)
214 end
214 end
215 end
215 end
216 end
216 end
217
217
218
218
219
219
220
220
221
221
You need to be logged in to leave comments. Login now