Description:
[web] in problems, added turn_all_off, and improved ui
git-svn-id: http://theory.cpe.ku.ac.th/grader/web/trunk@128 6386c4cd-e34a-4fa8-8920-d93eb39b512e
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r56:ae06afdcf005 - - 4 files changed: 71 inserted, 39 deleted
@@ -0,0 +1,8 | |||||
|
|
1 | + | ||
|
|
2 | + tr.available { | ||
|
|
3 | + background: #c0ffc0; | ||
|
|
4 | + } | ||
|
|
5 | + | ||
|
|
6 | + tr.not-available { | ||
|
|
7 | + background: #ffc0c0; | ||
|
|
8 | + } |
@@ -42,29 +42,38 | |||||
|
42 | end |
|
42 | end |
|
43 |
|
43 | ||
|
44 | def update |
|
44 | def update |
|
45 | @problem = Problem.find(params[:id]) |
|
45 | @problem = Problem.find(params[:id]) |
|
46 | if @problem.update_attributes(params[:problem]) |
|
46 | if @problem.update_attributes(params[:problem]) |
|
47 | flash[:notice] = 'Problem was successfully updated.' |
|
47 | flash[:notice] = 'Problem was successfully updated.' |
|
48 | redirect_to :action => 'show', :id => @problem |
|
48 | redirect_to :action => 'show', :id => @problem |
|
49 | else |
|
49 | else |
|
50 | render :action => 'edit' |
|
50 | render :action => 'edit' |
|
51 | end |
|
51 | end |
|
52 | end |
|
52 | end |
|
53 |
|
53 | ||
|
54 | def destroy |
|
54 | def destroy |
|
55 | Problem.find(params[:id]).destroy |
|
55 | Problem.find(params[:id]).destroy |
|
56 | redirect_to :action => 'list' |
|
56 | redirect_to :action => 'list' |
|
57 | end |
|
57 | end |
|
58 |
|
58 | ||
|
59 | def toggle_avail |
|
59 | def toggle_avail |
|
60 | problem = Problem.find(params[:id]) |
|
60 | problem = Problem.find(params[:id]) |
|
61 | problem.available = !(problem.available) |
|
61 | problem.available = !(problem.available) |
|
62 | problem.save |
|
62 | problem.save |
|
63 | redirect_to :action => 'list' |
|
63 | redirect_to :action => 'list' |
|
64 | end |
|
64 | end |
|
65 |
|
65 | ||
|
|
66 | + def turn_all_off | ||
|
|
67 | + Problem.find(:all, | ||
|
|
68 | + :conditions => "available = 1").each do |problem| | ||
|
|
69 | + problem.available = false | ||
|
|
70 | + problem.save | ||
|
|
71 | + end | ||
|
|
72 | + redirect_to :action => 'list' | ||
|
|
73 | + end | ||
|
|
74 | + | ||
|
66 | def stat |
|
75 | def stat |
|
67 | @problem = Problem.find(params[:id]) |
|
76 | @problem = Problem.find(params[:id]) |
|
68 | @submissions = Submission.find_all_last_by_problem(params[:id]) |
|
77 | @submissions = Submission.find_all_last_by_problem(params[:id]) |
|
69 | end |
|
78 | end |
|
70 | end |
|
79 | end |
@@ -1,44 +1,46 | |||||
|
1 | <% content_for :head do %> |
|
1 | <% content_for :head do %> |
|
2 | <%= stylesheet_link_tag 'scaffold' %> |
|
2 | <%= stylesheet_link_tag 'scaffold' %> |
|
|
3 | + <%= stylesheet_link_tag 'problems' %> | ||
|
3 | <%= javascript_include_tag :defaults %> |
|
4 | <%= javascript_include_tag :defaults %> |
|
4 | <% end %> |
|
5 | <% end %> |
|
5 |
|
6 | ||
|
6 | <h1>Listing problems</h1> |
|
7 | <h1>Listing problems</h1> |
|
7 |
|
8 | ||
|
8 | <div class="usermenu"> |
|
9 | <div class="usermenu"> |
|
9 | <%= link_to 'Main', :controller => 'main', :action => 'list' %> |
|
10 | <%= link_to 'Main', :controller => 'main', :action => 'list' %> |
|
10 | </div> |
|
11 | </div> |
|
11 |
|
12 | ||
|
12 |
- <%= link_to 'New problem', :action => 'new' %> |
|
13 | + <%= link_to 'New problem', :action => 'new' %> |
|
|
14 | + <%= link_to 'Turn off all problems', :action => 'turn_all_off' %><br/> | ||
|
13 |
|
15 | ||
|
14 | <table> |
|
16 | <table> |
|
15 | <tr> |
|
17 | <tr> |
|
16 | <th>Name</th> |
|
18 | <th>Name</th> |
|
17 | <th>Full name</th> |
|
19 | <th>Full name</th> |
|
18 | <th>Full score</th> |
|
20 | <th>Full score</th> |
|
19 | <th>Date added</th> |
|
21 | <th>Date added</th> |
|
20 | <th>Available</th> |
|
22 | <th>Available</th> |
|
21 | </tr> |
|
23 | </tr> |
|
22 |
|
24 | ||
|
23 | <% for problem in @problems %> |
|
25 | <% for problem in @problems %> |
|
24 | - <tr> |
|
26 | + <tr class="<%= (problem.available) ? "available" : "not-available" %>"> |
|
25 | <% @problem=problem %> |
|
27 | <% @problem=problem %> |
|
26 | <td><%= in_place_editor_field :problem, :name, {}, :rows=>1 %> |
|
28 | <td><%= in_place_editor_field :problem, :name, {}, :rows=>1 %> |
|
27 | <td><%= in_place_editor_field :problem, :full_name, {}, :rows=>1 %> |
|
29 | <td><%= in_place_editor_field :problem, :full_name, {}, :rows=>1 %> |
|
28 | <td><%= in_place_editor_field :problem, :full_score, {}, :rows=>1 %> |
|
30 | <td><%= in_place_editor_field :problem, :full_score, {}, :rows=>1 %> |
|
29 | <td><%= problem.date_added %> |
|
31 | <td><%= problem.date_added %> |
|
30 | <td><%= problem.available %> |
|
32 | <td><%= problem.available %> |
|
31 |
|
33 | ||
|
32 | <td><%= link_to '[Toggle]', :action => 'toggle_avail', :id => problem.id %></td> |
|
34 | <td><%= link_to '[Toggle]', :action => 'toggle_avail', :id => problem.id %></td> |
|
33 | <td><%= link_to '[Stat]', :action => 'stat', :id => problem.id %></td> |
|
35 | <td><%= link_to '[Stat]', :action => 'stat', :id => problem.id %></td> |
|
34 | <td><%= link_to '[Show]', :action => 'show', :id => problem %></td> |
|
36 | <td><%= link_to '[Show]', :action => 'show', :id => problem %></td> |
|
35 | <td><%= link_to '[Edit]', :action => 'edit', :id => problem %></td> |
|
37 | <td><%= link_to '[Edit]', :action => 'edit', :id => problem %></td> |
|
36 | <td><%= link_to '[Destroy]', { :action => 'destroy', :id => problem }, :confirm => 'Are you sure?', :method => :post %></td> |
|
38 | <td><%= link_to '[Destroy]', { :action => 'destroy', :id => problem }, :confirm => 'Are you sure?', :method => :post %></td> |
|
37 | </tr> |
|
39 | </tr> |
|
38 | <% end %> |
|
40 | <% end %> |
|
39 | </table> |
|
41 | </table> |
|
40 |
|
42 | ||
|
41 |
|
43 | ||
|
42 | <br /> |
|
44 | <br /> |
|
43 |
|
45 | ||
|
44 | <%= link_to 'New problem', :action => 'new' %> |
|
46 | <%= link_to 'New problem', :action => 'new' %> |
@@ -1,88 +1,101 | |||||
|
|
1 | + /* Normal text */ | ||
|
1 | p { |
|
2 | p { |
|
2 | font-size: 12px; |
|
3 | font-size: 12px; |
|
3 | } |
|
4 | } |
|
4 |
|
5 | ||
|
5 | - div.title { |
|
6 | + /* This is the main menu bad*/ |
|
6 | - font-size: 20px; |
|
||
|
7 | - font-weight: bold; |
|
||
|
8 | - background: lightgreen; |
|
||
|
9 | - padding: 2px; |
|
||
|
10 | - } |
|
||
|
11 | - |
|
||
|
12 | div.userbar { |
|
7 | div.userbar { |
|
13 | border-top: thin solid grey; |
|
8 | border-top: thin solid grey; |
|
14 | border-bottom: thin solid grey; |
|
9 | border-bottom: thin solid grey; |
|
15 | text-align: right; |
|
10 | text-align: right; |
|
16 | font-size: 12px; |
|
11 | font-size: 12px; |
|
17 | } |
|
12 | } |
|
18 |
|
13 | ||
|
19 | - div.compilermsgbody { |
|
14 | + /* This is the top bar, displaying user's full name */ |
|
20 | - font-family: monospace; |
|
15 | + div.title { |
|
21 | - } |
|
16 | + font-size: 20px; |
|
22 | - |
|
||
|
23 | - div.submitbox { |
|
||
|
24 | - border: thin solid black; |
|
||
|
25 | - padding: 5px; |
|
||
|
26 | - color: white; |
|
||
|
27 | - background-color: #777777; |
|
||
|
28 | font-weight: bold; |
|
17 | font-weight: bold; |
|
29 | - font-size: 13px; |
|
18 | + background: lightgreen; |
|
|
19 | + padding: 2px; | ||
|
30 | } |
|
20 | } |
|
31 |
|
21 | ||
|
32 | - table.uinfo { |
|
22 | + /* Standard table with header and rows with alternating background */ |
|
33 | - border-collapse: collapse; |
|
||
|
34 | - border: 1px solid black; |
|
||
|
35 | - font-size: 13px; |
|
||
|
36 | - } |
|
||
|
37 | - |
|
||
|
38 | - td.uinfo { |
|
||
|
39 | - vertical-align: top; |
|
||
|
40 | - border: 1px solid black; |
|
||
|
41 | - padding: 5px; |
|
||
|
42 | - } |
|
||
|
43 | - |
|
||
|
44 | - th.uinfo { |
|
||
|
45 | - background: lightgreen; |
|
||
|
46 | - vertical-align: top; |
|
||
|
47 | - text-align: right; |
|
||
|
48 | - border: 1px solid black; |
|
||
|
49 | - padding: 5px; |
|
||
|
50 | - } |
|
||
|
51 | - |
|
||
|
52 | table.info { |
|
23 | table.info { |
|
53 | border: 1px solid black; |
|
24 | border: 1px solid black; |
|
54 | border-collapse: collapse; |
|
25 | border-collapse: collapse; |
|
55 | font-size: 12px; |
|
26 | font-size: 12px; |
|
56 | } |
|
27 | } |
|
57 |
|
28 | ||
|
58 | th.info { |
|
29 | th.info { |
|
59 | border: 1px solid black; |
|
30 | border: 1px solid black; |
|
60 | } |
|
31 | } |
|
61 |
|
32 | ||
|
62 | td.info { |
|
33 | td.info { |
|
63 | border-left: 1px solid black; |
|
34 | border-left: 1px solid black; |
|
64 | border-right: 1px solid black; |
|
35 | border-right: 1px solid black; |
|
65 | } |
|
36 | } |
|
66 |
|
37 | ||
|
67 | tr.info-head { |
|
38 | tr.info-head { |
|
68 | background: #777777; |
|
39 | background: #777777; |
|
69 | color: white; |
|
40 | color: white; |
|
70 | } |
|
41 | } |
|
71 |
|
42 | ||
|
72 | tr.info-odd { |
|
43 | tr.info-odd { |
|
73 | background: #dddddd; |
|
44 | background: #dddddd; |
|
74 | } |
|
45 | } |
|
75 |
|
46 | ||
|
76 | tr.info-even { |
|
47 | tr.info-even { |
|
77 | background: #f0f0f0; |
|
48 | background: #f0f0f0; |
|
78 | } |
|
49 | } |
|
79 |
|
50 | ||
|
|
51 | + /******************************* | ||
|
|
52 | + [Main] | ||
|
|
53 | + ********************************/ | ||
|
|
54 | + div.submitbox { | ||
|
|
55 | + border: thin solid black; | ||
|
|
56 | + padding: 5px; | ||
|
|
57 | + color: white; | ||
|
|
58 | + background-color: #777777; | ||
|
|
59 | + font-weight: bold; | ||
|
|
60 | + font-size: 13px; | ||
|
|
61 | + } | ||
|
|
62 | + | ||
|
|
63 | + /******************************* | ||
|
|
64 | + [Settings] | ||
|
|
65 | + ********************************/ | ||
|
|
66 | + table.uinfo { | ||
|
|
67 | + border-collapse: collapse; | ||
|
|
68 | + border: 1px solid black; | ||
|
|
69 | + font-size: 13px; | ||
|
|
70 | + } | ||
|
|
71 | + | ||
|
|
72 | + td.uinfo { | ||
|
|
73 | + vertical-align: top; | ||
|
|
74 | + border: 1px solid black; | ||
|
|
75 | + padding: 5px; | ||
|
|
76 | + } | ||
|
|
77 | + | ||
|
|
78 | + th.uinfo { | ||
|
|
79 | + background: lightgreen; | ||
|
|
80 | + vertical-align: top; | ||
|
|
81 | + text-align: right; | ||
|
|
82 | + border: 1px solid black; | ||
|
|
83 | + padding: 5px; | ||
|
|
84 | + } | ||
|
|
85 | + | ||
|
|
86 | + /******************************* | ||
|
|
87 | + [Submission] | ||
|
|
88 | + ********************************/ | ||
|
|
89 | + div.compilermsgbody { | ||
|
|
90 | + font-family: monospace; | ||
|
|
91 | + } | ||
|
|
92 | + | ||
|
80 | div.task-menu { |
|
93 | div.task-menu { |
|
81 | text-align: center; |
|
94 | text-align: center; |
|
82 | font-size: 13px; |
|
95 | font-size: 13px; |
|
83 | font-weight: bold; |
|
96 | font-weight: bold; |
|
84 | border-top: 1px solid black; |
|
97 | border-top: 1px solid black; |
|
85 | border-bottom: 1px solid black; |
|
98 | border-bottom: 1px solid black; |
|
86 | margin-top: 2px; |
|
99 | margin-top: 2px; |
|
87 | margin-bottom: 4px; |
|
100 | margin-bottom: 4px; |
|
88 | } |
|
101 | } |
You need to be logged in to leave comments.
Login now