Description:
* add forgotten toggle file
* main/submission changed to bootstrap
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
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,10 +1,9 | |||||
|
1 | #js for announcement |
|
1 | #js for announcement |
|
2 | $ -> |
|
2 | $ -> |
|
3 | $('.ajax-toggle').on 'click', (event) -> |
|
3 | $('.ajax-toggle').on 'click', (event) -> |
|
4 | - console.log event.target.id |
|
||
|
5 | target = $(event.target) |
|
4 | target = $(event.target) |
|
6 | target.removeClass 'btn-default' |
|
5 | target.removeClass 'btn-default' |
|
7 | target.removeClass 'btn-success' |
|
6 | target.removeClass 'btn-success' |
|
8 | target.addClass 'btn-warning' |
|
7 | target.addClass 'btn-warning' |
|
9 | target.text '...' |
|
8 | target.text '...' |
|
10 | return |
|
9 | return |
@@ -120,14 +120,14 | |||||
|
120 | @user = User.find(session[:user_id]) |
|
120 | @user = User.find(session[:user_id]) |
|
121 | @problems = @user.available_problems |
|
121 | @problems = @user.available_problems |
|
122 | if params[:id]==nil |
|
122 | if params[:id]==nil |
|
123 | @problem = nil |
|
123 | @problem = nil |
|
124 | @submissions = nil |
|
124 | @submissions = nil |
|
125 | else |
|
125 | else |
|
126 |
- @problem = Problem.find_by_ |
|
126 | + @problem = Problem.find_by_id(params[:id]) |
|
127 | - if not @problem.available |
|
127 | + if (@problem == nil) or (not @problem.available) |
|
128 | redirect_to :action => 'list' |
|
128 | redirect_to :action => 'list' |
|
129 | flash[:notice] = 'Error: submissions for that problem are not viewable.' |
|
129 | flash[:notice] = 'Error: submissions for that problem are not viewable.' |
|
130 | return |
|
130 | return |
|
131 | end |
|
131 | end |
|
132 | @submissions = Submission.find_all_by_user_problem(@user.id, @problem.id) |
|
132 | @submissions = Submission.find_all_by_user_problem(@user.id, @problem.id) |
|
133 | end |
|
133 | end |
@@ -104,12 +104,24 | |||||
|
104 | File.open(fname).read(max_size) |
|
104 | File.open(fname).read(max_size) |
|
105 | rescue |
|
105 | rescue |
|
106 | nil |
|
106 | nil |
|
107 | end |
|
107 | end |
|
108 | end |
|
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 | def user_title_bar(user) |
|
122 | def user_title_bar(user) |
|
111 | header = '' |
|
123 | header = '' |
|
112 | time_left = '' |
|
124 | time_left = '' |
|
113 |
|
125 | ||
|
114 | # |
|
126 | # |
|
115 | # if the contest is over |
|
127 | # if the contest is over |
@@ -5,13 +5,13 | |||||
|
5 | %h3= "#{pluralize(@submission.errors.count, "error")} prohibited this user from being saved:" |
|
5 | %h3= "#{pluralize(@submission.errors.count, "error")} prohibited this user from being saved:" |
|
6 | %ul |
|
6 | %ul |
|
7 | - @submission.errors.full_messages.each do |msg| |
|
7 | - @submission.errors.full_messages.each do |msg| |
|
8 | %li= msg |
|
8 | %li= msg |
|
9 | .form-group |
|
9 | .form-group |
|
10 | = label_tag :submission, 'Problem:' |
|
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 | .form-group |
|
12 | .form-group |
|
13 | = label_tag :file, 'File:' |
|
13 | = label_tag :file, 'File:' |
|
14 | .input-group |
|
14 | .input-group |
|
15 | %span.input-group-btn |
|
15 | %span.input-group-btn |
|
16 | %span.btn.btn-default.btn-file |
|
16 | %span.btn.btn-default.btn-file |
|
17 | Browse |
|
17 | Browse |
@@ -1,13 +1,19 | |||||
|
1 | = user_title_bar(@user) |
|
1 | = user_title_bar(@user) |
|
2 |
|
2 | ||
|
3 | - .task-menu |
|
3 | + .panel.panel-info |
|
4 | - Task List |
|
4 | + .panel-heading |
|
5 | - %br/ |
|
5 | + Select Problems |
|
6 | - - @problems.each do |problem| |
|
6 | + .panel-body |
|
7 | - = link_to problem.name, :action => 'submission', :id => problem.name |
|
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 | - if @problem!=nil |
|
15 | - if @problem!=nil |
|
10 | %h2= "Task: #{@problem.full_name} (#{@problem.name})" |
|
16 | %h2= "Task: #{@problem.full_name} (#{@problem.name})" |
|
11 |
|
17 | ||
|
12 | - if @submissions!=nil |
|
18 | - if @submissions!=nil |
|
13 | - if @submissions.length>0 |
|
19 | - if @submissions.length>0 |
@@ -17,12 +17,13 | |||||
|
17 | match 'tasks/view/:file.:ext' => 'tasks#view' |
|
17 | match 'tasks/view/:file.:ext' => 'tasks#view' |
|
18 | match 'tasks/download/:id/:file.:ext' => 'tasks#download' |
|
18 | match 'tasks/download/:id/:file.:ext' => 'tasks#download' |
|
19 | match 'heartbeat/:id/edit' => 'heartbeat#edit' |
|
19 | match 'heartbeat/:id/edit' => 'heartbeat#edit' |
|
20 |
|
20 | ||
|
21 | #main |
|
21 | #main |
|
22 | get "main/list" |
|
22 | get "main/list" |
|
|
23 | + get 'main/submission(/:id)', to: 'main#submission', as: 'main_submission' | ||
|
23 |
|
24 | ||
|
24 | # See how all your routes lay out with "rake routes" |
|
25 | # See how all your routes lay out with "rake routes" |
|
25 |
|
26 | ||
|
26 | # This is a legacy wild controller route that's not recommended for RESTful applications. |
|
27 | # This is a legacy wild controller route that's not recommended for RESTful applications. |
|
27 | # Note: This route will make all actions in every controller accessible via GET requests. |
|
28 | # Note: This route will make all actions in every controller accessible via GET requests. |
|
28 | match ':controller(/:action(/:id))(.:format)' |
|
29 | match ':controller(/:action(/:id))(.:format)' |
You need to be logged in to leave comments.
Login now