Description:
use ace editor for submission viewing
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r566:46de378c3b60 - - 3 files changed: 109 inserted, 65 deleted

@@ -37,9 +37,11
37 target.addClass 'btn-warning'
37 target.addClass 'btn-warning'
38 target.text '...'
38 target.text '...'
39 return
39 return
40 -
40 +
41 - editor = ace.edit("editor")
41 + #ace editor
42 - editor.setTheme("ace/theme/merbivore")
42 + e = ace.edit("editor")
43 - editor.getSession().setMode("ace/mode/javascript")
43 + e.setTheme('ace/theme/merbivore')
44 + e.getSession().setTabSize(2)
45 + e.getSession().setUseSoftTabs(true)
44
46
45 return
47 return
@@ -115,6 +115,25
115 data: {remote: true, method: 'get'}}
115 data: {remote: true, method: 'get'}}
116 end
116 end
117
117
118 + def get_ace_mode(language)
119 + # return ace mode string from Language
120 +
121 + case language.pretty_name
122 + when 'Pascal'
123 + 'ace/mode/pascal'
124 + when 'C++','C'
125 + 'ace/mode/c_cpp'
126 + when 'Ruby'
127 + 'ace/mode/ruby'
128 + when 'Python'
129 + 'ace/mode/python'
130 + when 'Java'
131 + 'ace/mode/java'
132 + else
133 + 'ace/mode/c_cpp'
134 + end
135 + end
136 +
118 def user_title_bar(user)
137 def user_title_bar(user)
119 header = ''
138 header = ''
120 time_left = ''
139 time_left = ''
@@ -1,67 +1,90
1 - %style{type: "text/css"}
1 + //%style{type: "text/css"}
2 - = @css_style
2 + // = @css_style
3 - :css
4 - .field {
5 - font-weight: bold;
6 - text-align: right;
7 - padding: 3px;
8 - }
9 -
10
3
11 %h1= "Submission: #{@submission.id}"
4 %h1= "Submission: #{@submission.id}"
12
5
13 -
6 + %textarea#data{style: "display:none;"}
14 - %h2 Stat
7 + :preserve
8 + #{@submission.source}
15
9
16 - %table.info
10 + //%div.highlight{:style => "border: 1px solid black;"}
17 - %thead
11 + //=@formatted_code.html_safe
18 - %tr.info-head
12 + .containter
19 - %th Field
13 + .row
20 - %th Value
14 + .col-md-7
21 - %tbody
15 + %h2 Source Code
22 - %tr{class: cycle('info-even','info-odd')}
16 + .col-md-5
23 - %td.field User:
17 + %h2 Stat
24 - %td.value
18 + .row
25 - - if @submission.user
19 + .col-md-7
26 - = link_to "(#{@submission.user.login})", controller: "users", action: "profile", id: @submission.user
20 + %div#editor{ style: "font-size: 14px; height: 400px; border-radius:5px;" }
27 - = @submission.user.full_name
21 + :javascript
28 - - else
22 + e = ace.edit("editor")
29 - = "(n/a)"
23 + e.setOptions({ maxLines: Infinity })
30 - %tr{class: cycle('info-even','info-odd')}
24 + e.setValue($("#data").text())
31 - %td.field Problem:
25 + e.gotoLine(1)
32 - %td.value
26 + e.getSession().setMode("#{get_ace_mode(@submission.language)}")
33 - - if @submission.problem!=nil
27 + e.setReadOnly(true)
34 - = link_to "(#{@submission.problem.name})", controller: "problems", action: "stat", id: @submission.problem
28 + .col-md-5
35 - = @submission.problem.full_name
29 + %table.table.table-striped
36 - - else
30 + %tr
37 - = "(n/a)"
31 + %td.text-right
38 - %tr{class: cycle('info-even','info-odd')}
32 + %strong User
39 - %td.field Tries:
33 + %td
40 - %td.value= @submission.number
34 + - if @submission.user
41 - %tr{class: cycle('info-even','info-odd')}
35 + = link_to "(#{@submission.user.login})", controller: "users", action: "profile", id: @submission.user
42 - %td.field Submitted:
36 + = @submission.user.full_name
43 - %td.value #{time_ago_in_words(@submission.submitted_at)} ago (at #{@submission.submitted_at.to_formatted_s(:long)})
37 + - else
44 - %tr{class: cycle('info-even','info-odd')}
38 + = "(n/a)"
45 - %td.field Graded:
39 + %tr
46 - %td.value #{time_ago_in_words(@submission.graded_at)} ago (at #{@submission.graded_at.to_formatted_s(:long)})
40 + %td.text-right
47 - %tr{class: cycle('info-even','info-odd')}
41 + %strong Task
48 - %td.field Points:
42 + %td
49 - %td.value #{@submission.points}/#{@submission.problem.full_score}
43 + - if @submission.problem!=nil
50 - %tr{class: cycle('info-even','info-odd')}
44 + = link_to "(#{@submission.problem.name})", controller: "problems", action: "stat", id: @submission.problem
51 - %td.field Comment:
45 + = @submission.problem.full_name
52 - %td.value #{@submission.grader_comment}
46 + - else
53 - %tr{class: cycle('info-even','info-odd')}
47 + = "(n/a)"
54 - %td.field Runtime (s):
48 + %tr
55 - %td.value #{@submission.max_runtime}
49 + %td.text-right
56 - %tr{class: cycle('info-even','info-odd')}
50 + %strong Tries
57 - %td.field Memory (kb):
51 + %td= @submission.number
58 - %td.value #{@submission.peak_memory}
52 + %tr
59 - - if session[:admin]
53 + %td.text-right
60 - %tr{class: cycle('info-even','info-odd')}
54 + %strong Language
61 - %td.field IP:
55 + %td= @submission.language.pretty_name
62 - %td.value #{@submission.ip_address}
56 + %tr
57 + %td.text-right
58 + %strong Submitted
59 + %td #{time_ago_in_words(@submission.submitted_at)} ago (at #{@submission.submitted_at.to_formatted_s(:long)})
60 + %tr
61 + %td.text-right
62 + %strong Graded
63 + - if @submission.graded_at
64 + %td #{time_ago_in_words(@submission.graded_at)} ago (at #{@submission.graded_at.to_formatted_s(:long)})
65 + - else
66 + %td -
67 + %tr
68 + %td.text-right
69 + %strong Points
70 + %td #{@submission.points}/#{@submission.problem.full_score}
71 + %tr
72 + %td.text-right
73 + %strong Comment
74 + %td #{@submission.grader_comment}
75 + %tr
76 + %td.text-right
77 + %strong Runtime (s)
78 + %td #{@submission.max_runtime}
79 + %tr
80 + %td.text-right
81 + %strong Memory (kb)
82 + %td #{@submission.peak_memory}
83 + - if session[:admin]
84 + %tr
85 + %td.text-right
86 + %strong IP
87 + %td #{@submission.ip_address}
63
88
64 - %h2 Source code
65 - //%div.highlight{:style => "border: 1px solid black;"}
66 - =@formatted_code.html_safe
67
89
90 +
You need to be logged in to leave comments. Login now