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
@@ -58,7 +58,25 | |||||
|
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 |
@@ -40,12 +40,20 | |||||
|
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 |
@@ -12,13 +12,14 | |||||
|
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,9 +1,9 | |||||
|
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 |
@@ -70,12 +70,16 | |||||
|
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). |
You need to be logged in to leave comments.
Login now