Description:
* add forgotten toggle file * main/submission changed to bootstrap
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r559:2e5e11be6cae - - 9 files changed: 91 inserted, 9 deleted

@@ -0,0 +1,6
1 + $ ->
2 + $("#submission_problem_go").on 'click', (event) ->
3 + url = $("#submission_problem_id").val()
4 + if (url)
5 + window.location = url
6 +
@@ -0,0 +1,46
1 + - content_for :head do
2 + = stylesheet_link_tag 'problems'
3 + %h1 Listing problems
4 + %p
5 + = link_to 'New problem', new_problem_path, class: 'btn btn-default btn-sm'
6 + = link_to 'Manage problems', { action: 'manage'}, class: 'btn btn-default btn-sm'
7 + = link_to 'Import problems', {:action => 'import'}, class: 'btn btn-default btn-sm'
8 + = link_to 'Turn off all problems', {:action => 'turn_all_off'}, class: 'btn btn-default btn-sm'
9 + = link_to 'Turn on all problems', {:action => 'turn_all_on'}, class: 'btn btn-default btn-sm'
10 + .submitbox
11 + = form_tag :action => 'quick_create' do
12 + %b Quick New:
13 + %label{:for => "problem_name"} Name
14 + = text_field 'problem', 'name'
15 + |
16 + %label{:for => "problem_full_name"} Full name
17 + = text_field 'problem', 'full_name'
18 + = submit_tag "Create"
19 + %table.table.table-condensed.table-hover
20 + %thead
21 + %th Name
22 + %th Full name
23 + %th Full score
24 + %th Date added
25 + %th Avail?
26 + %th Test?
27 + - if GraderConfiguration.multicontests?
28 + %th Contests
29 + - for problem in @problems
30 + %tr{:class => "#{(problem.available) ? "success" : "danger"}", :id => "prob-#{problem.id}", :name => "prob-#{problem.id}"}
31 + - @problem=problem
32 + %td= in_place_editor_field :problem, :name, {}, :rows=>1
33 + %td= in_place_editor_field :problem, :full_name, {}, :rows=>1
34 + %td= in_place_editor_field :problem, :full_score, {}, :rows=>1
35 + %td= problem.date_added
36 + %td{}= link_to (@problem.available? ? "Yes" : "No"), url_for(controller: :problems, action: :toggle, id: @problem), { class: "btn btn-block btn-sm btn-#{(@problem.available? ? 'success' : 'default')} ajax-toggle", id: "prob-#{@problem.id}-avail", data: {remote: true, method: 'post' } }
37 + %td= problem.test_allowed
38 + - if GraderConfiguration.multicontests?
39 + %td
40 + = problem.contests.collect { |c| c.name }.join(', ')
41 + %td= link_to 'Stat', {:action => 'stat', :id => problem.id}, class: 'btn btn-primary btn-sm'
42 + %td= link_to 'Show', {:action => 'show', :id => problem}, class: 'btn btn-primary btn-sm'
43 + %td= link_to 'Edit', {:action => 'edit', :id => problem}, class: 'btn btn-primary btn-sm'
44 + %td= link_to 'Destroy', { :action => 'destroy', :id => problem }, :confirm => 'Are you sure?', :method => :post, class: 'btn btn-danger btn-sm'
45 + %br/
46 + = link_to '[New problem]', :action => 'new'
@@ -0,0 +1,12
1 + :plain
2 + b = $("#prob-#{@problem.id}-avail");
3 + b.removeClass('btn-default');
4 + b.removeClass('btn-success');
5 + b.removeClass('btn-warning');
6 + b.addClass("btn-#{@problem.available? ? 'success' : 'default'}");
7 + b.text("#{@problem.available? ? 'Yes' : 'No'}");
8 + r = $("#prob-#{@problem.id}");
9 + r.removeClass('success');
10 + r.removeClass('danger');
11 + r.addClass("#{@problem.available? ? 'success' : 'danger'}");
12 +
@@ -1,7 +1,6
1 1 #js for announcement
2 2 $ ->
3 3 $('.ajax-toggle').on 'click', (event) ->
4 - console.log event.target.id
5 4 target = $(event.target)
6 5 target.removeClass 'btn-default'
7 6 target.removeClass 'btn-success'
@@ -123,8 +123,8
123 123 @problem = nil
124 124 @submissions = nil
125 125 else
126 - @problem = Problem.find_by_name(params[:id])
127 - if not @problem.available
126 + @problem = Problem.find_by_id(params[:id])
127 + if (@problem == nil) or (not @problem.available)
128 128 redirect_to :action => 'list'
129 129 flash[:notice] = 'Error: submissions for that problem are not viewable.'
130 130 return
@@ -107,6 +107,18
107 107 end
108 108 end
109 109
110 + def problem_select(problems, options = {})
111 + prefix = options[:with_specific_in_header] ? [[(t 'main.specified_in_header'),'-1']] : []
112 + selected = options[:selected] || (options[:with_specific_in_header] ? -1 : nil)
113 + puts "selected = #{selected} hehe"
114 + html_options = {class: 'select2 form-control'}
115 + html_options[:id] = options[:id]if options[:id]
116 + select 'submission',
117 + 'problem_id', prefix + problems.collect {|p| ["[#{p.name}] #{p.full_name}", p.id]},
118 + (selected ? { selected: "#{selected}"} : {} ),
119 + html_options
120 + end
121 +
110 122 def user_title_bar(user)
111 123 header = ''
112 124 time_left = ''
@@ -8,7 +8,7
8 8 %li= msg
9 9 .form-group
10 10 = label_tag :submission, 'Problem:'
11 - = select 'submission', 'problem_id', [[(t 'main.specified_in_header'),'-1']] + @problems.collect {|p| [p.full_name, p.id]}, {:selected => '-1'}, { class: 'select2 form-control' }
11 + = select 'submission', 'problem_id', [[(t 'main.specified_in_header'),'-1']] + @problems.collect {|p| ["[#{p.name}] #{p.full_name}", p.id]}, {:selected => '-1'}, { class: 'select2 form-control' }
12 12 .form-group
13 13 = label_tag :file, 'File:'
14 14 .input-group
@@ -1,10 +1,16
1 1 = user_title_bar(@user)
2 2
3 - .task-menu
4 - Task List
5 - %br/
6 - - @problems.each do |problem|
7 - = link_to problem.name, :action => 'submission', :id => problem.name
3 + .panel.panel-info
4 + .panel-heading
5 + Select Problems
6 + .panel-body
7 + .form-inline
8 + = select 'submission',
9 + 'problem_id',
10 + @problems.collect {|p| ["[#{p.name}] #{p.full_name}", main_submission_url(p.id)]},
11 + {:selected => '-1'},
12 + { class: 'select2 form-control' }
13 + %button.btn.btn-primary.btn-sm#submission_problem_go Go
8 14
9 15 - if @problem!=nil
10 16 %h2= "Task: #{@problem.full_name} (#{@problem.name})"
@@ -20,6 +20,7
20 20
21 21 #main
22 22 get "main/list"
23 + get 'main/submission(/:id)', to: 'main#submission', as: 'main_submission'
23 24
24 25 # See how all your routes lay out with "rake routes"
25 26
You need to be logged in to leave comments. Login now