diff --git a/app/controllers/tasks_controller.rb b/app/controllers/tasks_controller.rb new file mode 100644 --- /dev/null +++ b/app/controllers/tasks_controller.rb @@ -0,0 +1,15 @@ +class TasksController < ApplicationController + + before_filter :authenticate + + + def index + redirect_to :action => 'list' + end + + def list + @problems = Problem.find_available_problems + @user = User.find(session[:user_id]) + end + +end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -18,6 +18,7 @@ # main page append_to menu_items, '[Main]', 'main', 'list' + append_to menu_items, '[Tasks]', 'tasks', 'list' append_to menu_items, '[Submissions]', 'main', 'submission' append_to menu_items, '[Test]', 'test', 'index' append_to menu_items, '[Settings]', 'users', 'index' diff --git a/app/helpers/tasks_helper.rb b/app/helpers/tasks_helper.rb new file mode 100644 --- /dev/null +++ b/app/helpers/tasks_helper.rb @@ -0,0 +1,2 @@ +module TasksHelper +end diff --git a/app/views/problems/_form.rhtml b/app/views/problems/_form.rhtml --- a/app/views/problems/_form.rhtml +++ b/app/views/problems/_form.rhtml @@ -13,6 +13,9 @@


<%= date_select 'problem', 'date_added' %>

+


+<%= text_area 'problem', 'body', :rows => 10 %>

+


<%= text_field 'problem', 'url' %>

diff --git a/app/views/problems/show.rhtml b/app/views/problems/show.rhtml --- a/app/views/problems/show.rhtml +++ b/app/views/problems/show.rhtml @@ -1,6 +1,13 @@ <% for column in Problem.content_columns %>

- <%= column.human_name %>: <%=h @problem.send(column.name) %> + <%= column.human_name %>: + <% if column.name != 'body' %> + <%=h @problem.send(column.name) %> + <% else %> +

+    <%= @problem.body %>
+    
+ <% end %>

<% end %> diff --git a/app/views/tasks/_problem.html.haml b/app/views/tasks/_problem.html.haml new file mode 100644 --- /dev/null +++ b/app/views/tasks/_problem.html.haml @@ -0,0 +1,5 @@ +%a{:name => problem.name} +%h3= "#{problem.full_name} (#{problem.name})" +%pre + %div{:style => "border: 1px solid grey; background: #eeeeee"} + = problem.body || "(not available)" diff --git a/app/views/tasks/list.html.haml b/app/views/tasks/list.html.haml new file mode 100644 --- /dev/null +++ b/app/views/tasks/list.html.haml @@ -0,0 +1,13 @@ += user_title_bar(@user) + +%h2 Task Listing + +%b Task: + +- @problems.each do |problem| + - if problem.body!=nil + %a{:href => "\##{problem.name}"} + = problem.full_name +   + += render :partial => 'problem', :collection => @problems diff --git a/db/migrate/026_add_body_to_problems.rb b/db/migrate/026_add_body_to_problems.rb new file mode 100644 --- /dev/null +++ b/db/migrate/026_add_body_to_problems.rb @@ -0,0 +1,9 @@ +class AddBodyToProblems < ActiveRecord::Migration + def self.up + add_column :problems, :body, :text + end + + def self.down + remove_column :problems, :body + end +end diff --git a/db/schema.rb b/db/schema.rb --- a/db/schema.rb +++ b/db/schema.rb @@ -9,7 +9,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 25) do +ActiveRecord::Schema.define(:version => 26) do create_table "configurations", :force => true do |t| t.string "key" @@ -44,6 +44,7 @@ t.date "date_added" t.boolean "available" t.string "url" + t.text "body" end create_table "rights", :force => true do |t| diff --git a/test/functional/tasks_controller_test.rb b/test/functional/tasks_controller_test.rb new file mode 100644 --- /dev/null +++ b/test/functional/tasks_controller_test.rb @@ -0,0 +1,8 @@ +require File.dirname(__FILE__) + '/../test_helper' + +class TasksControllerTest < ActionController::TestCase + # Replace this with your real tests. + def test_truth + assert true + end +end