Description:
add jquery to manage problem, now we can select a range of problem
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r456:2cbe975cbc59 - - 11 files changed: 67 inserted, 63 deleted
file renamed from app/assets/javascripts/new.js to app/assets/javascripts/local_jquery.js |
@@ -9,13 +9,13 | |||||
|
9 | 'reply','hide','list_all'] |
|
9 | 'reply','hide','list_all'] |
|
10 |
|
10 | ||
|
11 | def list |
|
11 | def list |
|
12 | @user = User.find(session[:user_id]) |
|
12 | @user = User.find(session[:user_id]) |
|
13 | @messages = Message.find_all_sent_by_user(@user) |
|
13 | @messages = Message.find_all_sent_by_user(@user) |
|
14 | end |
|
14 | end |
|
15 | - |
|
15 | + |
|
16 | def console |
|
16 | def console |
|
17 | @user = User.find(session[:user_id]) |
|
17 | @user = User.find(session[:user_id]) |
|
18 | @messages = Message.find_all_system_unreplied_messages |
|
18 | @messages = Message.find_all_system_unreplied_messages |
|
19 | end |
|
19 | end |
|
20 |
|
20 | ||
|
21 | def show |
|
21 | def show |
@@ -161,14 +161,18 | |||||
|
161 | @problems = Problem.find(:all, :order => 'date_added DESC') |
|
161 | @problems = Problem.find(:all, :order => 'date_added DESC') |
|
162 | end |
|
162 | end |
|
163 |
|
163 | ||
|
164 | def do_manage |
|
164 | def do_manage |
|
165 | if params.has_key? 'change_date_added' |
|
165 | if params.has_key? 'change_date_added' |
|
166 | change_date_added |
|
166 | change_date_added |
|
167 |
- els |
|
167 | + elsif params.has_key? 'add_to_contest' |
|
168 | add_to_contest |
|
168 | add_to_contest |
|
|
169 | + elsif params.has_key? 'enable_problem' | ||
|
|
170 | + set_available(true) | ||
|
|
171 | + elsif params.has_key? 'disable_problem' | ||
|
|
172 | + set_available(false) | ||
|
169 | end |
|
173 | end |
|
170 | redirect_to :action => 'manage' |
|
174 | redirect_to :action => 'manage' |
|
171 | end |
|
175 | end |
|
172 |
|
176 | ||
|
173 | def import |
|
177 | def import |
|
174 | @allow_test_pair_import = allow_test_pair_import? |
|
178 | @allow_test_pair_import = allow_test_pair_import? |
@@ -231,17 +235,25 | |||||
|
231 | problems.each do |p| |
|
235 | problems.each do |p| |
|
232 | p.contests << contest |
|
236 | p.contests << contest |
|
233 | end |
|
237 | end |
|
234 | end |
|
238 | end |
|
235 | end |
|
239 | end |
|
236 |
|
240 | ||
|
|
241 | + def set_available(avail) | ||
|
|
242 | + problems = get_problems_from_params | ||
|
|
243 | + problems.each do |p| | ||
|
|
244 | + p.available = avail | ||
|
|
245 | + p.save | ||
|
|
246 | + end | ||
|
|
247 | + end | ||
|
|
248 | + | ||
|
237 | def get_problems_from_params |
|
249 | def get_problems_from_params |
|
238 | problems = [] |
|
250 | problems = [] |
|
239 | params.keys.each do |k| |
|
251 | params.keys.each do |k| |
|
240 | if k.index('prob-')==0 |
|
252 | if k.index('prob-')==0 |
|
241 | - name, id = k.split('-') |
|
253 | + name, id, order = k.split('-') |
|
242 | problems << Problem.find(id) |
|
254 | problems << Problem.find(id) |
|
243 | end |
|
255 | end |
|
244 | end |
|
256 | end |
|
245 | problems |
|
257 | problems |
|
246 | end |
|
258 | end |
|
247 |
|
259 |
@@ -18,13 +18,13 | |||||
|
18 | def self.find_all_sent_by_user(user) |
|
18 | def self.find_all_sent_by_user(user) |
|
19 | messages = user.messages |
|
19 | messages = user.messages |
|
20 | replied_messages = user.replied_messages |
|
20 | replied_messages = user.replied_messages |
|
21 | Message.build_replying_message_hierarchy messages, replied_messages |
|
21 | Message.build_replying_message_hierarchy messages, replied_messages |
|
22 | return messages |
|
22 | return messages |
|
23 | end |
|
23 | end |
|
24 | - |
|
24 | + |
|
25 | def self.find_all_system_unreplied_messages |
|
25 | def self.find_all_system_unreplied_messages |
|
26 | self.find(:all, |
|
26 | self.find(:all, |
|
27 | :conditions => 'ISNULL(receiver_id) ' + |
|
27 | :conditions => 'ISNULL(receiver_id) ' + |
|
28 | 'AND (ISNULL(replied) OR replied=0)', |
|
28 | 'AND (ISNULL(replied) OR replied=0)', |
|
29 | :order => 'created_at') |
|
29 | :order => 'created_at') |
|
30 | end |
|
30 | end |
@@ -1,43 +1,85 | |||||
|
1 | - content_for :head do |
|
1 | - content_for :head do |
|
2 | = stylesheet_link_tag 'problems' |
|
2 | = stylesheet_link_tag 'problems' |
|
|
3 | + = javascript_include_tag 'local_jquery' | ||
|
|
4 | + | ||
|
|
5 | + :javascript | ||
|
|
6 | + $(document).ready( function() { | ||
|
|
7 | + function shiftclick(start,stop,value) { | ||
|
|
8 | + $('tr input').each( function(id,input) { | ||
|
|
9 | + var $input=$(input); | ||
|
|
10 | + var iid=parseInt($input.attr('id').split('-')[2]); | ||
|
|
11 | + if(iid>=start&&iid<=stop){ | ||
|
|
12 | + $input.prop('checked',value) | ||
|
|
13 | + } | ||
|
|
14 | + }); | ||
|
|
15 | + } | ||
|
|
16 | + | ||
|
|
17 | + $('tr input').click( function(e) { | ||
|
|
18 | + if (e.shiftKey) { | ||
|
|
19 | + stop = parseInt($(this).attr('id').split('-')[2]); | ||
|
|
20 | + var orig_stop = stop | ||
|
|
21 | + if (typeof start !== 'undefined') { | ||
|
|
22 | + if (start > stop) { | ||
|
|
23 | + var tmp = start; | ||
|
|
24 | + start = stop; | ||
|
|
25 | + stop = tmp; | ||
|
|
26 | + } | ||
|
|
27 | + shiftclick(start,stop,$(this).is(':checked') ) | ||
|
|
28 | + } | ||
|
|
29 | + start = orig_stop | ||
|
|
30 | + } else { | ||
|
|
31 | + start = parseInt($(this).attr('id').split('-')[2]); | ||
|
|
32 | + } | ||
|
|
33 | + }); | ||
|
|
34 | + }); | ||
|
|
35 | + | ||
|
3 |
|
36 | ||
|
4 | %h1 Manage problems |
|
37 | %h1 Manage problems |
|
5 |
|
38 | ||
|
6 | %p= link_to '[Back to problem list]', :action => 'list' |
|
39 | %p= link_to '[Back to problem list]', :action => 'list' |
|
7 |
|
40 | ||
|
8 | = form_tag :action=>'do_manage' do |
|
41 | = form_tag :action=>'do_manage' do |
|
9 | .submitbox |
|
42 | .submitbox |
|
10 | - What do you want to do? |
|
43 | + What do you want to do to the selected problem? |
|
11 | %br/ |
|
44 | %br/ |
|
|
45 | + (You can shift-click to select a range of problems) | ||
|
12 | %ul |
|
46 | %ul |
|
13 | %li |
|
47 | %li |
|
14 | Change date added to |
|
48 | Change date added to |
|
15 | = select_date Date.current, :prefix => 'date_added' |
|
49 | = select_date Date.current, :prefix => 'date_added' |
|
16 | |
|
50 | |
|
17 | = submit_tag 'Change', :name => 'change_date_added' |
|
51 | = submit_tag 'Change', :name => 'change_date_added' |
|
|
52 | + %li | ||
|
|
53 | + Set available to | ||
|
|
54 | + = submit_tag 'True', :name => 'enable_problem' | ||
|
|
55 | + = submit_tag 'False', :name => 'disable_problem' | ||
|
18 |
|
56 | ||
|
19 | - if GraderConfiguration.multicontests? |
|
57 | - if GraderConfiguration.multicontests? |
|
20 | %li |
|
58 | %li |
|
21 | Add to |
|
59 | Add to |
|
22 | = select("contest","id",Contest.all.collect {|c| [c.title, c.id]}) |
|
60 | = select("contest","id",Contest.all.collect {|c| [c.title, c.id]}) |
|
23 | = submit_tag 'Add', :name => 'add_to_contest' |
|
61 | = submit_tag 'Add', :name => 'add_to_contest' |
|
24 |
|
62 | ||
|
25 | %table |
|
63 | %table |
|
26 | - %tr |
|
64 | + %tr{style: "text-align: left;"} |
|
27 | - %th/ |
|
65 | + %th= check_box_tag 'select_all' |
|
28 | %th Name |
|
66 | %th Name |
|
29 | %th Full name |
|
67 | %th Full name |
|
|
68 | + %th Available | ||
|
30 | %th Date added |
|
69 | %th Date added |
|
31 | - if GraderConfiguration.multicontests? |
|
70 | - if GraderConfiguration.multicontests? |
|
32 | %th Contests |
|
71 | %th Contests |
|
33 |
|
72 | ||
|
|
73 | + - num = 0 | ||
|
34 | - for problem in @problems |
|
74 | - for problem in @problems |
|
|
75 | + - num += 1 | ||
|
35 | %tr{:id => "row-prob-#{problem.id}", :name=> "prob-#{problem.id}"} |
|
76 | %tr{:id => "row-prob-#{problem.id}", :name=> "prob-#{problem.id}"} |
|
36 | - %td= check_box_tag "prob-#{problem.id}" |
|
77 | + %td= check_box_tag "prob-#{problem.id}-#{num}" |
|
37 | %td= problem.name |
|
78 | %td= problem.name |
|
38 | %td= problem.full_name |
|
79 | %td= problem.full_name |
|
|
80 | + %td= problem.available | ||
|
39 | %td= problem.date_added |
|
81 | %td= problem.date_added |
|
40 | - if GraderConfiguration.multicontests? |
|
82 | - if GraderConfiguration.multicontests? |
|
41 | %td |
|
83 | %td |
|
42 | - problem.contests.each do |contest| |
|
84 | - problem.contests.each do |contest| |
|
43 | = "(#{contest.name} [#{link_to 'x', :action => 'remove_contest', :id => problem.id, :contest_id => contest.id }])" |
|
85 | = "(#{contest.name} [#{link_to 'x', :action => 'remove_contest', :id => problem.id, :contest_id => contest.id }])" |
@@ -1,9 +1,9 | |||||
|
1 | - content_for :header do |
|
1 | - content_for :header do |
|
2 | = stylesheet_link_tag 'tablesorter-theme.cafe' |
|
2 | = stylesheet_link_tag 'tablesorter-theme.cafe' |
|
3 |
- = javascript_include_tag ' |
|
3 | + = javascript_include_tag 'local_jquery' |
|
4 |
|
4 | ||
|
5 | %script{:type=>"text/javascript"} |
|
5 | %script{:type=>"text/javascript"} |
|
6 | $(function () { |
|
6 | $(function () { |
|
7 | $('#since_datetime').datetimepicker({ showButtonPanel: true, dateFormat: "yy-mm-dd", controlType: "slider"} ); |
|
7 | $('#since_datetime').datetimepicker({ showButtonPanel: true, dateFormat: "yy-mm-dd", controlType: "slider"} ); |
|
8 | $('#until_datetime').datetimepicker({ showButtonPanel: true, dateFormat: "yy-mm-dd", controlType: "slider"} ); |
|
8 | $('#until_datetime').datetimepicker({ showButtonPanel: true, dateFormat: "yy-mm-dd", controlType: "slider"} ); |
|
9 | $('#my_table').tablesorter({widthFixed: true, widgets: ['zebra']}); |
|
9 | $('#my_table').tablesorter({widthFixed: true, widgets: ['zebra']}); |
@@ -1,8 +1,8 | |||||
|
1 | - content_for :header do |
|
1 | - content_for :header do |
|
2 |
- = javascript_include_tag ' |
|
2 | + = javascript_include_tag 'local_jquery' |
|
3 |
|
3 | ||
|
4 | %script{:type=>"text/javascript"} |
|
4 | %script{:type=>"text/javascript"} |
|
5 | $(function () { |
|
5 | $(function () { |
|
6 | $('#since_datetime').datetimepicker({ showButtonPanel: true, dateFormat: "yy-mm-dd", controlType: "slider"} ); |
|
6 | $('#since_datetime').datetimepicker({ showButtonPanel: true, dateFormat: "yy-mm-dd", controlType: "slider"} ); |
|
7 | $('#until_datetime').datetimepicker({ showButtonPanel: true, dateFormat: "yy-mm-dd", controlType: "slider"} ); |
|
7 | $('#until_datetime').datetimepicker({ showButtonPanel: true, dateFormat: "yy-mm-dd", controlType: "slider"} ); |
|
8 | }); |
|
8 | }); |
@@ -1,8 +1,8 | |||||
|
1 | - content_for :header do |
|
1 | - content_for :header do |
|
2 |
- = javascript_include_tag ' |
|
2 | + = javascript_include_tag 'local_jquery' |
|
3 | = stylesheet_link_tag 'tablesorter-theme.cafe' |
|
3 | = stylesheet_link_tag 'tablesorter-theme.cafe' |
|
4 |
|
4 | ||
|
5 | %script{:type=>"text/javascript"} |
|
5 | %script{:type=>"text/javascript"} |
|
6 | $(function () { |
|
6 | $(function () { |
|
7 | $('#since_datetime').datetimepicker({ showButtonPanel: true, dateFormat: "yy-mm-dd", controlType: "slider"} ); |
|
7 | $('#since_datetime').datetimepicker({ showButtonPanel: true, dateFormat: "yy-mm-dd", controlType: "slider"} ); |
|
8 | $('#until_datetime').datetimepicker({ showButtonPanel: true, dateFormat: "yy-mm-dd", controlType: "slider"} ); |
|
8 | $('#until_datetime').datetimepicker({ showButtonPanel: true, dateFormat: "yy-mm-dd", controlType: "slider"} ); |
@@ -1,8 +1,8 | |||||
|
1 | - content_for :header do |
|
1 | - content_for :header do |
|
2 |
- = javascript_include_tag ' |
|
2 | + = javascript_include_tag 'local_jquery' |
|
3 |
|
3 | ||
|
4 | %script{:type=>"text/javascript"} |
|
4 | %script{:type=>"text/javascript"} |
|
5 | $(function () { |
|
5 | $(function () { |
|
6 | $('#submission_table').tablesorter({widgets: ['zebra']}); |
|
6 | $('#submission_table').tablesorter({widgets: ['zebra']}); |
|
7 | }); |
|
7 | }); |
|
8 |
|
8 |
@@ -57,9 +57,9 | |||||
|
57 | config.assets.enabled = true |
|
57 | config.assets.enabled = true |
|
58 |
|
58 | ||
|
59 | # Version of your assets, change this if you want to expire all your assets |
|
59 | # Version of your assets, change this if you want to expire all your assets |
|
60 | config.assets.version = '1.0' |
|
60 | config.assets.version = '1.0' |
|
61 |
|
61 | ||
|
62 | config.assets.precompile += ['announcement_refresh.js','effects.js','site_update.js','graders.css','problems.css'] |
|
62 | config.assets.precompile += ['announcement_refresh.js','effects.js','site_update.js','graders.css','problems.css'] |
|
63 |
- config.assets.precompile += [' |
|
63 | + config.assets.precompile += ['local_jquery.js','tablesorter-theme.cafe.css'] |
|
64 | end |
|
64 | end |
|
65 | end |
|
65 | end |
deleted file |
You need to be logged in to leave comments.
Login now