Description:
- bootstrapize submission list - add live edit from submission
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r565:d9febe97b3f0 - - 12 files changed: 93 inserted, 63 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 }
@@ -16,12 +16,18
16 //= require bootstrap-sprockets
16 //= require bootstrap-sprockets
17 //x= require bootstrap-switch
17 //x= require bootstrap-switch
18 //= require bootstrap-toggle
18 //= require bootstrap-toggle
19 //= require select2
19 //= require select2
20 //= require custom
20 //= require custom
21 //= require ace-rails-ap
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 // since this is after blank line, it is not downloaded
30 // since this is after blank line, it is not downloaded
25 //x= require prototype
31 //x= require prototype
26 //x= require prototype_ujs
32 //x= require prototype_ujs
27 //x= require effects
33 //x= require effects
@@ -36,10 +36,10
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 editor = ace.edit("editor")
42 - editor.setTheme("ace/theme/monokai")
42 + editor.setTheme("ace/theme/merbivore")
43 editor.getSession().setMode("ace/mode/javascript")
43 editor.getSession().setMode("ace/mode/javascript")
44
44
45 return
45 return
@@ -5,6 +5,28
5
5
6 $ ->
6 $ ->
7 $("#live_submit").on "click", (event) ->
7 $("#live_submit").on "click", (event) ->
8 h = $("#editor_text")
8 h = $("#editor_text")
9 e = ace.edit("editor")
9 e = ace.edit("editor")
10 h.val(e.getValue())
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 class SourcesController < ApplicationController
1 class SourcesController < ApplicationController
2 - before_filter :authenticate, :except => [:index, :login]
2 + before_filter :authenticate
3
3
4 def direct_edit
4 def direct_edit
5 - @problem = Problem.find_by_id(params[:pid])
5 + @problem = Problem.find(params[:pid])
6 + @source = ''
6 end
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'
15 + end
16 +
7 end
17 end
@@ -1,24 +1,26
1
1
2 - %tr{:class => ((submission_counter%2==0) ? "info-even" : "info-odd")}
2 + %tr
3 - %td.info{:align => "center"}
3 + %td{:align => "center"}
4 = submission_counter+1
4 = submission_counter+1
5 - %td.info{:align => "center"}
5 + %td{:align => "center"}
6 = link_to "##{submission.id}", controller: :graders, action: :submission, id: submission.id
6 = link_to "##{submission.id}", controller: :graders, action: :submission, id: submission.id
7 - %td.info
7 + %td
8 = l submission.submitted_at, format: :long
8 = l submission.submitted_at, format: :long
9 = "( #{time_ago_in_words(submission.submitted_at)} ago)"
9 = "( #{time_ago_in_words(submission.submitted_at)} ago)"
10 - %td.info{:align => "center"}
10 + %td
11 = submission.source_filename
11 = submission.source_filename
12 = " (#{submission.language.pretty_name}) "
12 = " (#{submission.language.pretty_name}) "
13 = link_to('[load]',{:action => 'source', :id => submission.id})
13 = link_to('[load]',{:action => 'source', :id => submission.id})
14 - %td.info
14 + %td
15 - if submission.graded_at!=nil
15 - if submission.graded_at!=nil
16 = "Graded at #{format_short_time(submission.graded_at)}."
16 = "Graded at #{format_short_time(submission.graded_at)}."
17 %br/
17 %br/
18 = "Score: #{(submission.points*100/submission.problem.full_score).to_i} " if GraderConfiguration['ui.show_score']
18 = "Score: #{(submission.points*100/submission.problem.full_score).to_i} " if GraderConfiguration['ui.show_score']
19 = " ["
19 = " ["
20 %tt
20 %tt
21 = submission.grader_comment
21 = submission.grader_comment
22 = "]"
22 = "]"
23 - %td.info
23 + %td
24 = render :partial => 'compiler_message', :locals => {:compiler_message => submission.compiler_message }
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'
@@ -20,7 +20,7
20 = link_to '[detailed result]', :action => 'result', :id => submission.id
20 = link_to '[detailed result]', :action => 'result', :id => submission.id
21 = " | "
21 = " | "
22 = link_to("[#{t 'main.cmp_msg'}]", {:action => 'compiler_msg', :id => submission.id}, {:popup => true})
22 = link_to("[#{t 'main.cmp_msg'}]", {:action => 'compiler_msg', :id => submission.id}, {:popup => true})
23 = " | "
23 = " | "
24 = link_to("[#{t 'main.src_link'}]",{:action => 'source', :id => submission.id})
24 = link_to("[#{t 'main.src_link'}]",{:action => 'source', :id => submission.id})
25 = " | "
25 = " | "
26 - = link_to "[#{t 'main.submissions_link'}]", :action => 'submission', :id => submission.problem.id
26 + = link_to "[#{t 'main.submissions_link'}]", main_submission_path(submission.problem.id)
@@ -21,34 +21,31
21
21
22 - if GraderConfiguration.show_tasks_to?(@user)
22 - if GraderConfiguration.show_tasks_to?(@user)
23 - if not GraderConfiguration.multicontests?
23 - if not GraderConfiguration.multicontests?
24 %table.table.table-striped.table-condensed
24 %table.table.table-striped.table-condensed
25 %thead
25 %thead
26 %tr.info-head
26 %tr.info-head
27 - %th #
27 + %th Task name
28 - %th Tasks name
29 %th Full name
28 %th Full name
30 %th # of sub(s)
29 %th # of sub(s)
31 %th Results
30 %th Results
32 %tbody
31 %tbody
33 = render :partial => 'problem', :collection => @problems
32 = render :partial => 'problem', :collection => @problems
34 - else
33 - else
35 - @contest_problems.each do |cp|
34 - @contest_problems.each do |cp|
36 - if cp[:problems].length > 0
35 - if cp[:problems].length > 0
37 %h2{:class =>'contest-title'}
36 %h2{:class =>'contest-title'}
38 = "#{cp[:contest] ? cp[:contest].title : 'Public problems'}"
37 = "#{cp[:contest] ? cp[:contest].title : 'Public problems'}"
39 %table.info
38 %table.info
40 %tr.info-head
39 %tr.info-head
41 - %th
40 + %th Task name
42 - %th Tasks name
43 %th Full name
41 %th Full name
44 %th # of sub(s)
42 %th # of sub(s)
45 %th Results
43 %th Results
46 = render :partial => 'problem', :collection => cp[:problems]
44 = render :partial => 'problem', :collection => cp[:problems]
47
45
48 -
49 %hr/
46 %hr/
50
47
51 %script{:type => 'text/javascript'}
48 %script{:type => 'text/javascript'}
52 = "Announcement.refreshUrl = '#{url_for :controller => 'main', :action => 'announcements'}';"
49 = "Announcement.refreshUrl = '#{url_for :controller => 'main', :action => 'announcements'}';"
53 Announcement.registerRefreshEventTimer();
50 Announcement.registerRefreshEventTimer();
54
51
@@ -14,18 +14,18
14
14
15 - if @problem!=nil
15 - if @problem!=nil
16 %h2= "Task: #{@problem.full_name} (#{@problem.name})"
16 %h2= "Task: #{@problem.full_name} (#{@problem.name})"
17
17
18 - if @submissions!=nil
18 - if @submissions!=nil
19 - if @submissions.length>0
19 - if @submissions.length>0
20 - %table.info
20 + %table.table
21 - %tr.info-head
21 + %thead
22 - %th.info No.
22 + %th No.
23 - %th.info #
23 + %th #
24 - %th.info At
24 + %th At
25 - %th.info Source
25 + %th Source
26 - %th.info Result
26 + %th Result
27 - %th.info{:width => "300px"}
27 + %th{:width => "300px"} Compiler message
28 - Compiler message
28 + %th
29 = render :partial => 'submission', :collection => @submissions
29 = render :partial => 'submission', :collection => @submissions
30 - else
30 - else
31 No submission
31 No submission
@@ -1,21 +1,23
1 - %h1 Live submit
1 + %h2 Live submit
2 - = form_tag({controller: :main, :action => 'submit'}, :multipart => true, class: 'form-inline') do
3 - = hidden_field_tag 'editor_text'
4 - = hidden_field_tag 'submission[problem_id]', @problem.id
5 - .form-group
6 - = label_tag "Task:"
7 - = text_field_tag 'asdf', "#{@problem.long_name}", class: 'form-control', disabled: true
8 -
9 - .form-group
10 - = label_tag 'Language'
11 - = select_tag 'language_id', options_from_collection_for_select(Language.all, 'id', 'pretty_name',"C++"), class: 'form-control', style: "width: 100px"
12 - .form-group
13 - = submit_tag 'Submit', class: 'btn btn-success', id: 'live_submit'
14 -
15 %br
2 %br
16
3
4 + %textarea#text_haha{style: "display:none"}~ @source
17 .container
5 .container
18 .row
6 .row
19 - .col-md-12
7 + .col-md-7
20 - %div#editor{style: 'height: 400px'}
8 + %div#editor{style: 'height: 500px; border-radius: 7px; font-size: 14px;'}
21 - Hahaha
9 + .col-md-5
10 + = form_tag({controller: :main, :action => 'submit'}, :multipart => true, class: 'form') do
11 +
12 + = hidden_field_tag 'editor_text', @source
13 + = hidden_field_tag 'submission[problem_id]', @problem.id
14 + .form-group
15 + = label_tag "Task:"
16 + = text_field_tag 'asdf', "#{@problem.long_name}", class: 'form-control', disabled: true
17 +
18 + .form-group
19 + = label_tag 'Language'
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"
21 + .form-group
22 + = submit_tag 'Submit', class: 'btn btn-success', id: 'live_submit',
23 + data: {confirm: "Submitting this source code for task #{@problem.long_name}?"}
@@ -37,12 +37,13
37
37
38 #resources :sources do
38 #resources :sources do
39 # collection do
39 # collection do
40 # end
40 # end
41 #end
41 #end
42 get 'sources/direct_edit/:pid', to: 'sources#direct_edit', as: 'direct_edit'
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 match 'tasks/view/:file.:ext' => 'tasks#view'
46 match 'tasks/view/:file.:ext' => 'tasks#view'
46 match 'tasks/download/:id/:file.:ext' => 'tasks#download'
47 match 'tasks/download/:id/:file.:ext' => 'tasks#download'
47 match 'heartbeat/:id/edit' => 'heartbeat#edit'
48 match 'heartbeat/:id/edit' => 'heartbeat#edit'
48
49
deleted file
You need to be logged in to leave comments. Login now