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 | 58 | end |
|
59 | 59 | |
|
60 | 60 | def submission |
|
61 | 61 | @submission = Submission.find(params[:id]) |
|
62 | 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 | 82 | end |
@@ -40,12 +40,20 | |||
|
40 | 40 | GraderProcess.find(:all, |
|
41 | 41 | :conditions => ["(`terminated` = 0) AND active AND " + |
|
42 | 42 | "(updated_at < ?)", |
|
43 | 43 | Time.now.gmtime - GraderProcess.stalled_time]) |
|
44 | 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 | 54 | def report_active(task=nil) |
|
47 | 55 | self.active = true |
|
48 | 56 | if task!=nil |
|
49 | 57 | self.task_id = task.id |
|
50 | 58 | self.task_type = task.class.to_s |
|
51 | 59 | else |
@@ -12,13 +12,14 | |||
|
12 | 12 | - c = 'active' |
|
13 | 13 | - else |
|
14 | 14 | - c = 'inactive' |
|
15 | 15 | %tr{:class => c} |
|
16 | 16 | = render :partial => 'grader', :locals => {:grader => grader} |
|
17 | 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 | 20 | - else |
|
20 | 21 | %td= link_to 'clear', {:action => 'clear', :id => grader} |
|
21 | 22 | - else |
|
22 | 23 | %ul |
|
23 | 24 | %li None |
|
24 | 25 |
@@ -1,9 +1,9 | |||
|
1 | 1 | - content_for :head do |
|
2 | 2 | = stylesheet_link_tag 'graders' |
|
3 |
- <meta http-equiv ="refresh" content=" |
|
|
3 | + <meta http-equiv ="refresh" content="60"/> | |
|
4 | 4 | |
|
5 | 5 | %h1 Grader information |
|
6 | 6 | |
|
7 | 7 | - form_for :clear, nil, :url => {:action => 'clear_all'} do |f| |
|
8 | 8 | = submit_tag 'Clear all data' |
|
9 | 9 |
@@ -70,12 +70,16 | |||
|
70 | 70 | # Add new mime types for use in respond_to blocks: |
|
71 | 71 | # Mime::Type.register "text/richtext", :rtf |
|
72 | 72 | # Mime::Type.register "application/x-mobile", :mobile |
|
73 | 73 | |
|
74 | 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 | 80 | # These are where inputs and outputs of test requests are stored |
|
77 | 81 | TEST_REQUEST_INPUT_FILE_DIR = RAILS_ROOT + '/data/test_request/input' |
|
78 | 82 | TEST_REQUEST_OUTPUT_FILE_DIR = RAILS_ROOT + '/data/test_request/output' |
|
79 | 83 | |
|
80 | 84 | # To use ANALYSIS MODE, provide the testcases/testruns breakdown, |
|
81 | 85 | # and the directory of the grading result (usually in judge's dir). |
You need to be logged in to leave comments.
Login now