Description:
[grader] better status report for grader processes
git-svn-id: http://theory.cpe.ku.ac.th/grader/judge/trunk/scripts@256 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
r60:3eee9b559221 - - 1 file changed: 0 inserted, 4 deleted
@@ -1,60 +1,56 | |||
|
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 | - else | |
|
24 | - @grader_process.report_inactive if @grader_process!=nil | |
|
25 | 23 | end |
|
26 | 24 | return task |
|
27 | 25 | end |
|
28 | 26 | |
|
29 | 27 | def grade_problem(problem) |
|
30 | 28 | users = User.find(:all) |
|
31 | 29 | users.each do |u| |
|
32 | 30 | puts "user: #{u.login}" |
|
33 | 31 | last_sub = Submission.find(:first, |
|
34 | 32 | :conditions => "user_id = #{u.id} and " + |
|
35 | 33 | "problem_id = #{problem.id}", |
|
36 | 34 | :order => 'submitted_at DESC') |
|
37 | 35 | if last_sub!=nil |
|
38 | 36 | @engine.grade(last_sub) |
|
39 | 37 | end |
|
40 | 38 | end |
|
41 | 39 | end |
|
42 | 40 | |
|
43 | 41 | def grade_oldest_test_request |
|
44 | 42 | test_request = TestRequest.get_inqueue_and_change_status(Task::STATUS_GRADING) |
|
45 | 43 | if test_request!=nil |
|
46 | 44 | @grader_process.report_active(test_request) if @grader_process!=nil |
|
47 | 45 | |
|
48 | 46 | @engine.grade(test_request) |
|
49 | 47 | test_request.status_complete! |
|
50 | 48 | @grader_process.report_inactive(test_request) if @grader_process!=nil |
|
51 | - else | |
|
52 | - @grader_process.report_inactive if @grader_process!=nil | |
|
53 | 49 | end |
|
54 | 50 | return test_request |
|
55 | 51 | end |
|
56 | 52 | |
|
57 | 53 | end |
|
58 | 54 | |
|
59 | 55 | end |
|
60 | 56 |
You need to be logged in to leave comments.
Login now