Description:
[web] added body to problems, added task view page
git-svn-id: http://theory.cpe.ku.ac.th/grader/web/trunk@174 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
r88:61ad7e926318 - - 10 files changed: 66 inserted, 2 deleted
@@ -0,0 +1,15 | |||||
|
|
1 | + class TasksController < ApplicationController | ||
|
|
2 | + | ||
|
|
3 | + before_filter :authenticate | ||
|
|
4 | + | ||
|
|
5 | + | ||
|
|
6 | + def index | ||
|
|
7 | + redirect_to :action => 'list' | ||
|
|
8 | + end | ||
|
|
9 | + | ||
|
|
10 | + def list | ||
|
|
11 | + @problems = Problem.find_available_problems | ||
|
|
12 | + @user = User.find(session[:user_id]) | ||
|
|
13 | + end | ||
|
|
14 | + | ||
|
|
15 | + end |
@@ -0,0 +1,5 | |||||
|
|
1 | + %a{:name => problem.name} | ||
|
|
2 | + %h3= "#{problem.full_name} (#{problem.name})" | ||
|
|
3 | + %pre | ||
|
|
4 | + %div{:style => "border: 1px solid grey; background: #eeeeee"} | ||
|
|
5 | + = problem.body || "(not available)" |
@@ -0,0 +1,13 | |||||
|
|
1 | + = user_title_bar(@user) | ||
|
|
2 | + | ||
|
|
3 | + %h2 Task Listing | ||
|
|
4 | + | ||
|
|
5 | + %b Task: | ||
|
|
6 | + | ||
|
|
7 | + - @problems.each do |problem| | ||
|
|
8 | + - if problem.body!=nil | ||
|
|
9 | + %a{:href => "\##{problem.name}"} | ||
|
|
10 | + = problem.full_name | ||
|
|
11 | +   | ||
|
|
12 | + | ||
|
|
13 | + = render :partial => 'problem', :collection => @problems |
@@ -0,0 +1,9 | |||||
|
|
1 | + class AddBodyToProblems < ActiveRecord::Migration | ||
|
|
2 | + def self.up | ||
|
|
3 | + add_column :problems, :body, :text | ||
|
|
4 | + end | ||
|
|
5 | + | ||
|
|
6 | + def self.down | ||
|
|
7 | + remove_column :problems, :body | ||
|
|
8 | + end | ||
|
|
9 | + end |
@@ -0,0 +1,8 | |||||
|
|
1 | + require File.dirname(__FILE__) + '/../test_helper' | ||
|
|
2 | + | ||
|
|
3 | + class TasksControllerTest < ActionController::TestCase | ||
|
|
4 | + # Replace this with your real tests. | ||
|
|
5 | + def test_truth | ||
|
|
6 | + assert true | ||
|
|
7 | + end | ||
|
|
8 | + end |
@@ -1,71 +1,72 | |||||
|
1 | # Methods added to this helper will be available to all templates in the application. |
|
1 | # Methods added to this helper will be available to all templates in the application. |
|
2 | module ApplicationHelper |
|
2 | module ApplicationHelper |
|
3 |
|
3 | ||
|
4 | def user_header |
|
4 | def user_header |
|
5 | menu_items = '' |
|
5 | menu_items = '' |
|
6 | user = User.find(session[:user_id]) |
|
6 | user = User.find(session[:user_id]) |
|
7 |
|
7 | ||
|
8 | if (user!=nil) and (user.admin?) |
|
8 | if (user!=nil) and (user.admin?) |
|
9 | # admin menu |
|
9 | # admin menu |
|
10 | menu_items << "<b>Administrative task:</b> " |
|
10 | menu_items << "<b>Administrative task:</b> " |
|
11 | append_to menu_items, '[Problem admin]', 'problems', 'index' |
|
11 | append_to menu_items, '[Problem admin]', 'problems', 'index' |
|
12 | append_to menu_items, '[User admin]', 'user_admin', 'index' |
|
12 | append_to menu_items, '[User admin]', 'user_admin', 'index' |
|
13 | append_to menu_items, '[User stat]', 'user_admin', 'user_stat' |
|
13 | append_to menu_items, '[User stat]', 'user_admin', 'user_stat' |
|
14 | #append_to menu_items, '[Graders]', 'graders', 'list' |
|
14 | #append_to menu_items, '[Graders]', 'graders', 'list' |
|
15 | append_to menu_items, '[Site config]', 'configurations', 'index' |
|
15 | append_to menu_items, '[Site config]', 'configurations', 'index' |
|
16 | menu_items << "<br/>" |
|
16 | menu_items << "<br/>" |
|
17 | end |
|
17 | end |
|
18 |
|
18 | ||
|
19 | # main page |
|
19 | # main page |
|
20 | append_to menu_items, '[Main]', 'main', 'list' |
|
20 | append_to menu_items, '[Main]', 'main', 'list' |
|
|
21 | + append_to menu_items, '[Tasks]', 'tasks', 'list' | ||
|
21 | append_to menu_items, '[Submissions]', 'main', 'submission' |
|
22 | append_to menu_items, '[Submissions]', 'main', 'submission' |
|
22 | append_to menu_items, '[Test]', 'test', 'index' |
|
23 | append_to menu_items, '[Test]', 'test', 'index' |
|
23 | append_to menu_items, '[Settings]', 'users', 'index' |
|
24 | append_to menu_items, '[Settings]', 'users', 'index' |
|
24 | append_to menu_items, '[Log out]', 'main', 'login' |
|
25 | append_to menu_items, '[Log out]', 'main', 'login' |
|
25 |
|
26 | ||
|
26 | menu_items |
|
27 | menu_items |
|
27 | end |
|
28 | end |
|
28 |
|
29 | ||
|
29 | def append_to(option,label, controller, action) |
|
30 | def append_to(option,label, controller, action) |
|
30 | option << ' ' if option!='' |
|
31 | option << ' ' if option!='' |
|
31 | option << link_to_unless_current(label, |
|
32 | option << link_to_unless_current(label, |
|
32 | :controller => controller, |
|
33 | :controller => controller, |
|
33 | :action => action) |
|
34 | :action => action) |
|
34 | end |
|
35 | end |
|
35 |
|
36 | ||
|
36 | def format_short_time(time) |
|
37 | def format_short_time(time) |
|
37 | now = Time.now |
|
38 | now = Time.now |
|
38 | st = '' |
|
39 | st = '' |
|
39 | if (time.yday != now.yday) or |
|
40 | if (time.yday != now.yday) or |
|
40 | (time.year != now.year) |
|
41 | (time.year != now.year) |
|
41 | st = time.strftime("%x ") |
|
42 | st = time.strftime("%x ") |
|
42 | end |
|
43 | end |
|
43 | st + time.strftime("%X") |
|
44 | st + time.strftime("%X") |
|
44 | end |
|
45 | end |
|
45 |
|
46 | ||
|
46 |
|
47 | ||
|
47 | def user_title_bar(user) |
|
48 | def user_title_bar(user) |
|
48 | if user.site!=nil and user.site.finished? |
|
49 | if user.site!=nil and user.site.finished? |
|
49 | contest_over_string = <<CONTEST_OVER |
|
50 | contest_over_string = <<CONTEST_OVER |
|
50 | <tr><td colspan="2" align="center"> |
|
51 | <tr><td colspan="2" align="center"> |
|
51 | <span class="contest-over-msg">THE CONTEST IS OVER</span> |
|
52 | <span class="contest-over-msg">THE CONTEST IS OVER</span> |
|
52 | </td></tr> |
|
53 | </td></tr> |
|
53 | CONTEST_OVER |
|
54 | CONTEST_OVER |
|
54 | end |
|
55 | end |
|
55 | <<TITLEBAR |
|
56 | <<TITLEBAR |
|
56 | <div class="title"> |
|
57 | <div class="title"> |
|
57 | <table> |
|
58 | <table> |
|
58 | #{contest_over_string} |
|
59 | #{contest_over_string} |
|
59 | <tr> |
|
60 | <tr> |
|
60 | <td class="left-col"> |
|
61 | <td class="left-col"> |
|
61 | #{user.full_name}<br/> |
|
62 | #{user.full_name}<br/> |
|
62 | Current time is #{format_short_time(Time.new)}<br/> |
|
63 | Current time is #{format_short_time(Time.new)}<br/> |
|
63 | </td> |
|
64 | </td> |
|
64 | <td class="right-col">APIO'08</td> |
|
65 | <td class="right-col">APIO'08</td> |
|
65 | </tr> |
|
66 | </tr> |
|
66 | </table> |
|
67 | </table> |
|
67 | </div> |
|
68 | </div> |
|
68 | TITLEBAR |
|
69 | TITLEBAR |
|
69 | end |
|
70 | end |
|
70 |
|
71 | ||
|
71 | end |
|
72 | end |
@@ -1,22 +1,25 | |||||
|
1 | <%= error_messages_for 'problem' %> |
|
1 | <%= error_messages_for 'problem' %> |
|
2 |
|
2 | ||
|
3 | <!--[form:problem]--> |
|
3 | <!--[form:problem]--> |
|
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_body">Body</label><br/> | ||
|
|
17 | + <%= text_area 'problem', 'body', :rows => 10 %></p> | ||
|
|
18 | + | ||
|
16 | <p><label for="problem_url">URL</label><br/> |
|
19 | <p><label for="problem_url">URL</label><br/> |
|
17 | <%= text_field 'problem', 'url' %></p> |
|
20 | <%= text_field 'problem', 'url' %></p> |
|
18 |
|
21 | ||
|
19 | <p><label for="problem_available">Available</label><br/> |
|
22 | <p><label for="problem_available">Available</label><br/> |
|
20 | <%= select("problem","available",[['True',true],['False',false]]) %></p> |
|
23 | <%= select("problem","available",[['True',true],['False',false]]) %></p> |
|
21 | <!--[eoform:problem]--> |
|
24 | <!--[eoform:problem]--> |
|
22 |
|
25 |
@@ -1,8 +1,15 | |||||
|
1 | <% for column in Problem.content_columns %> |
|
1 | <% for column in Problem.content_columns %> |
|
2 | <p> |
|
2 | <p> |
|
3 |
- <b><%= column.human_name %>:</b> |
|
3 | + <b><%= column.human_name %>:</b> |
|
|
4 | + <% if column.name != 'body' %> | ||
|
|
5 | + <%=h @problem.send(column.name) %> | ||
|
|
6 | + <% else %> | ||
|
|
7 | + <pre> | ||
|
|
8 | + <%= @problem.body %> | ||
|
|
9 | + </pre> | ||
|
|
10 | + <% end %> | ||
|
4 | </p> |
|
11 | </p> |
|
5 | <% end %> |
|
12 | <% end %> |
|
6 |
|
13 | ||
|
7 | <%= link_to 'Edit', :action => 'edit', :id => @problem %> | |
|
14 | <%= link_to 'Edit', :action => 'edit', :id => @problem %> | |
|
8 | <%= link_to 'Back', :action => 'list' %> |
|
15 | <%= link_to 'Back', :action => 'list' %> |
@@ -1,142 +1,143 | |||||
|
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 => 2 |
|
12 | + ActiveRecord::Schema.define(:version => 26) 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 "grader_processes", :force => true do |t| |
|
22 | create_table "grader_processes", :force => true do |t| |
|
23 | t.string "host", :limit => 20 |
|
23 | t.string "host", :limit => 20 |
|
24 | t.integer "pid" |
|
24 | t.integer "pid" |
|
25 | t.string "mode" |
|
25 | t.string "mode" |
|
26 | t.boolean "active" |
|
26 | t.boolean "active" |
|
27 | t.datetime "created_at" |
|
27 | t.datetime "created_at" |
|
28 | t.datetime "updated_at" |
|
28 | t.datetime "updated_at" |
|
29 | t.integer "task_id" |
|
29 | t.integer "task_id" |
|
30 | end |
|
30 | end |
|
31 |
|
31 | ||
|
32 | add_index "grader_processes", ["host", "pid"], :name => "index_grader_processes_on_ip_and_pid" |
|
32 | add_index "grader_processes", ["host", "pid"], :name => "index_grader_processes_on_ip_and_pid" |
|
33 |
|
33 | ||
|
34 | create_table "languages", :force => true do |t| |
|
34 | create_table "languages", :force => true do |t| |
|
35 | t.string "name", :limit => 10 |
|
35 | t.string "name", :limit => 10 |
|
36 | t.string "pretty_name" |
|
36 | t.string "pretty_name" |
|
37 | t.string "ext", :limit => 10 |
|
37 | t.string "ext", :limit => 10 |
|
38 | end |
|
38 | end |
|
39 |
|
39 | ||
|
40 | create_table "problems", :force => true do |t| |
|
40 | create_table "problems", :force => true do |t| |
|
41 | t.string "name", :limit => 30 |
|
41 | t.string "name", :limit => 30 |
|
42 | t.string "full_name" |
|
42 | t.string "full_name" |
|
43 | t.integer "full_score" |
|
43 | t.integer "full_score" |
|
44 | t.date "date_added" |
|
44 | t.date "date_added" |
|
45 | t.boolean "available" |
|
45 | t.boolean "available" |
|
46 | t.string "url" |
|
46 | t.string "url" |
|
|
47 | + t.text "body" | ||
|
47 | end |
|
48 | end |
|
48 |
|
49 | ||
|
49 | create_table "rights", :force => true do |t| |
|
50 | create_table "rights", :force => true do |t| |
|
50 | t.string "name" |
|
51 | t.string "name" |
|
51 | t.string "controller" |
|
52 | t.string "controller" |
|
52 | t.string "action" |
|
53 | t.string "action" |
|
53 | end |
|
54 | end |
|
54 |
|
55 | ||
|
55 | create_table "rights_roles", :id => false, :force => true do |t| |
|
56 | create_table "rights_roles", :id => false, :force => true do |t| |
|
56 | t.integer "right_id" |
|
57 | t.integer "right_id" |
|
57 | t.integer "role_id" |
|
58 | t.integer "role_id" |
|
58 | end |
|
59 | end |
|
59 |
|
60 | ||
|
60 | add_index "rights_roles", ["role_id"], :name => "index_rights_roles_on_role_id" |
|
61 | add_index "rights_roles", ["role_id"], :name => "index_rights_roles_on_role_id" |
|
61 |
|
62 | ||
|
62 | create_table "roles", :force => true do |t| |
|
63 | create_table "roles", :force => true do |t| |
|
63 | t.string "name" |
|
64 | t.string "name" |
|
64 | end |
|
65 | end |
|
65 |
|
66 | ||
|
66 | create_table "roles_users", :id => false, :force => true do |t| |
|
67 | create_table "roles_users", :id => false, :force => true do |t| |
|
67 | t.integer "role_id" |
|
68 | t.integer "role_id" |
|
68 | t.integer "user_id" |
|
69 | t.integer "user_id" |
|
69 | end |
|
70 | end |
|
70 |
|
71 | ||
|
71 | add_index "roles_users", ["user_id"], :name => "index_roles_users_on_user_id" |
|
72 | add_index "roles_users", ["user_id"], :name => "index_roles_users_on_user_id" |
|
72 |
|
73 | ||
|
73 | create_table "sessions", :force => true do |t| |
|
74 | create_table "sessions", :force => true do |t| |
|
74 | t.string "session_id" |
|
75 | t.string "session_id" |
|
75 | t.text "data" |
|
76 | t.text "data" |
|
76 | t.datetime "updated_at" |
|
77 | t.datetime "updated_at" |
|
77 | end |
|
78 | end |
|
78 |
|
79 | ||
|
79 | add_index "sessions", ["session_id"], :name => "index_sessions_on_session_id" |
|
80 | add_index "sessions", ["session_id"], :name => "index_sessions_on_session_id" |
|
80 | add_index "sessions", ["updated_at"], :name => "index_sessions_on_updated_at" |
|
81 | add_index "sessions", ["updated_at"], :name => "index_sessions_on_updated_at" |
|
81 |
|
82 | ||
|
82 | create_table "sites", :force => true do |t| |
|
83 | create_table "sites", :force => true do |t| |
|
83 | t.string "name" |
|
84 | t.string "name" |
|
84 | t.boolean "started" |
|
85 | t.boolean "started" |
|
85 | t.datetime "start_time" |
|
86 | t.datetime "start_time" |
|
86 | t.datetime "created_at" |
|
87 | t.datetime "created_at" |
|
87 | t.datetime "updated_at" |
|
88 | t.datetime "updated_at" |
|
88 | end |
|
89 | end |
|
89 |
|
90 | ||
|
90 | create_table "submissions", :force => true do |t| |
|
91 | create_table "submissions", :force => true do |t| |
|
91 | t.integer "user_id" |
|
92 | t.integer "user_id" |
|
92 | t.integer "problem_id" |
|
93 | t.integer "problem_id" |
|
93 | t.integer "language_id" |
|
94 | t.integer "language_id" |
|
94 | t.text "source" |
|
95 | t.text "source" |
|
95 | t.binary "binary" |
|
96 | t.binary "binary" |
|
96 | t.datetime "submitted_at" |
|
97 | t.datetime "submitted_at" |
|
97 | t.datetime "compiled_at" |
|
98 | t.datetime "compiled_at" |
|
98 | t.text "compiler_message" |
|
99 | t.text "compiler_message" |
|
99 | t.datetime "graded_at" |
|
100 | t.datetime "graded_at" |
|
100 | t.integer "points" |
|
101 | t.integer "points" |
|
101 | t.text "grader_comment" |
|
102 | t.text "grader_comment" |
|
102 | t.integer "number" |
|
103 | t.integer "number" |
|
103 | end |
|
104 | end |
|
104 |
|
105 | ||
|
105 | add_index "submissions", ["user_id", "problem_id", "number"], :name => "index_submissions_on_user_id_and_problem_id_and_number", :unique => true |
|
106 | add_index "submissions", ["user_id", "problem_id", "number"], :name => "index_submissions_on_user_id_and_problem_id_and_number", :unique => true |
|
106 | add_index "submissions", ["user_id", "problem_id"], :name => "index_submissions_on_user_id_and_problem_id" |
|
107 | add_index "submissions", ["user_id", "problem_id"], :name => "index_submissions_on_user_id_and_problem_id" |
|
107 |
|
108 | ||
|
108 | create_table "tasks", :force => true do |t| |
|
109 | create_table "tasks", :force => true do |t| |
|
109 | t.integer "submission_id" |
|
110 | t.integer "submission_id" |
|
110 | t.datetime "created_at" |
|
111 | t.datetime "created_at" |
|
111 | t.integer "status" |
|
112 | t.integer "status" |
|
112 | t.datetime "updated_at" |
|
113 | t.datetime "updated_at" |
|
113 | end |
|
114 | end |
|
114 |
|
115 | ||
|
115 | create_table "test_requests", :force => true do |t| |
|
116 | create_table "test_requests", :force => true do |t| |
|
116 | t.integer "user_id" |
|
117 | t.integer "user_id" |
|
117 | t.integer "problem_id" |
|
118 | t.integer "problem_id" |
|
118 | t.integer "submission_id" |
|
119 | t.integer "submission_id" |
|
119 | t.string "input_file_name" |
|
120 | t.string "input_file_name" |
|
120 | t.string "output_file_name" |
|
121 | t.string "output_file_name" |
|
121 | t.string "running_stat" |
|
122 | t.string "running_stat" |
|
122 | t.integer "status" |
|
123 | t.integer "status" |
|
123 | t.datetime "updated_at" |
|
124 | t.datetime "updated_at" |
|
124 | t.datetime "submitted_at" |
|
125 | t.datetime "submitted_at" |
|
125 | t.datetime "compiled_at" |
|
126 | t.datetime "compiled_at" |
|
126 | t.text "compiler_message" |
|
127 | t.text "compiler_message" |
|
127 | t.datetime "graded_at" |
|
128 | t.datetime "graded_at" |
|
128 | t.string "grader_comment" |
|
129 | t.string "grader_comment" |
|
129 | t.datetime "created_at" |
|
130 | t.datetime "created_at" |
|
130 | t.float "running_time" |
|
131 | t.float "running_time" |
|
131 | t.string "exit_status" |
|
132 | t.string "exit_status" |
|
132 | t.integer "memory_usage" |
|
133 | t.integer "memory_usage" |
|
133 | end |
|
134 | end |
|
134 |
|
135 | ||
|
135 | add_index "test_requests", ["user_id", "problem_id"], :name => "index_test_requests_on_user_id_and_problem_id" |
|
136 | add_index "test_requests", ["user_id", "problem_id"], :name => "index_test_requests_on_user_id_and_problem_id" |
|
136 |
|
137 | ||
|
137 | create_table "users", :force => true do |t| |
|
138 | create_table "users", :force => true do |t| |
|
138 | t.string "login", :limit => 10 |
|
139 | t.string "login", :limit => 10 |
|
139 | t.string "full_name" |
|
140 | t.string "full_name" |
|
140 | t.string "hashed_password" |
|
141 | t.string "hashed_password" |
|
141 | t.string "salt", :limit => 5 |
|
142 | t.string "salt", :limit => 5 |
|
142 | t.string "alias" |
|
143 | t.string "alias" |
You need to be logged in to leave comments.
Login now