Description:
fixed new submission error showing nil compiler message
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r772:72eb3ebb9aef - - 1 file changed: 3 inserted, 1 deleted

@@ -1,158 +1,160
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'}
54 .modal.fade#compiler{tabindex: -1,role: 'dialog'}
55 .modal-dialog.modal-lg{role:'document'}
55 .modal-dialog.modal-lg{role:'document'}
56 .modal-content
56 .modal-content
57 .modal-header
57 .modal-header
58 %button.close{type: 'button', data: {dismissed: :modal}, aria: {label: 'close'}}
58 %button.close{type: 'button', data: {dismissed: :modal}, aria: {label: 'close'}}
59 %span{aria: {hidden: 'true'}, data: {dismiss: 'modal'}} &times;
59 %span{aria: {hidden: 'true'}, data: {dismiss: 'modal'}} &times;
60 %h4 Compiler message
60 %h4 Compiler message
61 .modal-body
61 .modal-body
62 - %pre#compiler_msg= @submission.compiler_message
62 + %pre#compiler_msg
63 + - if @submission
64 + = @submission.compiler_message
63 .modal-footer
65 .modal-footer
64 %button.btn.btn-default{type: 'button', data: {dismiss: 'modal'}} Close
66 %button.btn.btn-default{type: 'button', data: {dismiss: 'modal'}} Close
65
67
66 :javascript
68 :javascript
67 $(document).ready(function() {
69 $(document).ready(function() {
68 e = ace.edit("editor")
70 e = ace.edit("editor")
69 e.setValue($("#text_sourcecode").val());
71 e.setValue($("#text_sourcecode").val());
70 e.gotoLine(1);
72 e.gotoLine(1);
71 $("#language_id").trigger('change');
73 $("#language_id").trigger('change');
72
74
73 $("#load_file").on('change',function(evt) {
75 $("#load_file").on('change',function(evt) {
74 var file = evt.target.files[0];
76 var file = evt.target.files[0];
75 var reader = new FileReader();
77 var reader = new FileReader();
76 reader.onload = function(theFile) {
78 reader.onload = function(theFile) {
77 var e = ace.edit("editor")
79 var e = ace.edit("editor")
78 e.setValue(theFile.target.result);
80 e.setValue(theFile.target.result);
79 e.gotoLine(1);
81 e.gotoLine(1);
80 };
82 };
81 reader.readAsText(file)
83 reader.readAsText(file)
82 });
84 });
83
85
84 //brython();
86 //brython();
85 });
87 });
86
88
87
89
88
90
89
91
90
92
91 %script#__main__{type:'text/python3'}
93 %script#__main__{type:'text/python3'}
92 :plain
94 :plain
93 import sys
95 import sys
94 import traceback
96 import traceback
95
97
96 from browser import document as doc
98 from browser import document as doc
97 from browser import window, alert, console
99 from browser import window, alert, console
98
100
99 _credits = """ Thanks to CWI, CNRI, BeOpen.com, Zope Corporation and a cast of thousands
101 _credits = """ Thanks to CWI, CNRI, BeOpen.com, Zope Corporation and a cast of thousands
100 for supporting Python development. See www.python.org for more information."""
102 for supporting Python development. See www.python.org for more information."""
101
103
102 _copyright = """Copyright (c) 2012, Pierre Quentel pierre.quentel@gmail.com
104 _copyright = """Copyright (c) 2012, Pierre Quentel pierre.quentel@gmail.com
103 All Rights Reserved.
105 All Rights Reserved.
104
106
105 Copyright (c) 2001-2013 Python Software Foundation.
107 Copyright (c) 2001-2013 Python Software Foundation.
106 All Rights Reserved.
108 All Rights Reserved.
107
109
108 Copyright (c) 2000 BeOpen.com.
110 Copyright (c) 2000 BeOpen.com.
109 All Rights Reserved.
111 All Rights Reserved.
110
112
111 Copyright (c) 1995-2001 Corporation for National Research Initiatives.
113 Copyright (c) 1995-2001 Corporation for National Research Initiatives.
112 All Rights Reserved.
114 All Rights Reserved.
113
115
114 Copyright (c) 1991-1995 Stichting Mathematisch Centrum, Amsterdam.
116 Copyright (c) 1991-1995 Stichting Mathematisch Centrum, Amsterdam.
115 All Rights Reserved."""
117 All Rights Reserved."""
116
118
117 _license = """Copyright (c) 2012, Pierre Quentel pierre.quentel@gmail.com
119 _license = """Copyright (c) 2012, Pierre Quentel pierre.quentel@gmail.com
118 All rights reserved.
120 All rights reserved.
119
121
120 Redistribution and use in source and binary forms, with or without
122 Redistribution and use in source and binary forms, with or without
121 modification, are permitted provided that the following conditions are met:
123 modification, are permitted provided that the following conditions are met:
122
124
123 Redistributions of source code must retain the above copyright notice, this
125 Redistributions of source code must retain the above copyright notice, this
124 list of conditions and the following disclaimer. Redistributions in binary
126 list of conditions and the following disclaimer. Redistributions in binary
125 form must reproduce the above copyright notice, this list of conditions and
127 form must reproduce the above copyright notice, this list of conditions and
126 the following disclaimer in the documentation and/or other materials provided
128 the following disclaimer in the documentation and/or other materials provided
127 with the distribution.
129 with the distribution.
128 Neither the name of the <ORGANIZATION> nor the names of its contributors may
130 Neither the name of the <ORGANIZATION> nor the names of its contributors may
129 be used to endorse or promote products derived from this software without
131 be used to endorse or promote products derived from this software without
130 specific prior written permission.
132 specific prior written permission.
131
133
132 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
134 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
133 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
135 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
134 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
136 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
135 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
137 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
136 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
138 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
137 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
139 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
138 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
140 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
139 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
141 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
140 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
142 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
141 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
143 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
142 POSSIBILITY OF SUCH DAMAGE.
144 POSSIBILITY OF SUCH DAMAGE.
143 """
145 """
144
146
145 def credits():
147 def credits():
146 print(_credits)
148 print(_credits)
147 credits.__repr__ = lambda:_credits
149 credits.__repr__ = lambda:_credits
148
150
149 def copyright():
151 def copyright():
150 print(_copyright)
152 print(_copyright)
151 copyright.__repr__ = lambda:_copyright
153 copyright.__repr__ = lambda:_copyright
152
154
153 def license():
155 def license():
154 print(_license)
156 print(_license)
155 license.__repr__ = lambda:_license
157 license.__repr__ = lambda:_license
156
158
157 def write(data):
159 def write(data):
158 doc['console'].value += str(data)
160 doc['console'].value += str(data)
You need to be logged in to leave comments. Login now