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