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: 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 }
@@ -1,29 +1,35
1 // This is a manifest file that'll be compiled into application.js, which will include all the files
1 // This is a manifest file that'll be compiled into application.js, which will include all the files
2 // listed below.
2 // listed below.
3 //
3 //
4 // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
4 // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5 // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
5 // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
6 //
6 //
7 // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
7 // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8 // the compiled file.
8 // the compiled file.
9 //
9 //
10 // WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
10 // WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
11 // GO AFTER THE REQUIRES BELOW.
11 // GO AFTER THE REQUIRES BELOW.
12 //
12 //
13 //= require jquery
13 //= require jquery
14 //= require jquery_ujs
14 //= require jquery_ujs
15 //= require jquery.ui.all
15 //= require jquery.ui.all
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
28 //x= require dragdrop
34 //x= require dragdrop
29 //x= require controls
35 //x= require controls
@@ -18,28 +18,28
18 $('.btn-file :file').on 'fileselect', (event, numFiles, label) ->
18 $('.btn-file :file').on 'fileselect', (event, numFiles, label) ->
19 input = $(this).parents('.input-group').find(':text')
19 input = $(this).parents('.input-group').find(':text')
20 log = if numFiles > 1 then numFiles + ' files selected' else label
20 log = if numFiles > 1 then numFiles + ' files selected' else label
21 if input.length
21 if input.length
22 input.val log
22 input.val log
23 else
23 else
24 if log
24 if log
25 alert log
25 alert log
26 return
26 return
27 $(".go-button").on 'click', (event) ->
27 $(".go-button").on 'click', (event) ->
28 link = $(this).attr("data-source")
28 link = $(this).attr("data-source")
29 url = $(link).val()
29 url = $(link).val()
30 if url
30 if url
31 window.location.href = url
31 window.location.href = url
32 return
32 return
33 $('.ajax-toggle').on 'click', (event) ->
33 $('.ajax-toggle').on 'click', (event) ->
34 target = $(event.target)
34 target = $(event.target)
35 target.removeClass 'btn-default'
35 target.removeClass 'btn-default'
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
@@ -1,10 +1,32
1 # Place all the behaviors and hooks related to the matching controller here.
1 # Place all the behaviors and hooks related to the matching controller here.
2 # All this logic will automatically be available in application.js.
2 # All this logic will automatically be available in application.js.
3 # You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
3 # You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
4
4
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'
7 end
15 end
16 +
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'
@@ -2,25 +2,25
2 - if submission==nil
2 - if submission==nil
3 = "-"
3 = "-"
4 - else
4 - else
5 - if submission.graded_at==nil
5 - if submission.graded_at==nil
6 =t 'main.submitted_at'
6 =t 'main.submitted_at'
7 = format_short_time(submission.submitted_at.localtime)
7 = format_short_time(submission.submitted_at.localtime)
8 - else
8 - else
9 = t 'main.graded_at'
9 = t 'main.graded_at'
10 = "#{format_short_time(submission.graded_at.localtime)}, "
10 = "#{format_short_time(submission.graded_at.localtime)}, "
11 - if GraderConfiguration['ui.show_score']
11 - if GraderConfiguration['ui.show_score']
12 = t 'main.score'
12 = t 'main.score'
13 = "#{(submission.points*100/submission.problem.full_score).to_i} "
13 = "#{(submission.points*100/submission.problem.full_score).to_i} "
14 = " ["
14 = " ["
15 %tt
15 %tt
16 = submission.grader_comment
16 = submission.grader_comment
17 = "]"
17 = "]"
18 - if GraderConfiguration.show_grading_result
18 - if GraderConfiguration.show_grading_result
19 = " | "
19 = " | "
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)
@@ -3,52 +3,49
3
3
4 = user_title_bar(@user)
4 = user_title_bar(@user)
5
5
6 .announcementbox{:style => (@announcements.length==0 ? "display:none" : "")}
6 .announcementbox{:style => (@announcements.length==0 ? "display:none" : "")}
7 %span{:class => 'title'}
7 %span{:class => 'title'}
8 Announcements
8 Announcements
9 #announcementbox-body
9 #announcementbox-body
10 = render :partial => 'announcement', :collection => @announcements
10 = render :partial => 'announcement', :collection => @announcements
11
11
12 - if GraderConfiguration.show_submitbox_to?(@user)
12 - if GraderConfiguration.show_submitbox_to?(@user)
13 .submitbox
13 .submitbox
14 = render :partial => 'submission_box'
14 = render :partial => 'submission_box'
15
15
16
16
17 %hr/
17 %hr/
18
18
19 - if (GraderConfiguration.contest_mode?) and (@user.site!=nil) and (@user.site.started!=true)
19 - if (GraderConfiguration.contest_mode?) and (@user.site!=nil) and (@user.site.started!=true)
20 %p=t 'main.start_soon'
20 %p=t 'main.start_soon'
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
@@ -1,31 +1,31
1 = user_title_bar(@user)
1 = user_title_bar(@user)
2
2
3 .panel.panel-info
3 .panel.panel-info
4 .panel-heading
4 .panel-heading
5 Select Problems
5 Select Problems
6 .panel-body
6 .panel-body
7 .form-inline
7 .form-inline
8 = select 'submission',
8 = select 'submission',
9 'problem_id',
9 'problem_id',
10 @problems.collect {|p| ["[#{p.name}] #{p.full_name}", main_submission_url(p.id)]},
10 @problems.collect {|p| ["[#{p.name}] #{p.full_name}", main_submission_url(p.id)]},
11 { selected: (@problem ? main_submission_url(@problem) : -1) },
11 { selected: (@problem ? main_submission_url(@problem) : -1) },
12 { class: 'select2 form-control'}
12 { class: 'select2 form-control'}
13 %button.btn.btn-primary.btn-sm.go-button#problem_go{data: {source: '#submission_problem_id'}} Go
13 %button.btn.btn-primary.btn-sm.go-button#problem_go{data: {source: '#submission_problem_id'}} Go
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
2 + %br
3 - = hidden_field_tag 'editor_text'
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 = hidden_field_tag 'submission[problem_id]', @problem.id
13 = hidden_field_tag 'submission[problem_id]', @problem.id
5 .form-group
14 .form-group
6 = label_tag "Task:"
15 = label_tag "Task:"
7 = text_field_tag 'asdf', "#{@problem.long_name}", class: 'form-control', disabled: true
16 = text_field_tag 'asdf', "#{@problem.long_name}", class: 'form-control', disabled: true
8
17
9 .form-group
18 .form-group
10 = label_tag 'Language'
19 = 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"
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 .form-group
21 .form-group
13 - = submit_tag 'Submit', class: 'btn btn-success', id: 'live_submit'
22 + = submit_tag 'Submit', class: 'btn btn-success', id: 'live_submit',
14 -
23 + data: {confirm: "Submitting this source code for task #{@problem.long_name}?"}
15 - %br
16 -
17 - .container
18 - .row
19 - .col-md-12
20 - %div#editor{style: 'height: 400px'}
21 - Hahaha
@@ -19,44 +19,45
19 member do
19 member do
20 get 'toggle'
20 get 'toggle'
21 end
21 end
22 collection do
22 collection do
23 get 'turn_all_off'
23 get 'turn_all_off'
24 get 'turn_all_on'
24 get 'turn_all_on'
25 get 'import'
25 get 'import'
26 get 'manage'
26 get 'manage'
27 end
27 end
28 end
28 end
29
29
30 resources :grader_configuration, controller: 'configurations'
30 resources :grader_configuration, controller: 'configurations'
31
31
32 resources :users do
32 resources :users do
33 member do
33 member do
34 get 'toggle_activate', 'toggle_enable'
34 get 'toggle_activate', 'toggle_enable'
35 end
35 end
36 end
36 end
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
49 #main
50 #main
50 get "main/list"
51 get "main/list"
51 get 'main/submission(/:id)', to: 'main#submission', as: 'main_submission'
52 get 'main/submission(/:id)', to: 'main#submission', as: 'main_submission'
52
53
53 #report
54 #report
54 get 'report/problem_hof(/:id)', to: 'report#problem_hof', as: 'report_problem_hof'
55 get 'report/problem_hof(/:id)', to: 'report#problem_hof', as: 'report_problem_hof'
55 get "report/login"
56 get "report/login"
56
57
57 # See how all your routes lay out with "rake routes"
58 # See how all your routes lay out with "rake routes"
58
59
59 # This is a legacy wild controller route that's not recommended for RESTful applications.
60 # This is a legacy wild controller route that's not recommended for RESTful applications.
60 # Note: This route will make all actions in every controller accessible via GET requests.
61 # Note: This route will make all actions in every controller accessible via GET requests.
61 match ':controller(/:action(/:id))(.:format)'
62 match ':controller(/:action(/:id))(.:format)'
62 end
63 end
deleted file
You need to be logged in to leave comments. Login now