Description:
added first grader script calls from web (to stop grader)
git-svn-id: http://theory.cpe.ku.ac.th/grader/web/trunk@433 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
r202:75463b4f3803 - - 5 files changed: 33 inserted, 2 deleted
@@ -52,13 +52,31 | |||||
|
52 | def test_request |
|
52 | def test_request |
|
53 | @test_request = TestRequest.find(params[:id]) |
|
53 | @test_request = TestRequest.find(params[:id]) |
|
54 | end |
|
54 | end |
|
55 |
|
55 | ||
|
56 | def task |
|
56 | def task |
|
57 | @task = Task.find(params[:id]) |
|
57 | @task = Task.find(params[:id]) |
|
58 | end |
|
58 | end |
|
59 |
|
59 | ||
|
60 | def submission |
|
60 | def submission |
|
61 | @submission = Submission.find(params[:id]) |
|
61 | @submission = Submission.find(params[:id]) |
|
62 | end |
|
62 | end |
|
63 |
|
63 | ||
|
|
64 | + # various grader controls | ||
|
|
65 | + | ||
|
|
66 | + def stop | ||
|
|
67 | + grader_proc = GraderProcess.find(params[:id]) | ||
|
|
68 | + stop_grader(grader_proc.pid) | ||
|
|
69 | + redirect_to :action => 'list' | ||
|
|
70 | + end | ||
|
|
71 | + | ||
|
|
72 | + | ||
|
|
73 | + protected | ||
|
|
74 | + | ||
|
|
75 | + def stop_grader(pid) | ||
|
|
76 | + if GraderProcess.grader_control_enabled? | ||
|
|
77 | + cmd = "#{GRADER_SCRIPT_DIR}/grader stop #{pid}" | ||
|
|
78 | + system(cmd) | ||
|
|
79 | + end | ||
|
|
80 | + end | ||
|
|
81 | + | ||
|
64 | end |
|
82 | end |
@@ -34,24 +34,32 | |||||
|
34 | def self.find_terminated_graders |
|
34 | def self.find_terminated_graders |
|
35 | GraderProcess.find(:all, |
|
35 | GraderProcess.find(:all, |
|
36 | :conditions => "`terminated`") |
|
36 | :conditions => "`terminated`") |
|
37 | end |
|
37 | end |
|
38 |
|
38 | ||
|
39 | def self.find_stalled_process |
|
39 | def self.find_stalled_process |
|
40 | GraderProcess.find(:all, |
|
40 | GraderProcess.find(:all, |
|
41 | :conditions => ["(`terminated` = 0) AND active AND " + |
|
41 | :conditions => ["(`terminated` = 0) AND active AND " + |
|
42 | "(updated_at < ?)", |
|
42 | "(updated_at < ?)", |
|
43 | Time.now.gmtime - GraderProcess.stalled_time]) |
|
43 | Time.now.gmtime - GraderProcess.stalled_time]) |
|
44 | end |
|
44 | end |
|
45 |
|
45 | ||
|
|
46 | + def self.grader_control_enabled? | ||
|
|
47 | + if defined? GRADER_SCRIPT_DIR | ||
|
|
48 | + GRADER_SCRIPT_DIR != '' | ||
|
|
49 | + else | ||
|
|
50 | + false | ||
|
|
51 | + end | ||
|
|
52 | + end | ||
|
|
53 | + | ||
|
46 | def report_active(task=nil) |
|
54 | def report_active(task=nil) |
|
47 | self.active = true |
|
55 | self.active = true |
|
48 | if task!=nil |
|
56 | if task!=nil |
|
49 | self.task_id = task.id |
|
57 | self.task_id = task.id |
|
50 | self.task_type = task.class.to_s |
|
58 | self.task_type = task.class.to_s |
|
51 | else |
|
59 | else |
|
52 | self.task_id = nil |
|
60 | self.task_id = nil |
|
53 | self.task_type = nil |
|
61 | self.task_type = nil |
|
54 | end |
|
62 | end |
|
55 | self.save |
|
63 | self.save |
|
56 | end |
|
64 | end |
|
57 |
|
65 |
@@ -6,19 +6,20 | |||||
|
6 | %th mode |
|
6 | %th mode |
|
7 | %th last updated |
|
7 | %th last updated |
|
8 | %th type |
|
8 | %th type |
|
9 | %th task |
|
9 | %th task |
|
10 | - grader_list.each do |grader| |
|
10 | - grader_list.each do |grader| |
|
11 | - if grader.active |
|
11 | - if grader.active |
|
12 | - c = 'active' |
|
12 | - c = 'active' |
|
13 | - else |
|
13 | - else |
|
14 | - c = 'inactive' |
|
14 | - c = 'inactive' |
|
15 | %tr{:class => c} |
|
15 | %tr{:class => c} |
|
16 | = render :partial => 'grader', :locals => {:grader => grader} |
|
16 | = render :partial => 'grader', :locals => {:grader => grader} |
|
17 | - if not grader.terminated |
|
17 | - if not grader.terminated |
|
18 | - %td= link_to 'stop', {:action => 'stop', :id => grader} |
|
18 | + - if GraderProcess.grader_control_enabled? |
|
|
19 | + %td= link_to 'stop', {:action => 'stop', :id => grader} | ||
|
19 | - else |
|
20 | - else |
|
20 | %td= link_to 'clear', {:action => 'clear', :id => grader} |
|
21 | %td= link_to 'clear', {:action => 'clear', :id => grader} |
|
21 | - else |
|
22 | - else |
|
22 | %ul |
|
23 | %ul |
|
23 | %li None |
|
24 | %li None |
|
24 |
|
25 |
@@ -1,15 +1,15 | |||||
|
1 | - content_for :head do |
|
1 | - content_for :head do |
|
2 | = stylesheet_link_tag 'graders' |
|
2 | = stylesheet_link_tag 'graders' |
|
3 |
- <meta http-equiv ="refresh" content=" |
|
3 | + <meta http-equiv ="refresh" content="60"/> |
|
4 |
|
4 | ||
|
5 | %h1 Grader information |
|
5 | %h1 Grader information |
|
6 |
|
6 | ||
|
7 | - form_for :clear, nil, :url => {:action => 'clear_all'} do |f| |
|
7 | - form_for :clear, nil, :url => {:action => 'clear_all'} do |f| |
|
8 | = submit_tag 'Clear all data' |
|
8 | = submit_tag 'Clear all data' |
|
9 |
|
9 | ||
|
10 | - if @last_task |
|
10 | - if @last_task |
|
11 | Last task: |
|
11 | Last task: |
|
12 | = link_to "#{@last_task.id}", :action => 'view', :id => @last_task.id, :type => 'Task' |
|
12 | = link_to "#{@last_task.id}", :action => 'view', :id => @last_task.id, :type => 'Task' |
|
13 |
|
13 | ||
|
14 | %br/ |
|
14 | %br/ |
|
15 |
|
15 |
@@ -64,24 +64,28 | |||||
|
64 | # inflect.plural /^(ox)$/i, '\1en' |
|
64 | # inflect.plural /^(ox)$/i, '\1en' |
|
65 | # inflect.singular /^(ox)en/i, '\1' |
|
65 | # inflect.singular /^(ox)en/i, '\1' |
|
66 | # inflect.irregular 'person', 'people' |
|
66 | # inflect.irregular 'person', 'people' |
|
67 | # inflect.uncountable %w( fish sheep ) |
|
67 | # inflect.uncountable %w( fish sheep ) |
|
68 | # end |
|
68 | # end |
|
69 |
|
69 | ||
|
70 | # Add new mime types for use in respond_to blocks: |
|
70 | # Add new mime types for use in respond_to blocks: |
|
71 | # Mime::Type.register "text/richtext", :rtf |
|
71 | # Mime::Type.register "text/richtext", :rtf |
|
72 | # Mime::Type.register "application/x-mobile", :mobile |
|
72 | # Mime::Type.register "application/x-mobile", :mobile |
|
73 |
|
73 | ||
|
74 | # Include your application configuration below |
|
74 | # Include your application configuration below |
|
75 |
|
75 | ||
|
|
76 | + # If you want to manage graders through web interface, set the path to | ||
|
|
77 | + # script directory below | ||
|
|
78 | + GRADER_SCRIPT_DIR = '' | ||
|
|
79 | + | ||
|
76 | # These are where inputs and outputs of test requests are stored |
|
80 | # These are where inputs and outputs of test requests are stored |
|
77 | TEST_REQUEST_INPUT_FILE_DIR = RAILS_ROOT + '/data/test_request/input' |
|
81 | TEST_REQUEST_INPUT_FILE_DIR = RAILS_ROOT + '/data/test_request/input' |
|
78 | TEST_REQUEST_OUTPUT_FILE_DIR = RAILS_ROOT + '/data/test_request/output' |
|
82 | TEST_REQUEST_OUTPUT_FILE_DIR = RAILS_ROOT + '/data/test_request/output' |
|
79 |
|
83 | ||
|
80 | # To use ANALYSIS MODE, provide the testcases/testruns breakdown, |
|
84 | # To use ANALYSIS MODE, provide the testcases/testruns breakdown, |
|
81 | # and the directory of the grading result (usually in judge's dir). |
|
85 | # and the directory of the grading result (usually in judge's dir). |
|
82 | TASK_GRADING_INFO_FILENAME = RAILS_ROOT + '/config/tasks.yml' |
|
86 | TASK_GRADING_INFO_FILENAME = RAILS_ROOT + '/config/tasks.yml' |
|
83 |
|
87 | ||
|
84 | # TODO: change this to where results are kept. |
|
88 | # TODO: change this to where results are kept. |
|
85 | GRADING_RESULT_DIR = 'RESULT-DIR' |
|
89 | GRADING_RESULT_DIR = 'RESULT-DIR' |
|
86 |
|
90 | ||
|
87 | # Uncomment so that configuration is read only once when the server is loaded |
|
91 | # Uncomment so that configuration is read only once when the server is loaded |
You need to be logged in to leave comments.
Login now