Description:
- bootstrapize submission list
- add live edit from submission
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r565:d9febe97b3f0 - - 12 files changed: 89 inserted, 59 deleted
@@ -0,0 +1,11 | |||
|
1 | + %tr | |
|
2 | + %td | |
|
3 | + = "#{problem.name}" | |
|
4 | + %td | |
|
5 | + = "#{problem.full_name}" | |
|
6 | + = link_to_description_if_any "[#{t 'main.problem_desc'}] <span class='glyphicon glyphicon-file'></span>".html_safe, problem | |
|
7 | + %td{:align => "center"} | |
|
8 | + = @prob_submissions[problem.id][:count] | |
|
9 | + %td | |
|
10 | + = render :partial => 'submission_short', | |
|
11 | + :locals => {:submission => @prob_submissions[problem.id][:submission], :problem_name => problem.name } |
@@ -19,6 +19,12 | |||
|
19 | 19 | //= require select2 |
|
20 | 20 | //= require custom |
|
21 | 21 | //= require ace-rails-ap |
|
22 | + //= require ace/mode-c_cpp | |
|
23 | + //= require ace/mode-ruby | |
|
24 | + //= require ace/mode-pascal | |
|
25 | + //= require ace/mode-javascript | |
|
26 | + //= require ace/mode-java | |
|
27 | + //= require ace/theme-merbivore | |
|
22 | 28 | |
|
23 | 29 | |
|
24 | 30 | // since this is after blank line, it is not downloaded |
@@ -39,7 +39,7 | |||
|
39 | 39 | return |
|
40 | 40 | |
|
41 | 41 | editor = ace.edit("editor") |
|
42 |
- editor.setTheme("ace/theme/m |
|
|
42 | + editor.setTheme("ace/theme/merbivore") | |
|
43 | 43 | editor.getSession().setMode("ace/mode/javascript") |
|
44 | 44 | |
|
45 | 45 | return |
@@ -8,3 +8,25 | |||
|
8 | 8 | h = $("#editor_text") |
|
9 | 9 | e = ace.edit("editor") |
|
10 | 10 | h.val(e.getValue()) |
|
11 | + | |
|
12 | + $("#language_id").on "change", (event) -> | |
|
13 | + text = $("#language_id option:selected").text() | |
|
14 | + mode = 'ace/mode/c_cpp' | |
|
15 | + switch text | |
|
16 | + when 'Pascal' then mode = 'ace/mode/pascal' | |
|
17 | + when 'C++','C' then mode = 'ace/mode/c_cpp' | |
|
18 | + when 'Ruby' then mode = 'ace/mode/ruby' | |
|
19 | + when 'Python' then mode = 'ace/mode/python' | |
|
20 | + when 'Java' then mode = 'ace/mode/java' | |
|
21 | + editor = ace.edit('editor') | |
|
22 | + editor.getSession().setMode(mode) | |
|
23 | + | |
|
24 | + e = ace.edit("editor") | |
|
25 | + e.setValue($("#text_haha").val()) | |
|
26 | + e.gotoLine(1) | |
|
27 | + $("#language_id").trigger('change') | |
|
28 | + | |
|
29 | + | |
|
30 | + | |
|
31 | + | |
|
32 | + return |
@@ -1,7 +1,17 | |||
|
1 | 1 | class SourcesController < ApplicationController |
|
2 |
- before_filter :authenticate |
|
|
2 | + before_filter :authenticate | |
|
3 | 3 | |
|
4 | 4 | def direct_edit |
|
5 |
- @problem = Problem.find |
|
|
5 | + @problem = Problem.find(params[:pid]) | |
|
6 | + @source = '' | |
|
6 | 7 | end |
|
8 | + | |
|
9 | + def direct_edit_submission | |
|
10 | + @submission = Submission.find(params[:sid]) | |
|
11 | + @source = @submission.source.to_s | |
|
12 | + @problem = @submission.problem | |
|
13 | + @lang_id = @submission.language.id | |
|
14 | + render 'direct_edit' | |
|
7 | 15 | end |
|
16 | + | |
|
17 | + end |
@@ -1,17 +1,17 | |||
|
1 | 1 | |
|
2 | - %tr{:class => ((submission_counter%2==0) ? "info-even" : "info-odd")} | |
|
3 |
- %td |
|
|
2 | + %tr | |
|
3 | + %td{:align => "center"} | |
|
4 | 4 | = submission_counter+1 |
|
5 |
- %td |
|
|
5 | + %td{:align => "center"} | |
|
6 | 6 | = link_to "##{submission.id}", controller: :graders, action: :submission, id: submission.id |
|
7 |
- %td |
|
|
7 | + %td | |
|
8 | 8 | = l submission.submitted_at, format: :long |
|
9 | 9 | = "( #{time_ago_in_words(submission.submitted_at)} ago)" |
|
10 | - %td.info{:align => "center"} | |
|
10 | + %td | |
|
11 | 11 | = submission.source_filename |
|
12 | 12 | = " (#{submission.language.pretty_name}) " |
|
13 | 13 | = link_to('[load]',{:action => 'source', :id => submission.id}) |
|
14 |
- %td |
|
|
14 | + %td | |
|
15 | 15 | - if submission.graded_at!=nil |
|
16 | 16 | = "Graded at #{format_short_time(submission.graded_at)}." |
|
17 | 17 | %br/ |
@@ -20,5 +20,7 | |||
|
20 | 20 | %tt |
|
21 | 21 | = submission.grader_comment |
|
22 | 22 | = "]" |
|
23 |
- %td |
|
|
23 | + %td | |
|
24 | 24 | = render :partial => 'compiler_message', :locals => {:compiler_message => submission.compiler_message } |
|
25 | + %td | |
|
26 | + = link_to 'Edit', direct_edit_submission_path(submission.id), class: 'btn btn-success' |
@@ -23,4 +23,4 | |||
|
23 | 23 | = " | " |
|
24 | 24 | = link_to("[#{t 'main.src_link'}]",{:action => 'source', :id => submission.id}) |
|
25 | 25 | = " | " |
|
26 |
- = link_to "[#{t 'main.submissions_link'}]", |
|
|
26 | + = link_to "[#{t 'main.submissions_link'}]", main_submission_path(submission.problem.id) |
@@ -24,8 +24,7 | |||
|
24 | 24 | %table.table.table-striped.table-condensed |
|
25 | 25 | %thead |
|
26 | 26 | %tr.info-head |
|
27 |
- %th |
|
|
28 | - %th Tasks name | |
|
27 | + %th Task name | |
|
29 | 28 | %th Full name |
|
30 | 29 | %th # of sub(s) |
|
31 | 30 | %th Results |
@@ -38,14 +37,12 | |||
|
38 | 37 | = "#{cp[:contest] ? cp[:contest].title : 'Public problems'}" |
|
39 | 38 | %table.info |
|
40 | 39 | %tr.info-head |
|
41 | - %th | |
|
42 | - %th Tasks name | |
|
40 | + %th Task name | |
|
43 | 41 | %th Full name |
|
44 | 42 | %th # of sub(s) |
|
45 | 43 | %th Results |
|
46 | 44 | = render :partial => 'problem', :collection => cp[:problems] |
|
47 | 45 | |
|
48 | - | |
|
49 | 46 | %hr/ |
|
50 | 47 | |
|
51 | 48 | %script{:type => 'text/javascript'} |
@@ -17,15 +17,15 | |||
|
17 | 17 | |
|
18 | 18 | - if @submissions!=nil |
|
19 | 19 | - if @submissions.length>0 |
|
20 |
- %table. |
|
|
21 |
- %t |
|
|
22 |
- %th |
|
|
23 |
- %th |
|
|
24 |
- %th |
|
|
25 |
- %th |
|
|
26 |
- %th |
|
|
27 |
- %th |
|
|
28 | - Compiler message | |
|
20 | + %table.table | |
|
21 | + %thead | |
|
22 | + %th No. | |
|
23 | + %th # | |
|
24 | + %th At | |
|
25 | + %th Source | |
|
26 | + %th Result | |
|
27 | + %th{:width => "300px"} Compiler message | |
|
28 | + %th | |
|
29 | 29 | = render :partial => 'submission', :collection => @submissions |
|
30 | 30 | - else |
|
31 | 31 | No submission |
@@ -1,6 +1,15 | |||
|
1 |
- %h |
|
|
2 | - = form_tag({controller: :main, :action => 'submit'}, :multipart => true, class: 'form-inline') do | |
|
3 | - = hidden_field_tag 'editor_text' | |
|
1 | + %h2 Live submit | |
|
2 | + %br | |
|
3 | + | |
|
4 | + %textarea#text_haha{style: "display:none"}~ @source | |
|
5 | + .container | |
|
6 | + .row | |
|
7 | + .col-md-7 | |
|
8 | + %div#editor{style: 'height: 500px; border-radius: 7px; font-size: 14px;'} | |
|
9 | + .col-md-5 | |
|
10 | + = form_tag({controller: :main, :action => 'submit'}, :multipart => true, class: 'form') do | |
|
11 | + | |
|
12 | + = hidden_field_tag 'editor_text', @source | |
|
4 | 13 | = hidden_field_tag 'submission[problem_id]', @problem.id |
|
5 | 14 | .form-group |
|
6 | 15 | = label_tag "Task:" |
@@ -8,14 +17,7 | |||
|
8 | 17 | |
|
9 | 18 | .form-group |
|
10 | 19 | = label_tag 'Language' |
|
11 |
- = select_tag 'language_id', options_from_collection_for_select(Language.all, 'id', 'pretty_name', |
|
|
20 | + = select_tag 'language_id', options_from_collection_for_select(Language.all, 'id', 'pretty_name', @lang_id || Language.first.id), class: 'form-control select', style: "width: 100px" | |
|
12 | 21 | .form-group |
|
13 | - = submit_tag 'Submit', class: 'btn btn-success', id: 'live_submit' | |
|
14 | - | |
|
15 | - %br | |
|
16 | - | |
|
17 | - .container | |
|
18 | - .row | |
|
19 | - .col-md-12 | |
|
20 | - %div#editor{style: 'height: 400px'} | |
|
21 | - Hahaha | |
|
22 | + = submit_tag 'Submit', class: 'btn btn-success', id: 'live_submit', | |
|
23 | + data: {confirm: "Submitting this source code for task #{@problem.long_name}?"} |
@@ -40,6 +40,7 | |||
|
40 | 40 | # end |
|
41 | 41 | #end |
|
42 | 42 | get 'sources/direct_edit/:pid', to: 'sources#direct_edit', as: 'direct_edit' |
|
43 | + get 'sources/direct_edit_submission/:sid', to: 'sources#direct_edit_submission', as: 'direct_edit_submission' | |
|
43 | 44 | |
|
44 | 45 | |
|
45 | 46 | match 'tasks/view/:file.:ext' => 'tasks#view' |
deleted file |
You need to be logged in to leave comments.
Login now