Description:
[web] updated grader monitoring git-svn-id: http://theory.cpe.ku.ac.th/grader/web/trunk@222 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

r105:0ea7f18fc18a - - 14 files changed: 148 inserted, 19 deleted

@@ -0,0 +1,22
1 + %h1= "Submission: #{@submission.id}"
2 +
3 + %p
4 + User:
5 + = "#{@submission.user.login}"
6 + %br/
7 + Problem:
8 + - if @submission.problem!=nil
9 + = "#{@submission.problem.full_name}"
10 + - else
11 + = "(n/a)"
12 + %br/
13 + = "Number: #{@submission.number}"
14 + %br/
15 + = "Submitted at: #{format_short_time(@submission.submitted_at)}"
16 +
17 + %b Source code (first 10kb)
18 + %div{:style => "border: 1px solid black; background: lightgrey"}
19 + - if @submission.source
20 + %pre
21 + = truncate(@submission.source,10240)
22 +
@@ -0,0 +1,15
1 + %h1= "Task: #{@task.id}"
2 +
3 + %p
4 + User:
5 + = "#{@task.submission.user.login}"
6 + %br/
7 + Status:
8 + = "#{@task.status_str} (at #{format_short_time(@task.updated_at)})"
9 + %br/
10 + = "Submission: #{@task.submission_id}"
11 + - if @task.submission !=nil
12 + = link_to '[view submission]', :action => 'submission', :id => @task.submission.id
13 + %br/
14 + = "Submitted at: #{format_short_time(@task.created_at)}"
15 + %br/
@@ -0,0 +1,40
1 + %h1= "Test Request: #{@test_request.id}"
2 +
3 + %p
4 + User:
5 + = "#{@test_request.user.login}"
6 + %br/
7 + Problem:
8 + - if @test_request.problem!=nil
9 + = "#{@test_request.problem.full_name}"
10 + - else
11 + = "(n/a)"
12 + %br/
13 + = "Submission: #{@test_request.submission.number}"
14 + = link_to '[view submission]', :action => 'submission', :id => @test_request.submission.id
15 + %br/
16 + = "Test submitted at: #{format_short_time(@test_request.submitted_at)}"
17 + %br/
18 + = "Execution time: #{@test_request.running_time} s."
19 + %br/
20 + = "Memory usage: #{@test_request.memory_usage}kb"
21 + %br/
22 + %b= @test_request.exit_status
23 + %br/
24 +
25 + - if @test_request.compiler_message!=nil and @test_request.compiler_message!=''
26 + %b Compiler Message
27 + %div{:style => "border: 1px solid black; background: lightgrey"}
28 + = simple_format(truncate((@test_request.compiler_message or ''),200))
29 +
30 + %b Input (first 2kb)
31 + %div{:style => "border: 1px solid black; background: lightgrey"}
32 + - if @test_request.input_file_name!=nil
33 + = simple_format(read_textfile(@test_request.input_file_name,2048))
34 +
35 + %b Output (first 2kb)
36 + %div{:style => "border: 1px solid black; background: lightgrey"}
37 + - if @test_request.output_file_name!=nil
38 + = simple_format(read_textfile(@test_request.output_file_name,2048))
39 + - else
40 + (no output)
@@ -0,0 +1,9
1 + class AddTaskTypeToGraderProcesses < ActiveRecord::Migration
2 + def self.up
3 + add_column 'grader_processes', 'task_type', :string
4 + end
5 +
6 + def self.down
7 + remove_column 'grader_processes', 'task_type'
8 + end
9 + end
@@ -1,7 +1,13
1 class GradersController < ApplicationController
1 class GradersController < ApplicationController
2
2
3 + before_filter :admin_authorization
3
4
4 - before_filter :authorization
5 + verify :method => :post, :only => ['clear_all'],
6 + :redirect_to => {:action => 'index'}
7 +
8 + def index
9 + redirect_to :action => 'list'
10 + end
5
11
6 def list
12 def list
7 @grader_processes = GraderProcess.find(:all,
13 @grader_processes = GraderProcess.find(:all,
@@ -15,4 +21,31
15 redirect_to :action => 'list'
21 redirect_to :action => 'list'
16 end
22 end
17
23
24 + def clear_all
25 + GraderProcess.find(:all).each do |p|
26 + p.destroy
18 end
27 end
28 + redirect_to :action => 'list'
29 + end
30 +
31 + def view
32 + if params[:type]=='Task'
33 + redirect_to :action => 'task', :id => params[:id]
34 + else
35 + redirect_to :action => 'test_request', :id => params[:id]
36 + end
37 + end
38 +
39 + def test_request
40 + @test_request = TestRequest.find(params[:id])
41 + end
42 +
43 + def task
44 + @task = Task.find(params[:id])
45 + end
46 +
47 + def submission
48 + @submission = Submission.find(params[:id])
49 + end
50 +
51 + end
@@ -1,6 +1,6
1 class UserAdminController < ApplicationController
1 class UserAdminController < ApplicationController
2
2
3 - before_filter :authenticate, :authorization
3 + before_filter :admin_authorization
4
4
5 def index
5 def index
6 list
6 list
@@ -13,7 +13,7
13 append_to menu_items, '[Problem admin]', 'problems', 'index'
13 append_to menu_items, '[Problem admin]', 'problems', 'index'
14 append_to menu_items, '[User admin]', 'user_admin', 'index'
14 append_to menu_items, '[User admin]', 'user_admin', 'index'
15 append_to menu_items, '[User stat]', 'user_admin', 'user_stat'
15 append_to menu_items, '[User stat]', 'user_admin', 'user_stat'
16 - #append_to menu_items, '[Graders]', 'graders', 'list'
16 + append_to menu_items, '[Graders]', 'graders', 'list'
17 append_to menu_items, '[Site config]', 'configurations', 'index'
17 append_to menu_items, '[Site config]', 'configurations', 'index'
18 menu_items << "<br/>"
18 menu_items << "<br/>"
19 end
19 end
@@ -72,4 +72,12
72 TITLEBAR
72 TITLEBAR
73 end
73 end
74
74
75 + def read_textfile(fname,max_size=2048)
76 + begin
77 + File.open(fname).read(max_size)
78 + rescue
79 + nil
75 end
80 end
81 + end
82 +
83 + end
@@ -1,11 +1,2
1 module TestHelper
1 module TestHelper
2 -
3 - def read_textfile(fname,max_size=2048)
4 - begin
5 - File.open(fname).read(max_size)
6 - rescue
7 - nil
8 end
2 end
9 - end
10 -
11 - end
@@ -1,7 +1,5
1 class GraderProcess < ActiveRecord::Base
1 class GraderProcess < ActiveRecord::Base
2
2
3 - belongs_to :task
4 -
5 def self.find_by_host_and_pid(host,pid)
3 def self.find_by_host_and_pid(host,pid)
6 return GraderProcess.find(:first,
4 return GraderProcess.find(:first,
7 :conditions => {
5 :conditions => {
@@ -16,6 +14,7
16 grader.mode = mode
14 grader.mode = mode
17 grader.active = nil
15 grader.active = nil
18 grader.task_id = nil
16 grader.task_id = nil
17 + grader.task_type = nil
19 grader.save
18 grader.save
20 else
19 else
21 grader = GraderProcess.create(:host => host,
20 grader = GraderProcess.create(:host => host,
@@ -33,13 +32,15
33
32
34 def report_active(task=nil)
33 def report_active(task=nil)
35 self.active = true
34 self.active = true
36 - self.task = task
35 + self.task_id = task.id
36 + self.task_type = task.class.to_s
37 self.save
37 self.save
38 end
38 end
39
39
40 def report_inactive()
40 def report_inactive()
41 self.active = false
41 self.active = false
42 - self.task = nil
42 + self.task_id = nil
43 + self.task_type = nil
43 self.save
44 self.save
44 end
45 end
45
46
@@ -1,5 +1,7
1 class Task < ActiveRecord::Base
1 class Task < ActiveRecord::Base
2
2
3 + belongs_to :submission
4 +
3 STATUS_GRADING = 0
5 STATUS_GRADING = 0
4 STATUS_INQUEUE = 1
6 STATUS_INQUEUE = 1
5 STATUS_COMPLETE = 2
7 STATUS_COMPLETE = 2
@@ -1,9 +1,11
1
1
2 %td= grader.host
2 %td= grader.host
3 %td= grader.pid
3 %td= grader.pid
4 + %td= grader.mode
4 %td= grader.updated_at.strftime("%H:%M:%S") if grader.updated_at!=nil
5 %td= grader.updated_at.strftime("%H:%M:%S") if grader.updated_at!=nil
6 + %td= grader.task_type
5 %td
7 %td
6 - if grader.task_id==nil
8 - if grader.task_id==nil
7 - \-
9 + idle
8 - else
10 - else
9 - = grader.task_id
11 + = link_to "#{grader.task_id}", :action => 'view', :id => grader.task_id, :type => grader.task_type
@@ -3,7 +3,9
3 %tr
3 %tr
4 %th host
4 %th host
5 %th pid
5 %th pid
6 + %th mode
6 %th last updated
7 %th last updated
8 + %th type
7 %th task
9 %th task
8 - grader_list.each do |grader|
10 - grader_list.each do |grader|
9 - if grader.active
11 - if grader.active
@@ -3,6 +3,9
3
3
4 %h2 (Under Experiments)
4 %h2 (Under Experiments)
5
5
6 + - form_for :clear, nil, :url => {:action => 'clear_all'} do |f|
7 + = submit_tag 'Clear all data'
8 +
6 %h3 Current graders
9 %h3 Current graders
7
10
8 = render :partial => 'grader_list', :locals => {:grader_list => @grader_processes}
11 = render :partial => 'grader_list', :locals => {:grader_list => @grader_processes}
@@ -9,7 +9,7
9 #
9 #
10 # It's strongly recommended to check this file into your version control system.
10 # It's strongly recommended to check this file into your version control system.
11
11
12 - ActiveRecord::Schema.define(:version => 32) do
12 + ActiveRecord::Schema.define(:version => 33) do
13
13
14 create_table "announcements", :force => true do |t|
14 create_table "announcements", :force => true do |t|
15 t.string "author"
15 t.string "author"
@@ -42,6 +42,7
42 t.datetime "created_at"
42 t.datetime "created_at"
43 t.datetime "updated_at"
43 t.datetime "updated_at"
44 t.integer "task_id"
44 t.integer "task_id"
45 + t.string "task_type"
45 end
46 end
46
47
47 add_index "grader_processes", ["host", "pid"], :name => "index_grader_processes_on_ip_and_pid"
48 add_index "grader_processes", ["host", "pid"], :name => "index_grader_processes_on_ip_and_pid"
You need to be logged in to leave comments. Login now