Description:
+in_place_editing for problems git-svn-id: http://theory.cpe.ku.ac.th/grader/web/trunk@45 6386c4cd-e34a-4fa8-8920-d93eb39b512e
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r21:e66aa2c506e7 - - 6 files changed: 35 inserted, 27 deleted

@@ -1,16 +1,20
1 1 class ProblemsController < ApplicationController
2 2
3 3 before_filter :authenticate, :authorization
4 4
5 + in_place_edit_for :problem, :name
6 + in_place_edit_for :problem, :full_name
7 + in_place_edit_for :problem, :full_score
8 +
5 9 def index
6 10 list
7 11 render :action => 'list'
8 12 end
9 13
10 14 # GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html)
11 15 verify :method => :post, :only => [ :destroy, :create, :update ],
12 16 :redirect_to => { :action => :list }
13 17
14 18 def list
15 19 @problems = Problem.find(:all, :order => 'date_added DESC')
16 20 end
@@ -17,29 +17,29
17 17 if(n.style.display == 'none') { n.style.display = 'block'; }
18 18 else {n.style.display ='none'; } return false;">
19 19 Compiler message</a> (click to see)</div>
20 20 <div style="display: none">
21 21 <div class="compilermsgbody" style="border: thin solid grey; margin: 2px">
22 22 #{h(sub.compiler_message).gsub(/\n/,'<br/>')}
23 23 </div>
24 24 </div></div>
25 25 cmpmsg
26 26 end
27 27
28 28 def format_submission(sub, count)
29 - msg = "#{count} submission(s)<br />"
29 + msg = "#{count} submission(s)."
30 30 if count>0
31 31 msg = msg + "Last on " +
32 32 format_short_time(sub.submitted_at) + ' ' +
33 - link_to('[source]',{:action => 'get_source', :id => sub.id}) +
34 - "<br />"
33 + link_to('[source]',{:action => 'get_source', :id => sub.id})
35 34 end
35 + msg += "<br/>"
36 36 if sub!=nil and sub.graded_at!=nil
37 37 msg = msg + 'Graded at ' + format_short_time(sub.graded_at) + ', score: '+
38 38 sub.points.to_s +
39 39 ' [' + sub.grader_comment + "]<br />" +
40 40 format_compiler_msg(sub)
41 41 end
42 42 msg
43 43 end
44 44
45 45 end
@@ -1,17 +1,18
1 1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2 2 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3 3
4 4 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5 5 <head>
6 6 <meta http-equiv="content-type" content="text/html;charset=UTF-8" />
7 7 <title>Problems: <%= controller.action_name %></title>
8 8 <%= stylesheet_link_tag 'scaffold' %>
9 + <%= javascript_include_tag :defaults %>
9 10 </head>
10 11 <body>
11 12
12 13 <p style="color: green"><%= flash[:notice] %></p>
13 14
14 15 <%= yield %>
15 16
16 17 </body>
17 18 </html>
@@ -1,50 +1,37
1 - <h1>Hello <%=h @user.full_name %></h1>
2 - (<%= Time.new %>)
1 + <div class="title">Hello <%=h @user.full_name %></div>
2 + Current time is <%= format_short_time(Time.new) %>.
3 3
4 4 <div class="submitbox">
5 5 <% form_tag({:action => 'submit'}, :multipart => true) do %>
6 6 Problem: <%= select 'submission', 'problem_id',
7 7 [['Specified in header','-1']] +
8 8 @problems.collect {|p| [p.full_name, p.id]},
9 9 :selected => '-1' %>
10 10 File: <%= file_field_tag 'file' %>
11 11 <%= submit_tag 'Submit' %>
12 12 <% end %>
13 13 </div>
14 14
15 15 <hr/>
16 16
17 17 <p style="color: red"><%= flash[:notice] %></p>
18 18
19 19 <div class="problist">
20 20 <% i = 0 %>
21 21 <% @problems.each do |p| %>
22 22 <div class="problist-each">
23 23 <div class="probname">
24 24 <%= "#{i+1}: #{p.full_name} (#{p.name})" %>
25 - <%= link_to '[task description]', p.url if p.url!=nil %>
25 + <%= link_to '[task description]', p.url if (p.url!=nil) and (p.url!='') %>
26 26 </div>
27 27 <div class="subinfo">
28 28 <%= format_submission(@prob_submissions[i][1],
29 29 @prob_submissions[i][0]) %>
30 30 </div>
31 31 </div>
32 32 <% i = i+1 %>
33 33 <% end %>
34 34 </div>
35 35
36 - <br />
37 36 <hr />
38 - <br />
39 37
40 - <div class="submitbox">
41 - <% form_tag({:action => 'submit'}, :multipart => true) do %>
42 - Problem: <%= select 'submission', 'problem_id',
43 - [['Specified in header','-1']] +
44 - @problems.collect {|p| [p.full_name, p.id]},
45 - :selected => '-1' %>
46 - File: <%= file_field_tag 'file' %>
47 - <%= submit_tag 'Submit' %>
48 - <% end %>
49 - </div>
50 -
@@ -1,30 +1,36
1 1 <h1>Listing problems</h1>
2 2
3 3 <div class="usermenu">
4 4 <%= link_to 'Main', :controller => 'main', :action => 'list' %>
5 5 </div>
6 6
7 7 <table>
8 8 <tr>
9 - <% for column in Problem.content_columns %>
10 - <th><%= column.human_name %></th>
11 - <% end %>
9 + <th>Name</th>
10 + <th>Full name</th>
11 + <th>Full score</th>
12 + <th>Date added</th>
13 + <th>Available</th>
12 14 </tr>
13 15
14 16 <% for problem in @problems %>
15 17 <tr>
16 - <% for column in Problem.content_columns %>
17 - <td><%=h problem.send(column.name) %></td>
18 - <% end %>
18 + <% @problem=problem %>
19 + <td><%= in_place_editor_field :problem, :name, {}, :rows=>1 %>
20 + <td><%= in_place_editor_field :problem, :full_name, {}, :rows=>1 %>
21 + <td><%= in_place_editor_field :problem, :full_score, {}, :rows=>1 %>
22 + <td><%= problem.date_added %>
23 + <td><%= problem.available %>
24 +
19 25 <td><%= link_to '[Toggle]', :action => 'toggle_avail', :id => problem.id %></td>
20 26 <td><%= link_to '[Stat]', :action => 'stat', :id => problem.id %></td>
21 27 <td><%= link_to '[Show]', :action => 'show', :id => problem %></td>
22 28 <td><%= link_to '[Edit]', :action => 'edit', :id => problem %></td>
23 29 <td><%= link_to '[Destroy]', { :action => 'destroy', :id => problem }, :confirm => 'Are you sure?', :method => :post %></td>
24 30 </tr>
25 31 <% end %>
26 32 </table>
27 33
28 34
29 35 <br />
30 36
@@ -1,50 +1,60
1 1 p {
2 2 font-size: 12px;
3 3 }
4 4
5 + div.title {
6 + font-size: 20px;
7 + font-weight: bold;
8 + background: lightgreen;
9 + padding: 2px;
10 + }
11 +
5 12 div.problist-each {
6 13 margin-top: 2px;
7 14 margin-bottom: 2px
8 15 }
9 16
10 17 div.usermenu {
11 18 border-top: thin solid grey;
12 19 border-bottom: thin solid grey;
13 - text-align: right
20 + text-align: right;
21 + font-size: 12px;
14 22 }
15 23
16 24 div.probname {
17 25 background-color: #eeeeee;
18 26 font-weight: bold;
19 27 padding: 2px;
20 28 border: 1px solid black;
21 29 }
22 30
23 31 div.subinfo {
24 32 margin-left: 20px;
25 33 margin-top: 2px;
26 34 border-bottom: thin solid grey;
27 - border-left: thin solid grey
35 + border-left: thin solid grey;
36 + font-size: 12px;
28 37 }
29 38
30 39 div.compilermsgbody {
31 40 font-family: monospace;
32 41 }
33 42
34 43 div.submitbox {
35 44 border: thin solid black;
36 45 padding: 5px;
37 46 color: white;
38 47 background-color: #777777;
48 + font-weight: bold;
39 49 }
40 50
41 51
42 52 table.uinfo {
43 53 border-collapse: collapse;
44 54 border: 1px solid black;
45 55 font-size: 13px;
46 56 }
47 57
48 58
49 59 td.uinfo {
50 60 vertical-align: top;
You need to be logged in to leave comments. Login now