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: 97 inserted, 53 deleted

@@ -38,8 +38,10
38 38 target.text '...'
39 39 return
40 40
41 - editor = ace.edit("editor")
42 - editor.setTheme("ace/theme/merbivore")
43 - editor.getSession().setMode("ace/mode/javascript")
41 + #ace editor
42 + e = ace.edit("editor")
43 + e.setTheme('ace/theme/merbivore')
44 + e.getSession().setTabSize(2)
45 + e.getSession().setUseSoftTabs(true)
44 46
45 47 return
@@ -115,6 +115,25
115 115 data: {remote: true, method: 'get'}}
116 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 137 def user_title_bar(user)
119 138 header = ''
120 139 time_left = ''
@@ -1,67 +1,90
1 - %style{type: "text/css"}
2 - = @css_style
3 - :css
4 - .field {
5 - font-weight: bold;
6 - text-align: right;
7 - padding: 3px;
8 - }
9 -
1 + //%style{type: "text/css"}
2 + // = @css_style
10 3
11 4 %h1= "Submission: #{@submission.id}"
12 5
13 -
14 - %h2 Stat
6 + %textarea#data{style: "display:none;"}
7 + :preserve
8 + #{@submission.source}
15 9
16 - %table.info
17 - %thead
18 - %tr.info-head
19 - %th Field
20 - %th Value
21 - %tbody
22 - %tr{class: cycle('info-even','info-odd')}
23 - %td.field User:
24 - %td.value
10 + //%div.highlight{:style => "border: 1px solid black;"}
11 + //=@formatted_code.html_safe
12 + .containter
13 + .row
14 + .col-md-7
15 + %h2 Source Code
16 + .col-md-5
17 + %h2 Stat
18 + .row
19 + .col-md-7
20 + %div#editor{ style: "font-size: 14px; height: 400px; border-radius:5px;" }
21 + :javascript
22 + e = ace.edit("editor")
23 + e.setOptions({ maxLines: Infinity })
24 + e.setValue($("#data").text())
25 + e.gotoLine(1)
26 + e.getSession().setMode("#{get_ace_mode(@submission.language)}")
27 + e.setReadOnly(true)
28 + .col-md-5
29 + %table.table.table-striped
30 + %tr
31 + %td.text-right
32 + %strong User
33 + %td
25 34 - if @submission.user
26 35 = link_to "(#{@submission.user.login})", controller: "users", action: "profile", id: @submission.user
27 36 = @submission.user.full_name
28 37 - else
29 38 = "(n/a)"
30 - %tr{class: cycle('info-even','info-odd')}
31 - %td.field Problem:
32 - %td.value
39 + %tr
40 + %td.text-right
41 + %strong Task
42 + %td
33 43 - if @submission.problem!=nil
34 44 = link_to "(#{@submission.problem.name})", controller: "problems", action: "stat", id: @submission.problem
35 45 = @submission.problem.full_name
36 46 - else
37 47 = "(n/a)"
38 - %tr{class: cycle('info-even','info-odd')}
39 - %td.field Tries:
40 - %td.value= @submission.number
41 - %tr{class: cycle('info-even','info-odd')}
42 - %td.field Submitted:
43 - %td.value #{time_ago_in_words(@submission.submitted_at)} ago (at #{@submission.submitted_at.to_formatted_s(:long)})
44 - %tr{class: cycle('info-even','info-odd')}
45 - %td.field Graded:
46 - %td.value #{time_ago_in_words(@submission.graded_at)} ago (at #{@submission.graded_at.to_formatted_s(:long)})
47 - %tr{class: cycle('info-even','info-odd')}
48 - %td.field Points:
49 - %td.value #{@submission.points}/#{@submission.problem.full_score}
50 - %tr{class: cycle('info-even','info-odd')}
51 - %td.field Comment:
52 - %td.value #{@submission.grader_comment}
53 - %tr{class: cycle('info-even','info-odd')}
54 - %td.field Runtime (s):
55 - %td.value #{@submission.max_runtime}
56 - %tr{class: cycle('info-even','info-odd')}
57 - %td.field Memory (kb):
58 - %td.value #{@submission.peak_memory}
48 + %tr
49 + %td.text-right
50 + %strong Tries
51 + %td= @submission.number
52 + %tr
53 + %td.text-right
54 + %strong Language
55 + %td= @submission.language.pretty_name
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}
59 83 - if session[:admin]
60 - %tr{class: cycle('info-even','info-odd')}
61 - %td.field IP:
62 - %td.value #{@submission.ip_address}
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