Description:
fixed grading wrong submission when 2 submissions created at the same time git-svn-id: http://theory.cpe.ku.ac.th/grader/judge/trunk/scripts@373 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

r68:fd3aca136ef8 - - 1 file changed: 1 inserted, 4 deleted

@@ -1,61 +1,58
1 1 #
2 2 # A runner drives the engine into various tasks.
3 3 #
4 4
5 5 module Grader
6 6
7 7 class Runner
8 8
9 9 def initialize(engine, grader_process=nil)
10 10 @engine = engine
11 11 @grader_process = grader_process
12 12 end
13 13
14 14 def grade_oldest_task
15 15 task = Task.get_inqueue_and_change_status(Task::STATUS_GRADING)
16 16 if task!=nil
17 17 @grader_process.report_active(task) if @grader_process!=nil
18 18
19 19 submission = Submission.find(task.submission_id)
20 20 @engine.grade(submission)
21 21 task.status_complete!
22 22 @grader_process.report_inactive(task) if @grader_process!=nil
23 23 end
24 24 return task
25 25 end
26 26
27 27 def grade_problem(problem)
28 28 users = User.find(:all)
29 29 users.each do |u|
30 30 puts "user: #{u.login}"
31 - last_sub = Submission.find(:first,
32 - :conditions => "user_id = #{u.id} and " +
33 - "problem_id = #{problem.id}",
34 - :order => 'submitted_at DESC')
31 + last_sub = Submission.find_last_by_user_and_problem(u.id,problem.id)
35 32 if last_sub!=nil
36 33 @engine.grade(last_sub)
37 34 end
38 35 end
39 36 end
40 37
41 38 def grade_submission(submission)
42 39 puts "Submission: #{submission.id} by #{submission.user.full_name}"
43 40 @engine.grade(submission)
44 41 end
45 42
46 43 def grade_oldest_test_request
47 44 test_request = TestRequest.get_inqueue_and_change_status(Task::STATUS_GRADING)
48 45 if test_request!=nil
49 46 @grader_process.report_active(test_request) if @grader_process!=nil
50 47
51 48 @engine.grade(test_request)
52 49 test_request.status_complete!
53 50 @grader_process.report_inactive(test_request) if @grader_process!=nil
54 51 end
55 52 return test_request
56 53 end
57 54
58 55 end
59 56
60 57 end
61 58
You need to be logged in to leave comments. Login now