Description:
add lexer for php
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r451:46e3534d5d5d - - 1 file changed: 1 inserted, 0 deleted

@@ -35,83 +35,84
35 end
35 end
36
36
37 def clear
37 def clear
38 grader_proc = GraderProcess.find(params[:id])
38 grader_proc = GraderProcess.find(params[:id])
39 grader_proc.destroy if grader_proc!=nil
39 grader_proc.destroy if grader_proc!=nil
40 redirect_to :action => 'list'
40 redirect_to :action => 'list'
41 end
41 end
42
42
43 def clear_terminated
43 def clear_terminated
44 GraderProcess.find_terminated_graders.each do |p|
44 GraderProcess.find_terminated_graders.each do |p|
45 p.destroy
45 p.destroy
46 end
46 end
47 redirect_to :action => 'list'
47 redirect_to :action => 'list'
48 end
48 end
49
49
50 def clear_all
50 def clear_all
51 GraderProcess.find(:all).each do |p|
51 GraderProcess.find(:all).each do |p|
52 p.destroy
52 p.destroy
53 end
53 end
54 redirect_to :action => 'list'
54 redirect_to :action => 'list'
55 end
55 end
56
56
57 def view
57 def view
58 if params[:type]=='Task'
58 if params[:type]=='Task'
59 redirect_to :action => 'task', :id => params[:id]
59 redirect_to :action => 'task', :id => params[:id]
60 else
60 else
61 redirect_to :action => 'test_request', :id => params[:id]
61 redirect_to :action => 'test_request', :id => params[:id]
62 end
62 end
63 end
63 end
64
64
65 def test_request
65 def test_request
66 @test_request = TestRequest.find(params[:id])
66 @test_request = TestRequest.find(params[:id])
67 end
67 end
68
68
69 def task
69 def task
70 @task = Task.find(params[:id])
70 @task = Task.find(params[:id])
71 end
71 end
72
72
73 def submission
73 def submission
74 @submission = Submission.find(params[:id])
74 @submission = Submission.find(params[:id])
75 formatter = Rouge::Formatters::HTML.new(css_class: 'highlight', line_numbers: true )
75 formatter = Rouge::Formatters::HTML.new(css_class: 'highlight', line_numbers: true )
76 lexer = case @submission.language.name
76 lexer = case @submission.language.name
77 when "c" then Rouge::Lexers::C.new
77 when "c" then Rouge::Lexers::C.new
78 when "cpp" then Rouge::Lexers::Cpp.new
78 when "cpp" then Rouge::Lexers::Cpp.new
79 when "pas" then Rouge::Lexers::Pas.new
79 when "pas" then Rouge::Lexers::Pas.new
80 when "ruby" then Rouge::Lexers::Ruby.new
80 when "ruby" then Rouge::Lexers::Ruby.new
81 when "python" then Rouge::Lexers::Python.new
81 when "python" then Rouge::Lexers::Python.new
82 when "java" then Rouge::Lexers::Java.new
82 when "java" then Rouge::Lexers::Java.new
83 + when "php" then Rouge::Lexers::PHP.new
83 end
84 end
84 @formatted_code = formatter.format(lexer.lex(@submission.source))
85 @formatted_code = formatter.format(lexer.lex(@submission.source))
85 @css_style = Rouge::Themes::ThankfulEyes.render(scope: '.highlight')
86 @css_style = Rouge::Themes::ThankfulEyes.render(scope: '.highlight')
86
87
87 end
88 end
88
89
89 # various grader controls
90 # various grader controls
90
91
91 def stop
92 def stop
92 grader_proc = GraderProcess.find(params[:id])
93 grader_proc = GraderProcess.find(params[:id])
93 GraderScript.stop_grader(grader_proc.pid)
94 GraderScript.stop_grader(grader_proc.pid)
94 flash[:notice] = 'Grader stopped. It may not disappear now, but it should disappear shortly.'
95 flash[:notice] = 'Grader stopped. It may not disappear now, but it should disappear shortly.'
95 redirect_to :action => 'list'
96 redirect_to :action => 'list'
96 end
97 end
97
98
98 def stop_all
99 def stop_all
99 GraderScript.stop_graders(GraderProcess.find_running_graders +
100 GraderScript.stop_graders(GraderProcess.find_running_graders +
100 GraderProcess.find_stalled_process)
101 GraderProcess.find_stalled_process)
101 flash[:notice] = 'Graders stopped. They may not disappear now, but they should disappear shortly.'
102 flash[:notice] = 'Graders stopped. They may not disappear now, but they should disappear shortly.'
102 redirect_to :action => 'list'
103 redirect_to :action => 'list'
103 end
104 end
104
105
105 def start_grading
106 def start_grading
106 GraderScript.start_grader('grading')
107 GraderScript.start_grader('grading')
107 flash[:notice] = '2 graders in grading env started, one for grading queue tasks, another for grading test request'
108 flash[:notice] = '2 graders in grading env started, one for grading queue tasks, another for grading test request'
108 redirect_to :action => 'list'
109 redirect_to :action => 'list'
109 end
110 end
110
111
111 def start_exam
112 def start_exam
112 GraderScript.start_grader('exam')
113 GraderScript.start_grader('exam')
113 flash[:notice] = '2 graders in grading env started, one for grading queue tasks, another for grading test request'
114 flash[:notice] = '2 graders in grading env started, one for grading queue tasks, another for grading test request'
114 redirect_to :action => 'list'
115 redirect_to :action => 'list'
115 end
116 end
116
117
117 end
118 end
You need to be logged in to leave comments. Login now