Description:
add submission test
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r761:4315e4a33c9c - - 6 files changed: 101 inserted, 233 deleted
@@ -0,0 +1,44 | |||||
|
|
1 | + require "application_system_test_case" | ||
|
|
2 | + | ||
|
|
3 | + class SubmissionsTest < ApplicationSystemTestCase | ||
|
|
4 | + # test "visiting the index" do | ||
|
|
5 | + # visit users_url | ||
|
|
6 | + # | ||
|
|
7 | + # assert_selector "h1", text: "User" | ||
|
|
8 | + # end | ||
|
|
9 | + | ||
|
|
10 | + test "add new submission" do | ||
|
|
11 | + #admin can add new submission regardless of availability of the problem | ||
|
|
12 | + login('admin','admin') | ||
|
|
13 | + visit direct_edit_problem_submissions_path(problems(:prob_sub)) | ||
|
|
14 | + assert_text 'Live submit' | ||
|
|
15 | + find('.ace_text-input',visible: false).set "test code (will cause compilation error)" | ||
|
|
16 | + click_on 'Submit' | ||
|
|
17 | + page.accept_confirm | ||
|
|
18 | + assert_text 'less than a minute ago' | ||
|
|
19 | + visit logout_main_path | ||
|
|
20 | + | ||
|
|
21 | + #normal user can submit available problem | ||
|
|
22 | + login('john','hello') | ||
|
|
23 | + visit direct_edit_problem_submissions_path(problems(:prob_add)) | ||
|
|
24 | + assert_text 'Live submit' | ||
|
|
25 | + find('.ace_text-input',visible: false).set "test code (will cause compilation error)" | ||
|
|
26 | + click_on 'Submit' | ||
|
|
27 | + page.accept_confirm | ||
|
|
28 | + assert_text 'less than a minute ago' | ||
|
|
29 | + visit logout_main_path | ||
|
|
30 | + | ||
|
|
31 | + #but not unavailable problem | ||
|
|
32 | + login('john','hello') | ||
|
|
33 | + visit direct_edit_problem_submissions_path(problems(:prob_sub)) | ||
|
|
34 | + assert_text 'You are not authorized' | ||
|
|
35 | + end | ||
|
|
36 | + | ||
|
|
37 | + | ||
|
|
38 | + def login(username,password) | ||
|
|
39 | + visit root_path | ||
|
|
40 | + fill_in "Login", with: username | ||
|
|
41 | + fill_in "Password", with: password | ||
|
|
42 | + click_on "Login" | ||
|
|
43 | + end | ||
|
|
44 | + end |
@@ -38,96 +38,99 | |||||
|
38 | activesupport (= 5.2.3) |
|
38 | activesupport (= 5.2.3) |
|
39 | arel (>= 9.0) |
|
39 | arel (>= 9.0) |
|
40 | activerecord-session_store (1.1.3) |
|
40 | activerecord-session_store (1.1.3) |
|
41 | actionpack (>= 4.0) |
|
41 | actionpack (>= 4.0) |
|
42 | activerecord (>= 4.0) |
|
42 | activerecord (>= 4.0) |
|
43 | multi_json (~> 1.11, >= 1.11.2) |
|
43 | multi_json (~> 1.11, >= 1.11.2) |
|
44 | rack (>= 1.5.2, < 3) |
|
44 | rack (>= 1.5.2, < 3) |
|
45 | railties (>= 4.0) |
|
45 | railties (>= 4.0) |
|
46 | activestorage (5.2.3) |
|
46 | activestorage (5.2.3) |
|
47 | actionpack (= 5.2.3) |
|
47 | actionpack (= 5.2.3) |
|
48 | activerecord (= 5.2.3) |
|
48 | activerecord (= 5.2.3) |
|
49 | marcel (~> 0.3.1) |
|
49 | marcel (~> 0.3.1) |
|
50 | activesupport (5.2.3) |
|
50 | activesupport (5.2.3) |
|
51 | concurrent-ruby (~> 1.0, >= 1.0.2) |
|
51 | concurrent-ruby (~> 1.0, >= 1.0.2) |
|
52 | i18n (>= 0.7, < 2) |
|
52 | i18n (>= 0.7, < 2) |
|
53 | minitest (~> 5.1) |
|
53 | minitest (~> 5.1) |
|
54 | tzinfo (~> 1.1) |
|
54 | tzinfo (~> 1.1) |
|
55 | addressable (2.6.0) |
|
55 | addressable (2.6.0) |
|
56 | public_suffix (>= 2.0.2, < 4.0) |
|
56 | public_suffix (>= 2.0.2, < 4.0) |
|
57 | ansi (1.5.0) |
|
57 | ansi (1.5.0) |
|
58 | arel (9.0.0) |
|
58 | arel (9.0.0) |
|
59 | autoprefixer-rails (9.5.1.1) |
|
59 | autoprefixer-rails (9.5.1.1) |
|
60 | execjs |
|
60 | execjs |
|
61 | best_in_place (3.0.3) |
|
61 | best_in_place (3.0.3) |
|
62 | actionpack (>= 3.2) |
|
62 | actionpack (>= 3.2) |
|
63 | railties (>= 3.2) |
|
63 | railties (>= 3.2) |
|
64 | bindex (0.7.0) |
|
64 | bindex (0.7.0) |
|
65 | bootsnap (1.4.4) |
|
65 | bootsnap (1.4.4) |
|
66 | msgpack (~> 1.0) |
|
66 | msgpack (~> 1.0) |
|
67 | bootstrap-datepicker-rails (1.8.0.1) |
|
67 | bootstrap-datepicker-rails (1.8.0.1) |
|
68 | railties (>= 3.0) |
|
68 | railties (>= 3.0) |
|
69 | bootstrap-sass (3.4.1) |
|
69 | bootstrap-sass (3.4.1) |
|
70 | autoprefixer-rails (>= 5.2.1) |
|
70 | autoprefixer-rails (>= 5.2.1) |
|
71 | sassc (>= 2.0.0) |
|
71 | sassc (>= 2.0.0) |
|
72 | bootstrap-switch-rails (3.3.4) |
|
72 | bootstrap-switch-rails (3.3.4) |
|
73 | bootstrap-toggle-rails (2.2.1.0) |
|
73 | bootstrap-toggle-rails (2.2.1.0) |
|
74 | bootstrap3-datetimepicker-rails (4.17.47) |
|
74 | bootstrap3-datetimepicker-rails (4.17.47) |
|
75 | momentjs-rails (>= 2.8.1) |
|
75 | momentjs-rails (>= 2.8.1) |
|
76 | builder (3.2.3) |
|
76 | builder (3.2.3) |
|
77 | byebug (11.0.1) |
|
77 | byebug (11.0.1) |
|
78 | capybara (3.25.0) |
|
78 | capybara (3.25.0) |
|
79 | addressable |
|
79 | addressable |
|
80 | mini_mime (>= 0.1.3) |
|
80 | mini_mime (>= 0.1.3) |
|
81 | nokogiri (~> 1.8) |
|
81 | nokogiri (~> 1.8) |
|
82 | rack (>= 1.6.0) |
|
82 | rack (>= 1.6.0) |
|
83 | rack-test (>= 0.6.3) |
|
83 | rack-test (>= 0.6.3) |
|
84 | regexp_parser (~> 1.5) |
|
84 | regexp_parser (~> 1.5) |
|
85 | xpath (~> 3.2) |
|
85 | xpath (~> 3.2) |
|
|
86 | + capybara-console (0.0.4) | ||
|
|
87 | + capybara | ||
|
|
88 | + rails (>= 3.0) | ||
|
86 | childprocess (1.0.1) |
|
89 | childprocess (1.0.1) |
|
87 | rake (< 13.0) |
|
90 | rake (< 13.0) |
|
88 | coffee-rails (4.2.2) |
|
91 | coffee-rails (4.2.2) |
|
89 | coffee-script (>= 2.2.0) |
|
92 | coffee-script (>= 2.2.0) |
|
90 | railties (>= 4.0.0) |
|
93 | railties (>= 4.0.0) |
|
91 | coffee-script (2.4.1) |
|
94 | coffee-script (2.4.1) |
|
92 | coffee-script-source |
|
95 | coffee-script-source |
|
93 | execjs |
|
96 | execjs |
|
94 | coffee-script-source (1.12.2) |
|
97 | coffee-script-source (1.12.2) |
|
95 | concurrent-ruby (1.1.5) |
|
98 | concurrent-ruby (1.1.5) |
|
96 | crass (1.0.4) |
|
99 | crass (1.0.4) |
|
97 | dynamic_form (1.1.4) |
|
100 | dynamic_form (1.1.4) |
|
98 | erubi (1.8.0) |
|
101 | erubi (1.8.0) |
|
99 | erubis (2.7.0) |
|
102 | erubis (2.7.0) |
|
100 | execjs (2.7.0) |
|
103 | execjs (2.7.0) |
|
101 | ffi (1.11.1) |
|
104 | ffi (1.11.1) |
|
102 | fuzzy-string-match (1.0.1) |
|
105 | fuzzy-string-match (1.0.1) |
|
103 | RubyInline (>= 3.8.6) |
|
106 | RubyInline (>= 3.8.6) |
|
104 | globalid (0.4.2) |
|
107 | globalid (0.4.2) |
|
105 | activesupport (>= 4.2.0) |
|
108 | activesupport (>= 4.2.0) |
|
106 | haml (5.1.0) |
|
109 | haml (5.1.0) |
|
107 | temple (>= 0.8.0) |
|
110 | temple (>= 0.8.0) |
|
108 | tilt |
|
111 | tilt |
|
109 | haml-rails (1.0.0) |
|
112 | haml-rails (1.0.0) |
|
110 | actionpack (>= 4.0.1) |
|
113 | actionpack (>= 4.0.1) |
|
111 | activesupport (>= 4.0.1) |
|
114 | activesupport (>= 4.0.1) |
|
112 | haml (>= 4.0.6, < 6.0) |
|
115 | haml (>= 4.0.6, < 6.0) |
|
113 | html2haml (>= 1.0.1) |
|
116 | html2haml (>= 1.0.1) |
|
114 | railties (>= 4.0.1) |
|
117 | railties (>= 4.0.1) |
|
115 | html2haml (2.2.0) |
|
118 | html2haml (2.2.0) |
|
116 | erubis (~> 2.7.0) |
|
119 | erubis (~> 2.7.0) |
|
117 | haml (>= 4.0, < 6) |
|
120 | haml (>= 4.0, < 6) |
|
118 | nokogiri (>= 1.6.0) |
|
121 | nokogiri (>= 1.6.0) |
|
119 | ruby_parser (~> 3.5) |
|
122 | ruby_parser (~> 3.5) |
|
120 | i18n (1.6.0) |
|
123 | i18n (1.6.0) |
|
121 | concurrent-ruby (~> 1.0) |
|
124 | concurrent-ruby (~> 1.0) |
|
122 | in_place_editing (1.2.0) |
|
125 | in_place_editing (1.2.0) |
|
123 | jbuilder (2.9.1) |
|
126 | jbuilder (2.9.1) |
|
124 | activesupport (>= 4.2.0) |
|
127 | activesupport (>= 4.2.0) |
|
125 | jquery-countdown-rails (2.0.2) |
|
128 | jquery-countdown-rails (2.0.2) |
|
126 | jquery-datatables-rails (3.4.0) |
|
129 | jquery-datatables-rails (3.4.0) |
|
127 | actionpack (>= 3.1) |
|
130 | actionpack (>= 3.1) |
|
128 | jquery-rails |
|
131 | jquery-rails |
|
129 | railties (>= 3.1) |
|
132 | railties (>= 3.1) |
|
130 | sass-rails |
|
133 | sass-rails |
|
131 | jquery-rails (4.3.3) |
|
134 | jquery-rails (4.3.3) |
|
132 | rails-dom-testing (>= 1, < 3) |
|
135 | rails-dom-testing (>= 1, < 3) |
|
133 | railties (>= 4.2.0) |
|
136 | railties (>= 4.2.0) |
@@ -251,87 +254,88 | |||||
|
251 | sprockets (3.7.2) |
|
254 | sprockets (3.7.2) |
|
252 | concurrent-ruby (~> 1.0) |
|
255 | concurrent-ruby (~> 1.0) |
|
253 | rack (> 1, < 3) |
|
256 | rack (> 1, < 3) |
|
254 | sprockets-rails (3.2.1) |
|
257 | sprockets-rails (3.2.1) |
|
255 | actionpack (>= 4.0) |
|
258 | actionpack (>= 4.0) |
|
256 | activesupport (>= 4.0) |
|
259 | activesupport (>= 4.0) |
|
257 | sprockets (>= 3.0.0) |
|
260 | sprockets (>= 3.0.0) |
|
258 | sqlite3 (1.4.1) |
|
261 | sqlite3 (1.4.1) |
|
259 | temple (0.8.1) |
|
262 | temple (0.8.1) |
|
260 | thor (0.20.3) |
|
263 | thor (0.20.3) |
|
261 | thread_safe (0.3.6) |
|
264 | thread_safe (0.3.6) |
|
262 | tilt (2.0.9) |
|
265 | tilt (2.0.9) |
|
263 | tzinfo (1.2.5) |
|
266 | tzinfo (1.2.5) |
|
264 | thread_safe (~> 0.1) |
|
267 | thread_safe (~> 0.1) |
|
265 | uglifier (4.1.20) |
|
268 | uglifier (4.1.20) |
|
266 | execjs (>= 0.3.0, < 3) |
|
269 | execjs (>= 0.3.0, < 3) |
|
267 | web-console (3.7.0) |
|
270 | web-console (3.7.0) |
|
268 | actionview (>= 5.0) |
|
271 | actionview (>= 5.0) |
|
269 | activemodel (>= 5.0) |
|
272 | activemodel (>= 5.0) |
|
270 | bindex (>= 0.4.0) |
|
273 | bindex (>= 0.4.0) |
|
271 | railties (>= 5.0) |
|
274 | railties (>= 5.0) |
|
272 | webdriver (0.1.0) |
|
275 | webdriver (0.1.0) |
|
273 | websocket-driver (0.7.1) |
|
276 | websocket-driver (0.7.1) |
|
274 | websocket-extensions (>= 0.1.0) |
|
277 | websocket-extensions (>= 0.1.0) |
|
275 | websocket-extensions (0.1.4) |
|
278 | websocket-extensions (0.1.4) |
|
276 | will_paginate (3.0.12) |
|
279 | will_paginate (3.0.12) |
|
277 | xpath (3.2.0) |
|
280 | xpath (3.2.0) |
|
278 | nokogiri (~> 1.8) |
|
281 | nokogiri (~> 1.8) |
|
279 | yaml_db (0.7.0) |
|
282 | yaml_db (0.7.0) |
|
280 | rails (>= 3.0) |
|
283 | rails (>= 3.0) |
|
281 | rake (>= 0.8.7) |
|
284 | rake (>= 0.8.7) |
|
282 |
|
285 | ||
|
283 | PLATFORMS |
|
286 | PLATFORMS |
|
284 | ruby |
|
287 | ruby |
|
285 |
|
288 | ||
|
286 | DEPENDENCIES |
|
289 | DEPENDENCIES |
|
287 | ace-rails-ap |
|
290 | ace-rails-ap |
|
288 | activerecord-session_store |
|
291 | activerecord-session_store |
|
289 | autoprefixer-rails |
|
292 | autoprefixer-rails |
|
290 | best_in_place (~> 3.0.1) |
|
293 | best_in_place (~> 3.0.1) |
|
291 | bootsnap (>= 1.1.0) |
|
294 | bootsnap (>= 1.1.0) |
|
292 | bootstrap-datepicker-rails |
|
295 | bootstrap-datepicker-rails |
|
293 | bootstrap-sass (~> 3.4.1) |
|
296 | bootstrap-sass (~> 3.4.1) |
|
294 | bootstrap-switch-rails |
|
297 | bootstrap-switch-rails |
|
295 | bootstrap-toggle-rails |
|
298 | bootstrap-toggle-rails |
|
296 | bootstrap3-datetimepicker-rails |
|
299 | bootstrap3-datetimepicker-rails |
|
297 | byebug |
|
300 | byebug |
|
298 | capybara (>= 2.15) |
|
301 | capybara (>= 2.15) |
|
|
302 | + capybara-console | ||
|
299 | coffee-rails |
|
303 | coffee-rails |
|
300 | dynamic_form |
|
304 | dynamic_form |
|
301 | fuzzy-string-match |
|
305 | fuzzy-string-match |
|
302 | haml |
|
306 | haml |
|
303 | haml-rails |
|
307 | haml-rails |
|
304 | in_place_editing |
|
308 | in_place_editing |
|
305 | jbuilder (~> 2.5) |
|
309 | jbuilder (~> 2.5) |
|
306 | jquery-countdown-rails |
|
310 | jquery-countdown-rails |
|
307 | jquery-datatables-rails |
|
311 | jquery-datatables-rails |
|
308 | jquery-rails |
|
312 | jquery-rails |
|
309 | jquery-tablesorter |
|
313 | jquery-tablesorter |
|
310 | jquery-timepicker-addon-rails |
|
314 | jquery-timepicker-addon-rails |
|
311 | jquery-ui-rails |
|
315 | jquery-ui-rails |
|
312 | listen (>= 3.0.5, < 3.2) |
|
316 | listen (>= 3.0.5, < 3.2) |
|
313 |
|
317 | ||
|
314 | minitest-reporters |
|
318 | minitest-reporters |
|
315 | momentjs-rails |
|
319 | momentjs-rails |
|
316 | mysql2 |
|
320 | mysql2 |
|
317 | puma |
|
321 | puma |
|
318 | rails (~> 5.2) |
|
322 | rails (~> 5.2) |
|
319 | rails-controller-testing |
|
323 | rails-controller-testing |
|
320 | rails_bootstrap_sortable |
|
324 | rails_bootstrap_sortable |
|
321 | rdiscount |
|
325 | rdiscount |
|
322 | rouge |
|
326 | rouge |
|
323 | sassc-rails |
|
327 | sassc-rails |
|
324 | select2-rails |
|
328 | select2-rails |
|
325 | selenium-webdriver |
|
329 | selenium-webdriver |
|
326 | simple_form |
|
330 | simple_form |
|
327 | spring |
|
331 | spring |
|
328 | spring-watcher-listen (~> 2.0.0) |
|
332 | spring-watcher-listen (~> 2.0.0) |
|
329 | sqlite3 |
|
333 | sqlite3 |
|
330 | uglifier |
|
334 | uglifier |
|
331 | web-console (>= 3.3.0) |
|
335 | web-console (>= 3.3.0) |
|
332 | webdriver |
|
336 | webdriver |
|
333 | will_paginate (~> 3.0.7) |
|
337 | will_paginate (~> 3.0.7) |
|
334 | yaml_db |
|
338 | yaml_db |
|
335 |
|
339 | ||
|
336 | BUNDLED WITH |
|
340 | BUNDLED WITH |
|
337 | 1.17.2 |
|
341 | 1.17.2 |
@@ -1,310 +1,87 | |||||
|
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 |
|
||
|
50 | - .col-md-12 |
|
||
|
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} |
|
||
|
53 |
|
49 | ||
|
54 | - if @submission |
|
50 | - if @submission |
|
55 | .modal.fade#compiler{tabindex: -1,role: 'dialog'} |
|
51 | .modal.fade#compiler{tabindex: -1,role: 'dialog'} |
|
56 | .modal-dialog.modal-lg{role:'document'} |
|
52 | .modal-dialog.modal-lg{role:'document'} |
|
57 | .modal-content |
|
53 | .modal-content |
|
58 | .modal-header |
|
54 | .modal-header |
|
59 | %button.close{type: 'button', data: {dismissed: :modal}, aria: {label: 'close'}} |
|
55 | %button.close{type: 'button', data: {dismissed: :modal}, aria: {label: 'close'}} |
|
60 | %span{aria: {hidden: 'true'}, data: {dismiss: 'modal'}} × |
|
56 | %span{aria: {hidden: 'true'}, data: {dismiss: 'modal'}} × |
|
61 | %h4 Compiler message |
|
57 | %h4 Compiler message |
|
62 | .modal-body |
|
58 | .modal-body |
|
63 | %pre#compiler_msg= @submission.compiler_message |
|
59 | %pre#compiler_msg= @submission.compiler_message |
|
64 | .modal-footer |
|
60 | .modal-footer |
|
65 | %button.btn.btn-default{type: 'button', data: {dismiss: 'modal'}} Close |
|
61 | %button.btn.btn-default{type: 'button', data: {dismiss: 'modal'}} Close |
|
66 |
|
62 | ||
|
67 | :javascript |
|
63 | :javascript |
|
68 | $(document).ready(function() { |
|
64 | $(document).ready(function() { |
|
69 | e = ace.edit("editor") |
|
65 | e = ace.edit("editor") |
|
70 | e.setValue($("#text_sourcecode").val()); |
|
66 | e.setValue($("#text_sourcecode").val()); |
|
71 | e.gotoLine(1); |
|
67 | e.gotoLine(1); |
|
72 | $("#language_id").trigger('change'); |
|
68 | $("#language_id").trigger('change'); |
|
73 |
|
69 | ||
|
74 | $("#load_file").on('change',function(evt) { |
|
70 | $("#load_file").on('change',function(evt) { |
|
75 | var file = evt.target.files[0]; |
|
71 | var file = evt.target.files[0]; |
|
76 | var reader = new FileReader(); |
|
72 | var reader = new FileReader(); |
|
77 | reader.onload = function(theFile) { |
|
73 | reader.onload = function(theFile) { |
|
78 | var e = ace.edit("editor") |
|
74 | var e = ace.edit("editor") |
|
79 | e.setValue(theFile.target.result); |
|
75 | e.setValue(theFile.target.result); |
|
80 | e.gotoLine(1); |
|
76 | e.gotoLine(1); |
|
81 | }; |
|
77 | }; |
|
82 | reader.readAsText(file) |
|
78 | reader.readAsText(file) |
|
83 | }); |
|
79 | }); |
|
84 |
|
80 | ||
|
85 | //brython(); |
|
81 | //brython(); |
|
86 | }); |
|
82 | }); |
|
87 |
|
83 | ||
|
88 |
|
84 | ||
|
89 |
|
85 | ||
|
90 |
|
86 | ||
|
91 |
|
87 | ||
|
92 | - %script#__main__{type:'text/python3'} |
|
||
|
93 | - :plain |
|
||
|
94 | - import sys |
|
||
|
95 | - import traceback |
|
||
|
96 | - |
|
||
|
97 | - from browser import document as doc |
|
||
|
98 | - from browser import window, alert, console |
|
||
|
99 | - |
|
||
|
100 | - _credits = """ Thanks to CWI, CNRI, BeOpen.com, Zope Corporation and a cast of thousands |
|
||
|
101 | - for supporting Python development. See www.python.org for more information.""" |
|
||
|
102 | - |
|
||
|
103 | - _copyright = """Copyright (c) 2012, Pierre Quentel pierre.quentel@gmail.com |
|
||
|
104 | - All Rights Reserved. |
|
||
|
105 | - |
|
||
|
106 | - Copyright (c) 2001-2013 Python Software Foundation. |
|
||
|
107 | - All Rights Reserved. |
|
||
|
108 | - |
|
||
|
109 | - Copyright (c) 2000 BeOpen.com. |
|
||
|
110 | - All Rights Reserved. |
|
||
|
111 | - |
|
||
|
112 | - Copyright (c) 1995-2001 Corporation for National Research Initiatives. |
|
||
|
113 | - All Rights Reserved. |
|
||
|
114 | - |
|
||
|
115 | - Copyright (c) 1991-1995 Stichting Mathematisch Centrum, Amsterdam. |
|
||
|
116 | - All Rights Reserved.""" |
|
||
|
117 | - |
|
||
|
118 | - _license = """Copyright (c) 2012, Pierre Quentel pierre.quentel@gmail.com |
|
||
|
119 | - All rights reserved. |
|
||
|
120 | - |
|
||
|
121 | - Redistribution and use in source and binary forms, with or without |
|
||
|
122 | - modification, are permitted provided that the following conditions are met: |
|
||
|
123 | - |
|
||
|
124 | - Redistributions of source code must retain the above copyright notice, this |
|
||
|
125 | - list of conditions and the following disclaimer. Redistributions in binary |
|
||
|
126 | - form must reproduce the above copyright notice, this list of conditions and |
|
||
|
127 | - the following disclaimer in the documentation and/or other materials provided |
|
||
|
128 | - with the distribution. |
|
||
|
129 | - Neither the name of the <ORGANIZATION> nor the names of its contributors may |
|
||
|
130 | - be used to endorse or promote products derived from this software without |
|
||
|
131 | - specific prior written permission. |
|
||
|
132 | - |
|
||
|
133 | - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
|
||
|
134 | - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
|
||
|
135 | - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
|
||
|
136 | - ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
|
||
|
137 | - LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
|
||
|
138 | - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
|
||
|
139 | - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
|
||
|
140 | - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
|
||
|
141 | - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
|
||
|
142 | - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
|
||
|
143 | - POSSIBILITY OF SUCH DAMAGE. |
|
||
|
144 | - """ |
|
||
|
145 | - |
|
||
|
146 | - def credits(): |
|
||
|
147 | - print(_credits) |
|
||
|
148 | - credits.__repr__ = lambda:_credits |
|
||
|
149 | - |
|
||
|
150 | - def copyright(): |
|
||
|
151 | - print(_copyright) |
|
||
|
152 | - copyright.__repr__ = lambda:_copyright |
|
||
|
153 | - |
|
||
|
154 | - def license(): |
|
||
|
155 | - print(_license) |
|
||
|
156 | - license.__repr__ = lambda:_license |
|
||
|
157 | - |
|
||
|
158 | - def write(data): |
|
||
|
159 | - doc['console'].value += str(data) |
|
||
|
160 | - |
|
||
|
161 | - |
|
||
|
162 | - sys.stdout.write = sys.stderr.write = write |
|
||
|
163 | - history = [] |
|
||
|
164 | - current = 0 |
|
||
|
165 | - _status = "main" # or "block" if typing inside a block |
|
||
|
166 | - |
|
||
|
167 | - # execution namespace |
|
||
|
168 | - editor_ns = {'credits':credits, |
|
||
|
169 | - 'copyright':copyright, |
|
||
|
170 | - 'license':license, |
|
||
|
171 | - '__name__':'__main__'} |
|
||
|
172 | - |
|
||
|
173 | - def cursorToEnd(*args): |
|
||
|
174 | - pos = len(doc['console'].value) |
|
||
|
175 | - doc['console'].setSelectionRange(pos, pos) |
|
||
|
176 | - doc['console'].scrollTop = doc['console'].scrollHeight |
|
||
|
177 | - |
|
||
|
178 | - def get_col(area): |
|
||
|
179 | - # returns the column num of cursor |
|
||
|
180 | - sel = doc['console'].selectionStart |
|
||
|
181 | - lines = doc['console'].value.split('\n') |
|
||
|
182 | - for line in lines[:-1]: |
|
||
|
183 | - sel -= len(line) + 1 |
|
||
|
184 | - return sel |
|
||
|
185 | - |
|
||
|
186 | - |
|
||
|
187 | - def myKeyPress(event): |
|
||
|
188 | - global _status, current |
|
||
|
189 | - if event.keyCode == 9: # tab key |
|
||
|
190 | - event.preventDefault() |
|
||
|
191 | - doc['console'].value += " " |
|
||
|
192 | - elif event.keyCode == 13: # return |
|
||
|
193 | - src = doc['console'].value |
|
||
|
194 | - if _status == "main": |
|
||
|
195 | - currentLine = src[src.rfind('>>>') + 4:] |
|
||
|
196 | - elif _status == "3string": |
|
||
|
197 | - currentLine = src[src.rfind('>>>') + 4:] |
|
||
|
198 | - currentLine = currentLine.replace('\n... ', '\n') |
|
||
|
199 | - else: |
|
||
|
200 | - currentLine = src[src.rfind('...') + 4:] |
|
||
|
201 | - if _status == 'main' and not currentLine.strip(): |
|
||
|
202 | - doc['console'].value += '\n>>> ' |
|
||
|
203 | - event.preventDefault() |
|
||
|
204 | - return |
|
||
|
205 | - doc['console'].value += '\n' |
|
||
|
206 | - history.append(currentLine) |
|
||
|
207 | - current = len(history) |
|
||
|
208 | - if _status == "main" or _status == "3string": |
|
||
|
209 | - try: |
|
||
|
210 | - _ = editor_ns['_'] = eval(currentLine, editor_ns) |
|
||
|
211 | - if _ is not None: |
|
||
|
212 | - write(repr(_)+'\n') |
|
||
|
213 | - doc['console'].value += '>>> ' |
|
||
|
214 | - _status = "main" |
|
||
|
215 | - except IndentationError: |
|
||
|
216 | - doc['console'].value += '... ' |
|
||
|
217 | - _status = "block" |
|
||
|
218 | - except SyntaxError as msg: |
|
||
|
219 | - if str(msg) == 'invalid syntax : triple string end not found' or \ |
|
||
|
220 | - str(msg).startswith('Unbalanced bracket'): |
|
||
|
221 | - doc['console'].value += '... ' |
|
||
|
222 | - _status = "3string" |
|
||
|
223 | - elif str(msg) == 'eval() argument must be an expression': |
|
||
|
224 | - try: |
|
||
|
225 | - exec(currentLine, editor_ns) |
|
||
|
226 | - except: |
|
||
|
227 | - traceback.print_exc() |
|
||
|
228 | - doc['console'].value += '>>> ' |
|
||
|
229 | - _status = "main" |
|
||
|
230 | - elif str(msg) == 'decorator expects function': |
|
||
|
231 | - doc['console'].value += '... ' |
|
||
|
232 | - _status = "block" |
|
||
|
233 | - else: |
|
||
|
234 | - traceback.print_exc() |
|
||
|
235 | - doc['console'].value += '>>> ' |
|
||
|
236 | - _status = "main" |
|
||
|
237 | - except: |
|
||
|
238 | - traceback.print_exc() |
|
||
|
239 | - doc['console'].value += '>>> ' |
|
||
|
240 | - _status = "main" |
|
||
|
241 | - elif currentLine == "": # end of block |
|
||
|
242 | - block = src[src.rfind('>>>') + 4:].splitlines() |
|
||
|
243 | - block = [block[0]] + [b[4:] for b in block[1:]] |
|
||
|
244 | - block_src = '\n'.join(block) |
|
||
|
245 | - # status must be set before executing code in globals() |
|
||
|
246 | - _status = "main" |
|
||
|
247 | - try: |
|
||
|
248 | - _ = exec(block_src, editor_ns) |
|
||
|
249 | - if _ is not None: |
|
||
|
250 | - print(repr(_)) |
|
||
|
251 | - except: |
|
||
|
252 | - traceback.print_exc() |
|
||
|
253 | - doc['console'].value += '>>> ' |
|
||
|
254 | - else: |
|
||
|
255 | - doc['console'].value += '... ' |
|
||
|
256 | - |
|
||
|
257 | - cursorToEnd() |
|
||
|
258 | - event.preventDefault() |
|
||
|
259 | - |
|
||
|
260 | - def myKeyDown(event): |
|
||
|
261 | - global _status, current |
|
||
|
262 | - if event.keyCode == 37: # left arrow |
|
||
|
263 | - sel = get_col(doc['console']) |
|
||
|
264 | - if sel < 5: |
|
||
|
265 | - event.preventDefault() |
|
||
|
266 | - event.stopPropagation() |
|
||
|
267 | - elif event.keyCode == 36: # line start |
|
||
|
268 | - pos = doc['console'].selectionStart |
|
||
|
269 | - col = get_col(doc['console']) |
|
||
|
270 | - doc['console'].setSelectionRange(pos - col + 4, pos - col + 4) |
|
||
|
271 | - event.preventDefault() |
|
||
|
272 | - elif event.keyCode == 38: # up |
|
||
|
273 | - if current > 0: |
|
||
|
274 | - pos = doc['console'].selectionStart |
|
||
|
275 | - col = get_col(doc['console']) |
|
||
|
276 | - # remove current line |
|
||
|
277 | - doc['console'].value = doc['console'].value[:pos - col + 4] |
|
||
|
278 | - current -= 1 |
|
||
|
279 | - doc['console'].value += history[current] |
|
||
|
280 | - event.preventDefault() |
|
||
|
281 | - elif event.keyCode == 40: # down |
|
||
|
282 | - if current < len(history) - 1: |
|
||
|
283 | - pos = doc['console'].selectionStart |
|
||
|
284 | - col = get_col(doc['console']) |
|
||
|
285 | - # remove current line |
|
||
|
286 | - doc['console'].value = doc['console'].value[:pos - col + 4] |
|
||
|
287 | - current += 1 |
|
||
|
288 | - doc['console'].value += history[current] |
|
||
|
289 | - event.preventDefault() |
|
||
|
290 | - elif event.keyCode == 8: # backspace |
|
||
|
291 | - src = doc['console'].value |
|
||
|
292 | - lstart = src.rfind('\n') |
|
||
|
293 | - if (lstart == -1 and len(src) < 5) or (len(src) - lstart < 6): |
|
||
|
294 | - event.preventDefault() |
|
||
|
295 | - event.stopPropagation() |
|
||
|
296 | - |
|
||
|
297 | - |
|
||
|
298 | - doc['console'].bind('keypress', myKeyPress) |
|
||
|
299 | - doc['console'].bind('keydown', myKeyDown) |
|
||
|
300 | - doc['console'].bind('click', cursorToEnd) |
|
||
|
301 | - v = sys.implementation.version |
|
||
|
302 | - doc['console'].value = "Brython %s.%s.%s on %s %s\n>>> " % ( |
|
||
|
303 | - v[0], v[1], v[2], window.navigator.appName, window.navigator.appVersion) |
|
||
|
304 | - #doc['console'].value += 'Type "copyright", "credits" or "license" for more information.' |
|
||
|
305 | - doc['console'].focus() |
|
||
|
306 | - cursorToEnd() |
|
||
|
307 | - |
|
||
|
308 | - |
|
||
|
309 | - |
|
||
|
310 | - |
|
@@ -1,36 +1,36 | |||||
|
1 |
- Language_ |
|
1 | + Language_c: |
|
2 | name: c |
|
2 | name: c |
|
3 | pretty_name: C |
|
3 | pretty_name: C |
|
4 | ext: c |
|
4 | ext: c |
|
5 | common_ext: c |
|
5 | common_ext: c |
|
6 |
|
6 | ||
|
7 |
- Language_ |
|
7 | + Language_cpp: |
|
8 | name: cpp |
|
8 | name: cpp |
|
9 | pretty_name: C++ |
|
9 | pretty_name: C++ |
|
10 | ext: cpp |
|
10 | ext: cpp |
|
11 | common_ext: cpp,cc |
|
11 | common_ext: cpp,cc |
|
12 |
|
12 | ||
|
13 |
- Language_ |
|
13 | + Language_pas: |
|
14 | name: pas |
|
14 | name: pas |
|
15 | pretty_name: Pascal |
|
15 | pretty_name: Pascal |
|
16 | ext: pas |
|
16 | ext: pas |
|
17 | common_ext: pas |
|
17 | common_ext: pas |
|
18 |
|
18 | ||
|
19 |
- Language_ |
|
19 | + Language_ruby: |
|
20 | name: ruby |
|
20 | name: ruby |
|
21 | pretty_name: Ruby |
|
21 | pretty_name: Ruby |
|
22 | ext: rb |
|
22 | ext: rb |
|
23 | common_ext: rb |
|
23 | common_ext: rb |
|
24 |
|
24 | ||
|
25 |
- Language_ |
|
25 | + Language_python: |
|
26 | name: python |
|
26 | name: python |
|
27 | pretty_name: Python |
|
27 | pretty_name: Python |
|
28 | ext: py |
|
28 | ext: py |
|
29 | common_ext: py |
|
29 | common_ext: py |
|
30 |
|
30 | ||
|
31 |
- Language_ |
|
31 | + Language_java: |
|
32 | name: java |
|
32 | name: java |
|
33 | pretty_name: Java |
|
33 | pretty_name: Java |
|
34 | ext: java |
|
34 | ext: java |
|
35 | common_ext: java |
|
35 | common_ext: java |
|
36 |
|
36 |
@@ -1,24 +1,24 | |||||
|
1 | # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html |
|
1 | # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html |
|
2 | - one: |
|
2 | + prob_add: |
|
3 | id: 1 |
|
3 | id: 1 |
|
4 | name: add |
|
4 | name: add |
|
5 | full_name: add_full_name |
|
5 | full_name: add_full_name |
|
6 | available: true |
|
6 | available: true |
|
7 |
|
7 | ||
|
8 | - two: |
|
8 | + prob_sub: |
|
9 | id: 2 |
|
9 | id: 2 |
|
10 | name: subtract |
|
10 | name: subtract |
|
11 | full_name: subtract_full_name |
|
11 | full_name: subtract_full_name |
|
12 | available: false |
|
12 | available: false |
|
13 |
|
13 | ||
|
14 | easy: |
|
14 | easy: |
|
15 | name: easy_problem |
|
15 | name: easy_problem |
|
16 | full_name: Easy Problem |
|
16 | full_name: Easy Problem |
|
17 | available: true |
|
17 | available: true |
|
18 | contests: contest_a, contest_b |
|
18 | contests: contest_a, contest_b |
|
19 |
|
19 | ||
|
20 | hard: |
|
20 | hard: |
|
21 | name: hard_problem |
|
21 | name: hard_problem |
|
22 | full_name: Hard Problem |
|
22 | full_name: Hard Problem |
|
23 | available: true |
|
23 | available: true |
|
24 | contests: contest_b |
|
24 | contests: contest_b |
@@ -1,5 +1,48 | |||||
|
1 | # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html |
|
1 | # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html |
|
2 | - one: |
|
2 | + add1_by_admin: |
|
3 | id: 1 |
|
3 | id: 1 |
|
4 | - two: |
|
4 | + user: admin |
|
|
5 | + problem: prob_add | ||
|
|
6 | + language: Language_c | ||
|
|
7 | + source: | ||
|
|
8 | + \#include <stdio> | ||
|
|
9 | + \#include <stdlib> | ||
|
|
10 | + int main() { | ||
|
|
11 | + cout << 1 << endl; | ||
|
|
12 | + } | ||
|
|
13 | + | ||
|
|
14 | + sub1_by_admin: | ||
|
5 | id: 2 |
|
15 | id: 2 |
|
|
16 | + user: admin | ||
|
|
17 | + problem: prob_sub | ||
|
|
18 | + language: Language_c | ||
|
|
19 | + source: | ||
|
|
20 | + \#include <stdio> | ||
|
|
21 | + \#include <stdlib> | ||
|
|
22 | + int main() { | ||
|
|
23 | + cout << 2 << endl; | ||
|
|
24 | + } | ||
|
|
25 | + | ||
|
|
26 | + add1_by_john: | ||
|
|
27 | + id: 3 | ||
|
|
28 | + user: john | ||
|
|
29 | + problem: prob_add | ||
|
|
30 | + language: Language_c | ||
|
|
31 | + source: | ||
|
|
32 | + \#include <stdio> | ||
|
|
33 | + \#include <stdlib> | ||
|
|
34 | + int main() { | ||
|
|
35 | + cout << 33 << endl; | ||
|
|
36 | + } | ||
|
|
37 | + | ||
|
|
38 | + sub1_by_james: | ||
|
|
39 | + id: 4 | ||
|
|
40 | + user: james | ||
|
|
41 | + problem: prob_sub | ||
|
|
42 | + language: Language_c | ||
|
|
43 | + source: | ||
|
|
44 | + \#include <stdio> | ||
|
|
45 | + \#include <stdlib> | ||
|
|
46 | + int main() { | ||
|
|
47 | + cout << 44 << endl; | ||
|
|
48 | + } |
You need to be logged in to leave comments.
Login now