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

@@ -29,17 +29,19
29 url = $(link).val()
29 url = $(link).val()
30 if url
30 if url
31 window.location.href = url
31 window.location.href = url
32 return
32 return
33 $('.ajax-toggle').on 'click', (event) ->
33 $('.ajax-toggle').on 'click', (event) ->
34 target = $(event.target)
34 target = $(event.target)
35 target.removeClass 'btn-default'
35 target.removeClass 'btn-default'
36 target.removeClass 'btn-success'
36 target.removeClass 'btn-success'
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
@@ -106,24 +106,43
106 nil
106 nil
107 end
107 end
108 end
108 end
109
109
110 def toggle_button(on,toggle_url,id, option={})
110 def toggle_button(on,toggle_url,id, option={})
111 btn_size = option[:size] || 'btn-xs'
111 btn_size = option[:size] || 'btn-xs'
112 link_to (on ? "Yes" : "No"), toggle_url,
112 link_to (on ? "Yes" : "No"), toggle_url,
113 {class: "btn btn-block #{btn_size} btn-#{on ? 'success' : 'default'} ajax-toggle",
113 {class: "btn btn-block #{btn_size} btn-#{on ? 'success' : 'default'} ajax-toggle",
114 id: id,
114 id: id,
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 = ''
121
140
122 #
141 #
123 # if the contest is over
142 # if the contest is over
124 if GraderConfiguration.time_limit_mode?
143 if GraderConfiguration.time_limit_mode?
125 if user.contest_finished?
144 if user.contest_finished?
126 header = <<CONTEST_OVER
145 header = <<CONTEST_OVER
127 <tr><td colspan="2" align="center">
146 <tr><td colspan="2" align="center">
128 <span class="contest-over-msg">THE CONTEST IS OVER</span>
147 <span class="contest-over-msg">THE CONTEST IS OVER</span>
129 </td></tr>
148 </td></tr>
@@ -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
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 - if @submission.user
34 - if @submission.user
26 = link_to "(#{@submission.user.login})", controller: "users", action: "profile", id: @submission.user
35 = link_to "(#{@submission.user.login})", controller: "users", action: "profile", id: @submission.user
27 = @submission.user.full_name
36 = @submission.user.full_name
28 - else
37 - else
29 = "(n/a)"
38 = "(n/a)"
30 - %tr{class: cycle('info-even','info-odd')}
39 + %tr
31 - %td.field Problem:
40 + %td.text-right
32 - %td.value
41 + %strong Task
42 + %td
33 - if @submission.problem!=nil
43 - if @submission.problem!=nil
34 = link_to "(#{@submission.problem.name})", controller: "problems", action: "stat", id: @submission.problem
44 = link_to "(#{@submission.problem.name})", controller: "problems", action: "stat", id: @submission.problem
35 = @submission.problem.full_name
45 = @submission.problem.full_name
36 - else
46 - else
37 = "(n/a)"
47 = "(n/a)"
38 - %tr{class: cycle('info-even','info-odd')}
48 + %tr
39 - %td.field Tries:
49 + %td.text-right
40 - %td.value= @submission.number
50 + %strong Tries
41 - %tr{class: cycle('info-even','info-odd')}
51 + %td= @submission.number
42 - %td.field Submitted:
52 + %tr
43 - %td.value #{time_ago_in_words(@submission.submitted_at)} ago (at #{@submission.submitted_at.to_formatted_s(:long)})
53 + %td.text-right
44 - %tr{class: cycle('info-even','info-odd')}
54 + %strong Language
45 - %td.field Graded:
55 + %td= @submission.language.pretty_name
46 - %td.value #{time_ago_in_words(@submission.graded_at)} ago (at #{@submission.graded_at.to_formatted_s(:long)})
56 + %tr
47 - %tr{class: cycle('info-even','info-odd')}
57 + %td.text-right
48 - %td.field Points:
58 + %strong Submitted
49 - %td.value #{@submission.points}/#{@submission.problem.full_score}
59 + %td #{time_ago_in_words(@submission.submitted_at)} ago (at #{@submission.submitted_at.to_formatted_s(:long)})
50 - %tr{class: cycle('info-even','info-odd')}
60 + %tr
51 - %td.field Comment:
61 + %td.text-right
52 - %td.value #{@submission.grader_comment}
62 + %strong Graded
53 - %tr{class: cycle('info-even','info-odd')}
63 + - if @submission.graded_at
54 - %td.field Runtime (s):
64 + %td #{time_ago_in_words(@submission.graded_at)} ago (at #{@submission.graded_at.to_formatted_s(:long)})
55 - %td.value #{@submission.max_runtime}
65 + - else
56 - %tr{class: cycle('info-even','info-odd')}
66 + %td -
57 - %td.field Memory (kb):
67 + %tr
58 - %td.value #{@submission.peak_memory}
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 - if session[:admin]
83 - if session[:admin]
60 - %tr{class: cycle('info-even','info-odd')}
84 + %tr
61 - %td.field IP:
85 + %td.text-right
62 - %td.value #{@submission.ip_address}
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