Description:
[web] added test_allowed flag to problems git-svn-id: http://theory.cpe.ku.ac.th/grader/web/trunk@181 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

r94:c175b74a31f0 - - 4 files changed: 24 inserted, 10 deleted

@@ -73,17 +73,23
73 if @test_request==nil or @test_request.user_id != @user.id
73 if @test_request==nil or @test_request.user_id != @user.id
74 flash[:notice] = 'Invalid request'
74 flash[:notice] = 'Invalid request'
75 redirect_to :action => 'index'
75 redirect_to :action => 'index'
76 return
76 return
77 end
77 end
78 end
78 end
79
79
80 protected
80 protected
81
81
82 def prepare_index_information
82 def prepare_index_information
83 @user = User.find(session[:user_id])
83 @user = User.find(session[:user_id])
84 @submissions = Submission.find_last_for_all_available_problems(@user.id)
84 @submissions = Submission.find_last_for_all_available_problems(@user.id)
85 - @problems = @submissions.collect { |submission| submission.problem }
85 + all_problems = @submissions.collect { |submission| submission.problem }
86 + @problems = []
87 + all_problems.each do |problem|
88 + if problem.test_allowed
89 + @problems << problem
90 + end
91 + end
86 @test_requests = @user.test_requests
92 @test_requests = @user.test_requests
87 end
93 end
88
94
89 end
95 end
@@ -4,30 +4,35
4 <p><label for="problem_name">Name</label><br/>
4 <p><label for="problem_name">Name</label><br/>
5 <%= text_field 'problem', 'name' %></p>
5 <%= text_field 'problem', 'name' %></p>
6
6
7 <p><label for="problem_full_name">Full name</label><br/>
7 <p><label for="problem_full_name">Full name</label><br/>
8 <%= text_field 'problem', 'full_name' %></p>
8 <%= text_field 'problem', 'full_name' %></p>
9
9
10 <p><label for="problem_full_score">Full score</label><br/>
10 <p><label for="problem_full_score">Full score</label><br/>
11 <%= text_field 'problem', 'full_score' %></p>
11 <%= text_field 'problem', 'full_score' %></p>
12
12
13 <p><label for="problem_date_added">Date added</label><br/>
13 <p><label for="problem_date_added">Date added</label><br/>
14 <%= date_select 'problem', 'date_added' %></p>
14 <%= date_select 'problem', 'date_added' %></p>
15
15
16 + <p><label for="problem_available">Available?</label>
17 + <%= select("problem","available",[['True',true],['False',false]]) %></p>
18 +
19 + <p><label for="problem_test_allowed">Test allowed?</label>
20 + <%= select("problem","test_allowed",[['True',true],['False',false]]) %></p>
21 +
16 <%= error_messages_for 'description' %>
22 <%= error_messages_for 'description' %>
17
23
18 <p><label for="description_body">Description</label><br/>
24 <p><label for="description_body">Description</label><br/>
19 <%= text_area :description, :body, :rows => 10, :cols => 80 %></p>
25 <%= text_area :description, :body, :rows => 10, :cols => 80 %></p>
20
26
21 <p><label for="description_markdowned">Markdowned?</label>
27 <p><label for="description_markdowned">Markdowned?</label>
22 <%= select "description",
28 <%= select "description",
23 "markdowned",
29 "markdowned",
24 [['True',true],['False',false]],
30 [['True',true],['False',false]],
25 {:selected => (@description) ? @description.markdowned : false }
31 {:selected => (@description) ? @description.markdowned : false }
26 %></p>
32 %></p>
27
33
28 <p><label for="problem_url">URL</label><br/>
34 <p><label for="problem_url">URL</label><br/>
29 <%= text_field 'problem', 'url' %></p>
35 <%= text_field 'problem', 'url' %></p>
30
36
31 - <p><label for="problem_available">Available</label><br/>
37 +
32 - <%= select("problem","available",[['True',true],['False',false]]) %></p>
33 <!--[eoform:problem]-->
38 <!--[eoform:problem]-->
@@ -6,35 +6,37
6
6
7 <h1>Listing problems</h1>
7 <h1>Listing problems</h1>
8
8
9 <%= link_to 'New problem', :action => 'new' %>
9 <%= link_to 'New problem', :action => 'new' %>
10 <%= link_to 'Turn off all problems', :action => 'turn_all_off' %><br/>
10 <%= link_to 'Turn off all problems', :action => 'turn_all_off' %><br/>
11
11
12 <table>
12 <table>
13 <tr>
13 <tr>
14 <th>Name</th>
14 <th>Name</th>
15 <th>Full name</th>
15 <th>Full name</th>
16 <th>Full score</th>
16 <th>Full score</th>
17 <th>Date added</th>
17 <th>Date added</th>
18 - <th>Available</th>
18 + <th>Avail?</th>
19 + <th>Test?</th>
19 </tr>
20 </tr>
20
21
21 <% for problem in @problems %>
22 <% for problem in @problems %>
22 <tr class="<%= (problem.available) ? "available" : "not-available" %>">
23 <tr class="<%= (problem.available) ? "available" : "not-available" %>">
23 <% @problem=problem %>
24 <% @problem=problem %>
24 - <td><%= in_place_editor_field :problem, :name, {}, :rows=>1 %>
25 + <td><%= in_place_editor_field :problem, :name, {}, :rows=>1 %></td>
25 - <td><%= in_place_editor_field :problem, :full_name, {}, :rows=>1 %>
26 + <td><%= in_place_editor_field :problem, :full_name, {}, :rows=>1 %></td>
26 - <td><%= in_place_editor_field :problem, :full_score, {}, :rows=>1 %>
27 + <td><%= in_place_editor_field :problem, :full_score, {}, :rows=>1 %></td>
27 - <td><%= problem.date_added %>
28 + <td><%= problem.date_added %></td>
28 - <td><%= problem.available %>
29 + <td><%= problem.available %></td>
30 + <td><%= problem.test_allowed %></td>
29
31
30 <td><%= link_to '[Toggle]', :action => 'toggle_avail', :id => problem.id %></td>
32 <td><%= link_to '[Toggle]', :action => 'toggle_avail', :id => problem.id %></td>
31 <td><%= link_to '[Stat]', :action => 'stat', :id => problem.id %></td>
33 <td><%= link_to '[Stat]', :action => 'stat', :id => problem.id %></td>
32 <td><%= link_to '[Show]', :action => 'show', :id => problem %></td>
34 <td><%= link_to '[Show]', :action => 'show', :id => problem %></td>
33 <td><%= link_to '[Edit]', :action => 'edit', :id => problem %></td>
35 <td><%= link_to '[Edit]', :action => 'edit', :id => problem %></td>
34 <td><%= link_to '[Destroy]', { :action => 'destroy', :id => problem }, :confirm => 'Are you sure?', :method => :post %></td>
36 <td><%= link_to '[Destroy]', { :action => 'destroy', :id => problem }, :confirm => 'Are you sure?', :method => :post %></td>
35 </tr>
37 </tr>
36 <% end %>
38 <% end %>
37 </table>
39 </table>
38
40
39
41
40 <br />
42 <br />
@@ -1,24 +1,24
1 # This file is auto-generated from the current state of the database. Instead of editing this file,
1 # This file is auto-generated from the current state of the database. Instead of editing this file,
2 # please use the migrations feature of ActiveRecord to incrementally modify your database, and
2 # please use the migrations feature of ActiveRecord to incrementally modify your database, and
3 # then regenerate this schema definition.
3 # then regenerate this schema definition.
4 #
4 #
5 # Note that this schema.rb definition is the authoritative source for your database schema. If you need
5 # Note that this schema.rb definition is the authoritative source for your database schema. If you need
6 # to create the application database on another system, you should be using db:schema:load, not running
6 # to create the application database on another system, you should be using db:schema:load, not running
7 # all the migrations from scratch. The latter is a flawed and unsustainable approach (the more migrations
7 # all the migrations from scratch. The latter is a flawed and unsustainable approach (the more migrations
8 # you'll amass, the slower it'll run and the greater likelihood for issues).
8 # you'll amass, the slower it'll run and the greater likelihood for issues).
9 #
9 #
10 # It's strongly recommended to check this file into your version control system.
10 # It's strongly recommended to check this file into your version control system.
11
11
12 - ActiveRecord::Schema.define(:version => 28) do
12 + ActiveRecord::Schema.define(:version => 29) do
13
13
14 create_table "configurations", :force => true do |t|
14 create_table "configurations", :force => true do |t|
15 t.string "key"
15 t.string "key"
16 t.string "value_type"
16 t.string "value_type"
17 t.string "value"
17 t.string "value"
18 t.datetime "created_at"
18 t.datetime "created_at"
19 t.datetime "updated_at"
19 t.datetime "updated_at"
20 end
20 end
21
21
22 create_table "descriptions", :force => true do |t|
22 create_table "descriptions", :force => true do |t|
23 t.text "body"
23 t.text "body"
24 t.boolean "markdowned"
24 t.boolean "markdowned"
@@ -43,24 +43,25
43 t.string "pretty_name"
43 t.string "pretty_name"
44 t.string "ext", :limit => 10
44 t.string "ext", :limit => 10
45 end
45 end
46
46
47 create_table "problems", :force => true do |t|
47 create_table "problems", :force => true do |t|
48 t.string "name", :limit => 30
48 t.string "name", :limit => 30
49 t.string "full_name"
49 t.string "full_name"
50 t.integer "full_score"
50 t.integer "full_score"
51 t.date "date_added"
51 t.date "date_added"
52 t.boolean "available"
52 t.boolean "available"
53 t.string "url"
53 t.string "url"
54 t.integer "description_id"
54 t.integer "description_id"
55 + t.boolean "test_allowed"
55 end
56 end
56
57
57 create_table "rights", :force => true do |t|
58 create_table "rights", :force => true do |t|
58 t.string "name"
59 t.string "name"
59 t.string "controller"
60 t.string "controller"
60 t.string "action"
61 t.string "action"
61 end
62 end
62
63
63 create_table "rights_roles", :id => false, :force => true do |t|
64 create_table "rights_roles", :id => false, :force => true do |t|
64 t.integer "right_id"
65 t.integer "right_id"
65 t.integer "role_id"
66 t.integer "role_id"
66 end
67 end
You need to be logged in to leave comments. Login now