Description:
add last 20 submissions status
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r461:43d522bf3ca9 - - 2 files changed: 23 inserted, 1 deleted
@@ -1,118 +1,119 | |||
|
1 | 1 | class GradersController < ApplicationController |
|
2 | 2 | |
|
3 | 3 | before_filter :admin_authorization, except: [ :submission ] |
|
4 | 4 | before_filter(only: [:submission]) { |
|
5 | 5 | return false unless authenticate |
|
6 | 6 | |
|
7 | 7 | if GraderConfiguration["right.user_view_submission"] |
|
8 | 8 | return true; |
|
9 | 9 | end |
|
10 | 10 | |
|
11 | 11 | admin_authorization |
|
12 | 12 | } |
|
13 | 13 | |
|
14 | 14 | verify :method => :post, :only => ['clear_all', |
|
15 | 15 | 'start_exam', |
|
16 | 16 | 'start_grading', |
|
17 | 17 | 'stop_all', |
|
18 | 18 | 'clear_terminated'], |
|
19 | 19 | :redirect_to => {:action => 'index'} |
|
20 | 20 | |
|
21 | 21 | def index |
|
22 | 22 | redirect_to :action => 'list' |
|
23 | 23 | end |
|
24 | 24 | |
|
25 | 25 | def list |
|
26 | 26 | @grader_processes = GraderProcess.find_running_graders |
|
27 | 27 | @stalled_processes = GraderProcess.find_stalled_process |
|
28 | 28 | |
|
29 | 29 | @terminated_processes = GraderProcess.find_terminated_graders |
|
30 | 30 | |
|
31 | 31 | @last_task = Task.find(:first, |
|
32 | 32 | :order => 'created_at DESC') |
|
33 | 33 | @last_test_request = TestRequest.find(:first, |
|
34 | 34 | :order => 'created_at DESC') |
|
35 | + @submission = Submission.order("id desc").limit(20) | |
|
35 | 36 | end |
|
36 | 37 | |
|
37 | 38 | def clear |
|
38 | 39 | grader_proc = GraderProcess.find(params[:id]) |
|
39 | 40 | grader_proc.destroy if grader_proc!=nil |
|
40 | 41 | redirect_to :action => 'list' |
|
41 | 42 | end |
|
42 | 43 | |
|
43 | 44 | def clear_terminated |
|
44 | 45 | GraderProcess.find_terminated_graders.each do |p| |
|
45 | 46 | p.destroy |
|
46 | 47 | end |
|
47 | 48 | redirect_to :action => 'list' |
|
48 | 49 | end |
|
49 | 50 | |
|
50 | 51 | def clear_all |
|
51 | 52 | GraderProcess.find(:all).each do |p| |
|
52 | 53 | p.destroy |
|
53 | 54 | end |
|
54 | 55 | redirect_to :action => 'list' |
|
55 | 56 | end |
|
56 | 57 | |
|
57 | 58 | def view |
|
58 | 59 | if params[:type]=='Task' |
|
59 | 60 | redirect_to :action => 'task', :id => params[:id] |
|
60 | 61 | else |
|
61 | 62 | redirect_to :action => 'test_request', :id => params[:id] |
|
62 | 63 | end |
|
63 | 64 | end |
|
64 | 65 | |
|
65 | 66 | def test_request |
|
66 | 67 | @test_request = TestRequest.find(params[:id]) |
|
67 | 68 | end |
|
68 | 69 | |
|
69 | 70 | def task |
|
70 | 71 | @task = Task.find(params[:id]) |
|
71 | 72 | end |
|
72 | 73 | |
|
73 | 74 | def submission |
|
74 | 75 | @submission = Submission.find(params[:id]) |
|
75 | 76 | formatter = Rouge::Formatters::HTML.new(css_class: 'highlight', line_numbers: true ) |
|
76 | 77 | lexer = case @submission.language.name |
|
77 | 78 | when "c" then Rouge::Lexers::C.new |
|
78 | 79 | when "cpp" then Rouge::Lexers::Cpp.new |
|
79 | 80 | when "pas" then Rouge::Lexers::Pas.new |
|
80 | 81 | when "ruby" then Rouge::Lexers::Ruby.new |
|
81 | 82 | when "python" then Rouge::Lexers::Python.new |
|
82 | 83 | when "java" then Rouge::Lexers::Java.new |
|
83 | 84 | when "php" then Rouge::Lexers::PHP.new |
|
84 | 85 | end |
|
85 | 86 | @formatted_code = formatter.format(lexer.lex(@submission.source)) |
|
86 | 87 | @css_style = Rouge::Themes::ThankfulEyes.render(scope: '.highlight') |
|
87 | 88 | |
|
88 | 89 | end |
|
89 | 90 | |
|
90 | 91 | # various grader controls |
|
91 | 92 | |
|
92 | 93 | def stop |
|
93 | 94 | grader_proc = GraderProcess.find(params[:id]) |
|
94 | 95 | GraderScript.stop_grader(grader_proc.pid) |
|
95 | 96 | flash[:notice] = 'Grader stopped. It may not disappear now, but it should disappear shortly.' |
|
96 | 97 | redirect_to :action => 'list' |
|
97 | 98 | end |
|
98 | 99 | |
|
99 | 100 | def stop_all |
|
100 | 101 | GraderScript.stop_graders(GraderProcess.find_running_graders + |
|
101 | 102 | GraderProcess.find_stalled_process) |
|
102 | 103 | flash[:notice] = 'Graders stopped. They may not disappear now, but they should disappear shortly.' |
|
103 | 104 | redirect_to :action => 'list' |
|
104 | 105 | end |
|
105 | 106 | |
|
106 | 107 | def start_grading |
|
107 | 108 | GraderScript.start_grader('grading') |
|
108 | 109 | flash[:notice] = '2 graders in grading env started, one for grading queue tasks, another for grading test request' |
|
109 | 110 | redirect_to :action => 'list' |
|
110 | 111 | end |
|
111 | 112 | |
|
112 | 113 | def start_exam |
|
113 | 114 | GraderScript.start_grader('exam') |
|
114 | 115 | flash[:notice] = '2 graders in grading env started, one for grading queue tasks, another for grading test request' |
|
115 | 116 | redirect_to :action => 'list' |
|
116 | 117 | end |
|
117 | 118 | |
|
118 | 119 | end |
@@ -1,51 +1,72 | |||
|
1 | 1 | - content_for :head do |
|
2 | 2 | = stylesheet_link_tag 'graders' |
|
3 | 3 | <meta http-equiv ="refresh" content="60"/> |
|
4 | 4 | |
|
5 | 5 | %h1 Grader information |
|
6 | 6 | |
|
7 | 7 | = link_to '[Refresh]', :action => 'list' |
|
8 | 8 | %br/ |
|
9 | 9 | |
|
10 | 10 | .submitbox |
|
11 | 11 | .item |
|
12 | 12 | Grader control: |
|
13 | 13 | .item |
|
14 | 14 | = form_for :clear, :url => {:action => 'start_grading'} do |f| |
|
15 | 15 | = submit_tag 'Start graders in grading env' |
|
16 | 16 | .item |
|
17 | 17 | = form_for :clear, :url => {:action => 'start_exam'} do |f| |
|
18 | 18 | = submit_tag 'Start graders in exam env' |
|
19 | 19 | .item |
|
20 | 20 | = form_for :clear, :url => {:action => 'stop_all'} do |f| |
|
21 | 21 | = submit_tag 'Stop all running graders' |
|
22 | 22 | .item |
|
23 | 23 | = form_for :clear, :url => {:action => 'clear_all'} do |f| |
|
24 | 24 | = submit_tag 'Clear all data' |
|
25 | 25 | %br{:style => 'clear:both'}/ |
|
26 | 26 | |
|
27 | + %div{style: 'width:500px; float: left;'} | |
|
27 | 28 | - if @last_task |
|
28 | 29 | Last task: |
|
29 | 30 | = link_to "#{@last_task.id}", :action => 'view', :id => @last_task.id, :type => 'Task' |
|
30 | 31 | |
|
31 | 32 | %br/ |
|
32 | 33 | |
|
33 | 34 | - if @last_test_request |
|
34 | 35 | Last test_request: |
|
35 | 36 | = link_to "#{@last_test_request.id}", :action => 'view', :id => @last_test_request.id, :type => 'TestRequest' |
|
36 | 37 | |
|
37 | - | |
|
38 | 38 | %h2 Current graders |
|
39 | 39 | |
|
40 | 40 | = render :partial => 'grader_list', :locals => {:grader_list => @grader_processes} |
|
41 | 41 | |
|
42 | 42 | %h2 Stalled graders |
|
43 | 43 | |
|
44 | 44 | = render :partial => 'grader_list', :locals => {:grader_list => @stalled_processes} |
|
45 | 45 | |
|
46 | 46 | %h2 Terminated graders |
|
47 | 47 | |
|
48 | 48 | = form_for :clear, :url => {:action => 'clear_terminated'} do |f| |
|
49 | 49 | = submit_tag 'Clear data for terminated graders' |
|
50 | 50 | |
|
51 | 51 | = render :partial => 'grader_list', :locals => {:grader_list => @terminated_processes} |
|
52 | + %div{} | |
|
53 | + %h2 Last 20 submissions | |
|
54 | + %table.graders | |
|
55 | + %thead | |
|
56 | + %th ID | |
|
57 | + %th User | |
|
58 | + %th Problem | |
|
59 | + %th Submitted | |
|
60 | + %th Graded | |
|
61 | + %th Result | |
|
62 | + %tbody | |
|
63 | + - @submission.each do |sub| | |
|
64 | + %tr.inactive | |
|
65 | + %td= link_to sub.id, controller: 'graders' ,action: 'submission', id: sub.id | |
|
66 | + %td= sub.try(:user).try(:full_name) | |
|
67 | + %td= sub.try(:problem).try(:full_name) | |
|
68 | + %td= "#{time_ago_in_words(sub.submitted_at)} ago" | |
|
69 | + %td= "#{time_ago_in_words(sub.graded_at)} ago" | |
|
70 | + %td= sub.grader_comment | |
|
71 | + | |
|
72 | + |
You need to be logged in to leave comments.
Login now