Description:
fix compiler message
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r742:4c1b44c35caf - - 2 files changed: 15 inserted, 1 deleted

@@ -1,28 +1,30
1 - if submission.nil?
1 - if submission.nil?
2 = "-"
2 = "-"
3 - else
3 - else
4 %strong= "Submission ID:"
4 %strong= "Submission ID:"
5 = submission.id
5 = submission.id
6 %br
6 %br
7 - unless submission.graded_at
7 - unless submission.graded_at
8 %strong= t 'main.submitted_at:'
8 %strong= t 'main.submitted_at:'
9 = format_full_time_ago(submission.submitted_at.localtime)
9 = format_full_time_ago(submission.submitted_at.localtime)
10 - else
10 - else
11 %strong= t 'main.graded_at:'
11 %strong= t 'main.graded_at:'
12 = format_full_time_ago(submission.graded_at.localtime)
12 = format_full_time_ago(submission.graded_at.localtime)
13 %br
13 %br
14 - if GraderConfiguration['ui.show_score']
14 - if GraderConfiguration['ui.show_score']
15 %strong=t 'main.score'
15 %strong=t 'main.score'
16 = "#{(submission.points*100/submission.problem.full_score).to_i} "
16 = "#{(submission.points*100/submission.problem.full_score).to_i} "
17 = " ["
17 = " ["
18 %tt
18 %tt
19 = submission.grader_comment
19 = submission.grader_comment
20 = "]"
20 = "]"
21 %br
21 %br
22 %strong View:
22 %strong View:
23 - if GraderConfiguration.show_grading_result
23 - if GraderConfiguration.show_grading_result
24 = link_to '[detailed result]', :action => 'result', :id => submission.id
24 = link_to '[detailed result]', :action => 'result', :id => submission.id
25 - = link_to "#{t 'main.cmp_msg'}", {:action => 'compiler_msg', :id => submission.id}, {popup: true,class: 'btn btn-xs btn-info'} if submission.graded_at
25 + - if submission.graded_at
26 + %button.btn.btn-info.btn-xs{type: 'button', data: {toggle: 'modal', target: '#compiler'}}
27 + =t 'main.cmp_msg'
26 = link_to "#{t 'main.src_link'}", download_submission_path(submission.id), class: 'btn btn-xs btn-info'
28 = link_to "#{t 'main.src_link'}", download_submission_path(submission.id), class: 'btn btn-xs btn-info'
27 = link_to "#{t 'main.submissions_link'}", problem_submissions_path(problem_id), class: 'btn btn-xs btn-info'
29 = link_to "#{t 'main.submissions_link'}", problem_submissions_path(problem_id), class: 'btn btn-xs btn-info'
28
30
@@ -1,245 +1,257
1 %h2 Live submit
1 %h2 Live submit
2 %br
2 %br
3
3
4 %textarea#text_sourcecode{style: "display:none"}~ @source
4 %textarea#text_sourcecode{style: "display:none"}~ @source
5 .container
5 .container
6 .row
6 .row
7 .col-md-12
7 .col-md-12
8 .alert.alert-info
8 .alert.alert-info
9 Write your code in the following box, choose language, and click submit button when finished
9 Write your code in the following box, choose language, and click submit button when finished
10 .row
10 .row
11 .col-md-8
11 .col-md-8
12 %div#editor{style: 'height: 500px; border-radius: 7px; font-size: 14px;'}
12 %div#editor{style: 'height: 500px; border-radius: 7px; font-size: 14px;'}
13 .col-md-4
13 .col-md-4
14 - # submission form
14 - # submission form
15 = form_tag({controller: :main, :action => 'submit'}, :multipart => true, class: 'form') do
15 = form_tag({controller: :main, :action => 'submit'}, :multipart => true, class: 'form') do
16
16
17 = hidden_field_tag 'editor_text', @source
17 = hidden_field_tag 'editor_text', @source
18 = hidden_field_tag 'submission[problem_id]', @problem.id
18 = hidden_field_tag 'submission[problem_id]', @problem.id
19 .form-group
19 .form-group
20 = label_tag "Task:"
20 = label_tag "Task:"
21 = text_field_tag 'asdf', "#{@problem.long_name}", class: 'form-control', disabled: true
21 = text_field_tag 'asdf', "#{@problem.long_name}", class: 'form-control', disabled: true
22 .form-group
22 .form-group
23 = label_tag "Description:"
23 = label_tag "Description:"
24 = link_to_description_if_any "[download] <span class='glyphicon glyphicon-file'></span>".html_safe, @problem
24 = link_to_description_if_any "[download] <span class='glyphicon glyphicon-file'></span>".html_safe, @problem
25
25
26 .form-group
26 .form-group
27 = label_tag 'Language:'
27 = label_tag 'Language:'
28 = select_tag 'language_id', options_from_collection_for_select(Language.all, 'id', 'pretty_name', @lang_id || Language.find_by_pretty_name("Python").id || Language.first.id), class: 'form-control select', style: "width: 100px"
28 = select_tag 'language_id', options_from_collection_for_select(Language.all, 'id', 'pretty_name', @lang_id || Language.find_by_pretty_name("Python").id || Language.first.id), class: 'form-control select', style: "width: 100px"
29 .form-group
29 .form-group
30 .input-group
30 .input-group
31 %span.input-group-btn
31 %span.input-group-btn
32 %span.btn.btn-default.btn-file
32 %span.btn.btn-default.btn-file
33 Browse
33 Browse
34 = file_field_tag 'load_file'
34 = file_field_tag 'load_file'
35 = text_field_tag '' , nil, {readonly: true, class: 'form-control'}
35 = text_field_tag '' , nil, {readonly: true, class: 'form-control'}
36 .form-group
36 .form-group
37 = submit_tag 'Submit', class: 'btn btn-success', id: 'live_submit',
37 = submit_tag 'Submit', class: 'btn btn-success', id: 'live_submit',
38 data: {confirm: "Submitting this source code for task #{@problem.long_name}?"}
38 data: {confirm: "Submitting this source code for task #{@problem.long_name}?"}
39 - # latest submission status
39 - # latest submission status
40 .panel{class: (@submission && @submission.graded_at) ? "panel-info" : "panel-warning"}
40 .panel{class: (@submission && @submission.graded_at) ? "panel-info" : "panel-warning"}
41 .panel-heading
41 .panel-heading
42 Latest Submission Status
42 Latest Submission Status
43 = link_to "Refresh",get_latest_submission_status_submissions_path(@submission.user,@problem), class: "btn btn-default btn-sm", remote: true if @submission
43 = link_to "Refresh",get_latest_submission_status_submissions_path(@submission.user,@problem), class: "btn btn-default btn-sm", remote: true if @submission
44 .panel-body
44 .panel-body
45 %div#latest_status
45 %div#latest_status
46 - if @submission
46 - if @submission
47 = render :partial => 'submission_short',
47 = render :partial => 'submission_short',
48 :locals => {submission: @submission, problem_name: @problem.name, problem_id: @problem.id }
48 :locals => {submission: @submission, problem_name: @problem.name, problem_id: @problem.id }
49 .row
49 .row
50 .col-md-12
50 .col-md-12
51 %h2 Console
51 %h2 Console
52 %textarea#console{style: 'height: 100%; width: 100%;background-color:#000;color:#fff;font-family: consolas, monaco, "Droid Sans Mono";',rows: 20}
52 %textarea#console{style: 'height: 100%; width: 100%;background-color:#000;color:#fff;font-family: consolas, monaco, "Droid Sans Mono";',rows: 20}
53
53
54 + .modal.fade#compiler{tabindex: -1,role: 'dialog'}
55 + .modal-dialog.modal-lg{role:'document'}
56 + .modal-content
57 + .modal-header
58 + %button.close{type: 'button', data: {dismissed: :modal}, aria: {label: 'close'}}
59 + %span{aria: {hidden: 'true'}, data: {dismiss: 'modal'}} &times;
60 + %h4 Compiler message
61 + .modal-body
62 + %pre#compiler_msg= @submission.compiler_message
63 + .modal-footer
64 + %button.btn.btn-default{type: 'button', data: {dismiss: 'modal'}} Close
65 +
54 :javascript
66 :javascript
55 $(document).ready(function() {
67 $(document).ready(function() {
56 e = ace.edit("editor")
68 e = ace.edit("editor")
57 e.setValue($("#text_sourcecode").val());
69 e.setValue($("#text_sourcecode").val());
58 e.gotoLine(1);
70 e.gotoLine(1);
59 $("#language_id").trigger('change');
71 $("#language_id").trigger('change');
60
72
61 $("#load_file").on('change',function(evt) {
73 $("#load_file").on('change',function(evt) {
62 var file = evt.target.files[0];
74 var file = evt.target.files[0];
63 var reader = new FileReader();
75 var reader = new FileReader();
64 reader.onload = function(theFile) {
76 reader.onload = function(theFile) {
65 var e = ace.edit("editor")
77 var e = ace.edit("editor")
66 e.setValue(theFile.target.result);
78 e.setValue(theFile.target.result);
67 e.gotoLine(1);
79 e.gotoLine(1);
68 };
80 };
69 reader.readAsText(file)
81 reader.readAsText(file)
70 });
82 });
71
83
72 //brython();
84 //brython();
73 });
85 });
74
86
75
87
76
88
77
89
78
90
79 %script#__main__{type:'text/python3'}
91 %script#__main__{type:'text/python3'}
80 :plain
92 :plain
81 import sys
93 import sys
82 import traceback
94 import traceback
83
95
84 from browser import document as doc
96 from browser import document as doc
85 from browser import window, alert, console
97 from browser import window, alert, console
86
98
87 _credits = """ Thanks to CWI, CNRI, BeOpen.com, Zope Corporation and a cast of thousands
99 _credits = """ Thanks to CWI, CNRI, BeOpen.com, Zope Corporation and a cast of thousands
88 for supporting Python development. See www.python.org for more information."""
100 for supporting Python development. See www.python.org for more information."""
89
101
90 _copyright = """Copyright (c) 2012, Pierre Quentel pierre.quentel@gmail.com
102 _copyright = """Copyright (c) 2012, Pierre Quentel pierre.quentel@gmail.com
91 All Rights Reserved.
103 All Rights Reserved.
92
104
93 Copyright (c) 2001-2013 Python Software Foundation.
105 Copyright (c) 2001-2013 Python Software Foundation.
94 All Rights Reserved.
106 All Rights Reserved.
95
107
96 Copyright (c) 2000 BeOpen.com.
108 Copyright (c) 2000 BeOpen.com.
97 All Rights Reserved.
109 All Rights Reserved.
98
110
99 Copyright (c) 1995-2001 Corporation for National Research Initiatives.
111 Copyright (c) 1995-2001 Corporation for National Research Initiatives.
100 All Rights Reserved.
112 All Rights Reserved.
101
113
102 Copyright (c) 1991-1995 Stichting Mathematisch Centrum, Amsterdam.
114 Copyright (c) 1991-1995 Stichting Mathematisch Centrum, Amsterdam.
103 All Rights Reserved."""
115 All Rights Reserved."""
104
116
105 _license = """Copyright (c) 2012, Pierre Quentel pierre.quentel@gmail.com
117 _license = """Copyright (c) 2012, Pierre Quentel pierre.quentel@gmail.com
106 All rights reserved.
118 All rights reserved.
107
119
108 Redistribution and use in source and binary forms, with or without
120 Redistribution and use in source and binary forms, with or without
109 modification, are permitted provided that the following conditions are met:
121 modification, are permitted provided that the following conditions are met:
110
122
111 Redistributions of source code must retain the above copyright notice, this
123 Redistributions of source code must retain the above copyright notice, this
112 list of conditions and the following disclaimer. Redistributions in binary
124 list of conditions and the following disclaimer. Redistributions in binary
113 form must reproduce the above copyright notice, this list of conditions and
125 form must reproduce the above copyright notice, this list of conditions and
114 the following disclaimer in the documentation and/or other materials provided
126 the following disclaimer in the documentation and/or other materials provided
115 with the distribution.
127 with the distribution.
116 Neither the name of the <ORGANIZATION> nor the names of its contributors may
128 Neither the name of the <ORGANIZATION> nor the names of its contributors may
117 be used to endorse or promote products derived from this software without
129 be used to endorse or promote products derived from this software without
118 specific prior written permission.
130 specific prior written permission.
119
131
120 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
132 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
121 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
133 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
122 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
134 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
123 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
135 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
124 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
136 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
125 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
137 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
126 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
138 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
127 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
139 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
128 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
140 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
129 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
141 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
130 POSSIBILITY OF SUCH DAMAGE.
142 POSSIBILITY OF SUCH DAMAGE.
131 """
143 """
132
144
133 def credits():
145 def credits():
134 print(_credits)
146 print(_credits)
135 credits.__repr__ = lambda:_credits
147 credits.__repr__ = lambda:_credits
136
148
137 def copyright():
149 def copyright():
138 print(_copyright)
150 print(_copyright)
139 copyright.__repr__ = lambda:_copyright
151 copyright.__repr__ = lambda:_copyright
140
152
141 def license():
153 def license():
142 print(_license)
154 print(_license)
143 license.__repr__ = lambda:_license
155 license.__repr__ = lambda:_license
144
156
145 def write(data):
157 def write(data):
146 doc['console'].value += str(data)
158 doc['console'].value += str(data)
147
159
148
160
149 sys.stdout.write = sys.stderr.write = write
161 sys.stdout.write = sys.stderr.write = write
150 history = []
162 history = []
151 current = 0
163 current = 0
152 _status = "main" # or "block" if typing inside a block
164 _status = "main" # or "block" if typing inside a block
153
165
154 # execution namespace
166 # execution namespace
155 editor_ns = {'credits':credits,
167 editor_ns = {'credits':credits,
156 'copyright':copyright,
168 'copyright':copyright,
157 'license':license,
169 'license':license,
158 '__name__':'__main__'}
170 '__name__':'__main__'}
159
171
160 def cursorToEnd(*args):
172 def cursorToEnd(*args):
161 pos = len(doc['console'].value)
173 pos = len(doc['console'].value)
162 doc['console'].setSelectionRange(pos, pos)
174 doc['console'].setSelectionRange(pos, pos)
163 doc['console'].scrollTop = doc['console'].scrollHeight
175 doc['console'].scrollTop = doc['console'].scrollHeight
164
176
165 def get_col(area):
177 def get_col(area):
166 # returns the column num of cursor
178 # returns the column num of cursor
167 sel = doc['console'].selectionStart
179 sel = doc['console'].selectionStart
168 lines = doc['console'].value.split('\n')
180 lines = doc['console'].value.split('\n')
169 for line in lines[:-1]:
181 for line in lines[:-1]:
170 sel -= len(line) + 1
182 sel -= len(line) + 1
171 return sel
183 return sel
172
184
173
185
174 def myKeyPress(event):
186 def myKeyPress(event):
175 global _status, current
187 global _status, current
176 if event.keyCode == 9: # tab key
188 if event.keyCode == 9: # tab key
177 event.preventDefault()
189 event.preventDefault()
178 doc['console'].value += " "
190 doc['console'].value += " "
179 elif event.keyCode == 13: # return
191 elif event.keyCode == 13: # return
180 src = doc['console'].value
192 src = doc['console'].value
181 if _status == "main":
193 if _status == "main":
182 currentLine = src[src.rfind('>>>') + 4:]
194 currentLine = src[src.rfind('>>>') + 4:]
183 elif _status == "3string":
195 elif _status == "3string":
184 currentLine = src[src.rfind('>>>') + 4:]
196 currentLine = src[src.rfind('>>>') + 4:]
185 currentLine = currentLine.replace('\n... ', '\n')
197 currentLine = currentLine.replace('\n... ', '\n')
186 else:
198 else:
187 currentLine = src[src.rfind('...') + 4:]
199 currentLine = src[src.rfind('...') + 4:]
188 if _status == 'main' and not currentLine.strip():
200 if _status == 'main' and not currentLine.strip():
189 doc['console'].value += '\n>>> '
201 doc['console'].value += '\n>>> '
190 event.preventDefault()
202 event.preventDefault()
191 return
203 return
192 doc['console'].value += '\n'
204 doc['console'].value += '\n'
193 history.append(currentLine)
205 history.append(currentLine)
194 current = len(history)
206 current = len(history)
195 if _status == "main" or _status == "3string":
207 if _status == "main" or _status == "3string":
196 try:
208 try:
197 _ = editor_ns['_'] = eval(currentLine, editor_ns)
209 _ = editor_ns['_'] = eval(currentLine, editor_ns)
198 if _ is not None:
210 if _ is not None:
199 write(repr(_)+'\n')
211 write(repr(_)+'\n')
200 doc['console'].value += '>>> '
212 doc['console'].value += '>>> '
201 _status = "main"
213 _status = "main"
202 except IndentationError:
214 except IndentationError:
203 doc['console'].value += '... '
215 doc['console'].value += '... '
204 _status = "block"
216 _status = "block"
205 except SyntaxError as msg:
217 except SyntaxError as msg:
206 if str(msg) == 'invalid syntax : triple string end not found' or \
218 if str(msg) == 'invalid syntax : triple string end not found' or \
207 str(msg).startswith('Unbalanced bracket'):
219 str(msg).startswith('Unbalanced bracket'):
208 doc['console'].value += '... '
220 doc['console'].value += '... '
209 _status = "3string"
221 _status = "3string"
210 elif str(msg) == 'eval() argument must be an expression':
222 elif str(msg) == 'eval() argument must be an expression':
211 try:
223 try:
212 exec(currentLine, editor_ns)
224 exec(currentLine, editor_ns)
213 except:
225 except:
214 traceback.print_exc()
226 traceback.print_exc()
215 doc['console'].value += '>>> '
227 doc['console'].value += '>>> '
216 _status = "main"
228 _status = "main"
217 elif str(msg) == 'decorator expects function':
229 elif str(msg) == 'decorator expects function':
218 doc['console'].value += '... '
230 doc['console'].value += '... '
219 _status = "block"
231 _status = "block"
220 else:
232 else:
221 traceback.print_exc()
233 traceback.print_exc()
222 doc['console'].value += '>>> '
234 doc['console'].value += '>>> '
223 _status = "main"
235 _status = "main"
224 except:
236 except:
225 traceback.print_exc()
237 traceback.print_exc()
226 doc['console'].value += '>>> '
238 doc['console'].value += '>>> '
227 _status = "main"
239 _status = "main"
228 elif currentLine == "": # end of block
240 elif currentLine == "": # end of block
229 block = src[src.rfind('>>>') + 4:].splitlines()
241 block = src[src.rfind('>>>') + 4:].splitlines()
230 block = [block[0]] + [b[4:] for b in block[1:]]
242 block = [block[0]] + [b[4:] for b in block[1:]]
231 block_src = '\n'.join(block)
243 block_src = '\n'.join(block)
232 # status must be set before executing code in globals()
244 # status must be set before executing code in globals()
233 _status = "main"
245 _status = "main"
234 try:
246 try:
235 _ = exec(block_src, editor_ns)
247 _ = exec(block_src, editor_ns)
236 if _ is not None:
248 if _ is not None:
237 print(repr(_))
249 print(repr(_))
238 except:
250 except:
239 traceback.print_exc()
251 traceback.print_exc()
240 doc['console'].value += '>>> '
252 doc['console'].value += '>>> '
241 else:
253 else:
242 doc['console'].value += '... '
254 doc['console'].value += '... '
243
255
244 cursorToEnd()
256 cursorToEnd()
245 event.preventDefault()
257 event.preventDefault()
You need to be logged in to leave comments. Login now