添加课程index界面
This commit is contained in:
parent
77006198a1
commit
e490f7979d
|
@ -70,81 +70,81 @@ class CoursesController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
def course12
|
def index
|
||||||
@project_type = params[:project_type]
|
@course_type = params[:course_type]
|
||||||
@school_id = params[:school_id]
|
@school_id = params[:school_id]
|
||||||
per_page_option = 10
|
per_page_option = 10
|
||||||
if @school_id == "0" or @school_id.nil?
|
if @school_id == "0" or @school_id.nil?
|
||||||
@projects_all = Project.active.visible.
|
@courses_all = Project.active.visible.
|
||||||
joins("LEFT JOIN #{ProjectStatus.table_name} ON #{Project.table_name}.id = #{ProjectStatus.table_name}.project_id").
|
joins("LEFT JOIN #{ProjectStatus.table_name} ON #{Project.table_name}.id = #{ProjectStatus.table_name}.course_id").
|
||||||
where("#{Project.table_name}.project_type = ? ", Project::ProjectType_course)
|
where("#{Project.table_name}.course_type = ? ", Project::ProjectType_course)
|
||||||
else
|
else
|
||||||
@projects_all = Project.active.visible.
|
@courses_all = Project.active.visible.
|
||||||
joins("LEFT JOIN #{ProjectStatus.table_name} ON #{Project.table_name}.id = #{ProjectStatus.table_name}.project_id").
|
joins("LEFT JOIN #{ProjectStatus.table_name} ON #{Project.table_name}.id = #{ProjectStatus.table_name}.course_id").
|
||||||
joins(:course_extra).
|
joins(:course_extra).
|
||||||
where("#{Project.table_name}.project_type = ? AND #{Course.table_name}.school_id = ?", Project::ProjectType_course, @school_id)
|
where("#{Project.table_name}.course_type = ? AND #{Course.table_name}.school_id = ?", Project::ProjectType_course, @school_id)
|
||||||
end
|
end
|
||||||
|
|
||||||
@project_count = @projects_all.count
|
@course_count = @courses_all.count
|
||||||
@project_pages = Paginator.new @project_count, per_page_option, params['page']
|
@course_pages = Paginator.new @course_count, per_page_option, params['page']
|
||||||
|
|
||||||
#gcm activity count
|
#gcm activity count
|
||||||
|
|
||||||
@project_activity_count=Hash.new
|
@course_activity_count=Hash.new
|
||||||
#count initialize
|
#count initialize
|
||||||
@projects_all.each do |project|
|
@courses_all.each do |course|
|
||||||
@project_activity_count[project.id]=0
|
@course_activity_count[course.id]=0
|
||||||
end
|
end
|
||||||
|
|
||||||
#@project_activity_count=get_project_activity @projects_all,@project_activity_count
|
#@course_activity_count=get_course_activity @courses_all,@course_activity_count
|
||||||
#gcm end
|
#gcm end
|
||||||
|
|
||||||
|
|
||||||
case params[:project_sort_type]
|
case params[:course_sort_type]
|
||||||
when '0'
|
when '0'
|
||||||
@projects = @projects_all.order("created_on desc")
|
@courses = @courses_all.order("created_on desc")
|
||||||
@s_type = 0
|
@s_type = 0
|
||||||
@projects = @projects.offset(@project_pages.offset).limit(@project_pages.per_page)
|
@courses = @courses.offset(@course_pages.offset).limit(@course_pages.per_page)
|
||||||
|
|
||||||
#gcm
|
#gcm
|
||||||
@project_activity_count=get_project_activity @projects,@project_activity_count
|
@course_activity_count=get_course_activity @courses,@course_activity_count
|
||||||
#gcmend
|
#gcmend
|
||||||
|
|
||||||
when '1'
|
when '1'
|
||||||
@projects = @projects_all.order("course_ac_para desc")
|
@courses = @courses_all.order("course_ac_para desc")
|
||||||
@s_type = 1
|
@s_type = 1
|
||||||
@projects = @projects.offset(@project_pages.offset).limit(@project_pages.per_page)
|
@courses = @courses.offset(@course_pages.offset).limit(@course_pages.per_page)
|
||||||
|
|
||||||
#gcm
|
#gcm
|
||||||
@project_activity_count=get_project_activity @projects,@project_activity_count
|
@course_activity_count=get_course_activity @courses,@course_activity_count
|
||||||
#gcmend
|
#gcmend
|
||||||
|
|
||||||
when '2'
|
when '2'
|
||||||
@projects = @projects_all.order("watchers_count desc")
|
@courses = @courses_all.order("watchers_count desc")
|
||||||
@s_type = 2
|
@s_type = 2
|
||||||
@projects = @projects.offset(@project_pages.offset).limit(@project_pages.per_page)
|
@courses = @courses.offset(@course_pages.offset).limit(@course_pages.per_page)
|
||||||
|
|
||||||
#gcm
|
#gcm
|
||||||
@project_activity_count=get_project_activity @projects,@project_activity_count
|
@course_activity_count=get_course_activity @courses,@course_activity_count
|
||||||
#gcmend
|
#gcmend
|
||||||
|
|
||||||
#gcm
|
#gcm
|
||||||
when '3'
|
when '3'
|
||||||
|
|
||||||
#gcm
|
#gcm
|
||||||
@project_activity_count=get_project_activity @projects_all,@project_activity_count
|
@course_activity_count=get_course_activity @courses_all,@course_activity_count
|
||||||
#gcmend
|
#gcmend
|
||||||
|
|
||||||
@projects=handle_project @projects_all,@project_activity_count
|
@courses=handle_course @courses_all,@course_activity_count
|
||||||
@s_type = 3
|
@s_type = 3
|
||||||
@projects = @projects[@project_pages.offset, @project_pages.per_page]
|
@courses = @courses[@course_pages.offset, @course_pages.per_page]
|
||||||
else
|
else
|
||||||
@s_type = 0
|
@s_type = 0
|
||||||
@projects = @projects_all.order("created_on desc")
|
@courses = @courses_all.order("created_on desc")
|
||||||
@projects = @projects.offset(@project_pages.offset).limit(@project_pages.per_page)
|
@courses = @courses.offset(@course_pages.offset).limit(@course_pages.per_page)
|
||||||
|
|
||||||
#gcm
|
#gcm
|
||||||
@project_activity_count=get_project_activity @projects,@project_activity_count
|
@course_activity_count=get_course_activity @courses,@course_activity_count
|
||||||
#gcmend
|
#gcmend
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -155,21 +155,22 @@ class CoursesController < ApplicationController
|
||||||
}
|
}
|
||||||
format.api {
|
format.api {
|
||||||
# @offset, @limit = api_offset_and_limit
|
# @offset, @limit = api_offset_and_limit
|
||||||
# @project_count = Project.visible.count
|
# @course_count = Project.visible.count
|
||||||
# @projects = Project.visible.offset(@offset).limit(@limit).order('lft').all
|
# @courses = Project.visible.offset(@offset).limit(@limit).order('lft').all
|
||||||
}
|
}
|
||||||
format.atom {
|
format.atom {
|
||||||
projects = Project.visible.order('created_on DESC').limit(Setting.feeds_limit.to_i).all
|
courses = Project.visible.order('created_on DESC').limit(Setting.feeds_limit.to_i).all
|
||||||
render_feed(projects, :title => "#{Setting.app_title}: #{l(:label_project_latest)}")
|
render_feed(courses, :title => "#{Setting.app_title}: #{l(:label_course_latest)}")
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
def index
|
def index1
|
||||||
|
|
||||||
per_page_option = 10
|
per_page_option = 10
|
||||||
|
|
||||||
|
#当前所有的活动课程
|
||||||
@courses_all = Course.active.visible.
|
@courses_all = Course.active.visible.
|
||||||
joins("LEFT JOIN #{CourseStatus.table_name} ON #{Course.table_name}.id = #{CourseStatus.table_name}.couse_id")
|
joins("LEFT JOIN #{CourseStatus.table_name} ON #{Course.table_name}.id = #{CourseStatus.table_name}.couse_id")
|
||||||
|
|
||||||
|
|
|
@ -1,63 +1,70 @@
|
||||||
<% content_for :header_tags do %>
|
<% content_for :header_tags do %>
|
||||||
<%= auto_discovery_link_tag(:atom, {:action => 'index', :format => 'atom', :key => User.current.rss_key}) %>
|
<%= auto_discovery_link_tag(:atom, {:action => 'index', :format => 'atom', :key => User.current.rss_key}) %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<div class="top-content">
|
<div class="top-content">
|
||||||
<%= form_tag(courses_search_path, :method => :get) do %>
|
<%= form_tag(courses_search_path, :method => :get) do %>
|
||||||
<table width="940px">
|
<table width="940px">
|
||||||
<tr>
|
<tr>
|
||||||
<td class="info_font" style="width: 220px; color: #15bccf"><%= l(:label_course_deposit) %></td>
|
<td class="info_font" style="width: 220px; color: #15bccf"><%= l(:label_course_all) %></td>
|
||||||
<td class="location-list"><strong><%= l(:label_user_location) %> :</strong></td>
|
<td class="location-list"><strong><%= l(:label_user_location) %> :</strong></td>
|
||||||
<td rowspan="2">
|
<td rowspan="2">
|
||||||
<% if User.current.logged? %>
|
<% if User.current.logged? %>
|
||||||
<%= link_to(l(:label_course_new), {:controller => 'courses', :action => 'new', :course => 0, :course_type =>( @course_type||=0)}, :class => 'icon icon-add') if User.current.allowed_to?(:add_course, nil, :global => true) %>
|
<%= link_to(l(:label_course_new), {:controller => 'courses', :action => 'new', :course => 0, :course_type => (@course_type||=0)}, :class => 'icon icon-add') if User.current.allowed_to?(:add_course, nil, :global => true) %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</td>
|
</td>
|
||||||
<td rowspan="2" >
|
<td rowspan="2">
|
||||||
<div class="course-search" style="float: right">
|
<div class="course-search" style="float: right">
|
||||||
<%= text_field_tag 'name', params[:name], :size => 30 %>
|
<%= text_field_tag 'name', params[:name], :size => 30 %>
|
||||||
<%= hidden_field_tag 'course_type', params[:course_type] %>
|
<%= hidden_field_tag 'course_type', params[:course_type] %>
|
||||||
<%= submit_tag l(:label_search), :class => "enterprise", :name => nil %>
|
<%= submit_tag l(:label_search), :class => "enterprise", :name => nil %>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td style="padding-left: 8px"><a><%= link_to request.host()+"/courses", :controller => 'courses', :action => 'index', :course_type => 0 %> </a></td>
|
<td style="padding-left: 8px">
|
||||||
<td ><%=link_to l(:field_homepage), home_path %> > <%=link_to l(:label_course_deposit), :controller => 'courses', :action => 'index', :course_type => 0 %></td>
|
<a><%= link_to request.host()+"/courses", :controller => 'courses', :action => 'index', :course_type => 0 %> </a>
|
||||||
</tr>
|
</td>
|
||||||
</table>
|
<td><%= link_to l(:field_homepage), home_path %>
|
||||||
<% end %>
|
> <%= link_to l(:label_course_all), :controller => 'courses', :action => 'index', :course_type => 0 %></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
<%= sort_courses(@s_type) %>
|
<%= sort_courses(@s_type) %>
|
||||||
<div id="courses-index">
|
<div id="courses-index">
|
||||||
<%= render_course_hierarchy(@courses)%>
|
<% if @courses %>
|
||||||
|
<%= render_course_hierarchy(@courses) %>
|
||||||
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="pagination">
|
<div class="pagination">
|
||||||
<ul>
|
<ul>
|
||||||
<%= pagination_links_full @course_pages, @course_count %>
|
<% if @course_pages %>
|
||||||
</ul>
|
<%= pagination_links_full @course_pages, @course_count %>
|
||||||
|
<% end %>
|
||||||
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<% if User.current.logged? %>
|
<% if User.current.logged? %>
|
||||||
<p style="text-align:right;">
|
<p style="text-align:right;">
|
||||||
<span class="my-course"><%= l(:label_my_courses) %></span>
|
<span class="my-course"><%= l(:label_my_courses) %></span>
|
||||||
</p>
|
</p>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<% other_formats_links do |f| %>
|
<% other_formats_links do |f| %>
|
||||||
<%= f.link_to 'Atom', :url => {:key => User.current.rss_key} %>
|
<%= f.link_to 'Atom', :url => {:key => User.current.rss_key} %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<% content_for :sidebar do %>
|
<% content_for :sidebar do %>
|
||||||
|
|
||||||
<%= form_tag({}, :method => :get) do %>
|
<%= form_tag({}, :method => :get) do %>
|
||||||
<h3><%= l(:label_course_plural) %></h3>
|
<h3><%= l(:label_course_all) %></h3>
|
||||||
<label for="closed"><%= check_box_tag 'closed', 1, params[:closed] %> <%= l(:label_show_closed_courses) %></label>
|
<label for="closed"><%= check_box_tag 'closed', 1, params[:closed] %> <%= l(:label_show_closed_courses) %></label>
|
||||||
<p>
|
<p>
|
||||||
<%= submit_tag l(:button_apply), :class => 'button-small', :name => nil %>
|
<%= submit_tag l(:button_apply), :class => 'button-small', :name => nil %>
|
||||||
</p>
|
</p>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<% html_title(l(:label_course_plural)) -%>
|
<% html_title(l(:label_course_all)) -%>
|
||||||
|
|
|
@ -546,6 +546,7 @@ RedmineApp::Application.routes.draw do
|
||||||
post 'restartcourse'
|
post 'restartcourse'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
match '/courses/search', :controller => 'courses', :action => 'search', :via => [:get, :post]
|
||||||
#match 'project/enterprise_course', :to => 'projects#enterprise_course'
|
#match 'project/enterprise_course', :to => 'projects#enterprise_course'
|
||||||
#match 'project/course_enterprise', :to => 'projects#course_enterprise'
|
#match 'project/course_enterprise', :to => 'projects#course_enterprise'
|
||||||
#match 'project/course', :to => 'projects#course', :as => 'course'
|
#match 'project/course', :to => 'projects#course', :as => 'course'
|
||||||
|
|
|
@ -4,7 +4,7 @@ class StoredCourseProcedure < ActiveRecord::Migration
|
||||||
# project中所有的课程导入至course
|
# project中所有的课程导入至course
|
||||||
# Project_status导入至course_status
|
# Project_status导入至course_status
|
||||||
#
|
#
|
||||||
Project.find_all.each do |project|
|
Project.all.each do |project|
|
||||||
if project.project_type == 1
|
if project.project_type == 1
|
||||||
course = Course.find_by_extra(project.identifier)
|
course = Course.find_by_extra(project.identifier)
|
||||||
if course
|
if course
|
||||||
|
|
26
db/schema.rb
26
db/schema.rb
|
@ -11,7 +11,7 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended to check this file into your version control system.
|
# It's strongly recommended to check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(:version => 20140522025721) do
|
ActiveRecord::Schema.define(:version => 20140530102015) do
|
||||||
|
|
||||||
create_table "activities", :force => true do |t|
|
create_table "activities", :force => true do |t|
|
||||||
t.integer "act_id", :null => false
|
t.integer "act_id", :null => false
|
||||||
|
@ -220,6 +220,16 @@ ActiveRecord::Schema.define(:version => 20140522025721) do
|
||||||
t.datetime "updated_on", :null => false
|
t.datetime "updated_on", :null => false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
create_table "course_statuses", :force => true do |t|
|
||||||
|
t.integer "changesets_count"
|
||||||
|
t.integer "watchers_count"
|
||||||
|
t.integer "course_id"
|
||||||
|
t.float "grade", :default => 0.0
|
||||||
|
t.integer "course_ac_para", :default => 0
|
||||||
|
t.datetime "created_at", :null => false
|
||||||
|
t.datetime "updated_at", :null => false
|
||||||
|
end
|
||||||
|
|
||||||
create_table "courses", :force => true do |t|
|
create_table "courses", :force => true do |t|
|
||||||
t.integer "tea_id"
|
t.integer "tea_id"
|
||||||
t.string "name"
|
t.string "name"
|
||||||
|
@ -227,8 +237,8 @@ ActiveRecord::Schema.define(:version => 20140522025721) do
|
||||||
t.string "code"
|
t.string "code"
|
||||||
t.integer "time"
|
t.integer "time"
|
||||||
t.string "extra"
|
t.string "extra"
|
||||||
t.datetime "created_at", :null => false
|
t.datetime "created_at", :null => false
|
||||||
t.datetime "updated_at", :null => false
|
t.datetime "updated_at", :null => false
|
||||||
t.string "location"
|
t.string "location"
|
||||||
t.string "term"
|
t.string "term"
|
||||||
t.string "string"
|
t.string "string"
|
||||||
|
@ -237,6 +247,11 @@ ActiveRecord::Schema.define(:version => 20140522025721) do
|
||||||
t.string "endup_time"
|
t.string "endup_time"
|
||||||
t.string "class_period"
|
t.string "class_period"
|
||||||
t.integer "school_id"
|
t.integer "school_id"
|
||||||
|
t.text "description"
|
||||||
|
t.integer "status", :default => 1
|
||||||
|
t.integer "attachmenttype", :default => 2
|
||||||
|
t.integer "lft"
|
||||||
|
t.integer "rgt"
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "custom_fields", :force => true do |t|
|
create_table "custom_fields", :force => true do |t|
|
||||||
|
@ -482,12 +497,13 @@ ActiveRecord::Schema.define(:version => 20140522025721) do
|
||||||
t.text "notes"
|
t.text "notes"
|
||||||
t.integer "status"
|
t.integer "status"
|
||||||
t.integer "reply_id"
|
t.integer "reply_id"
|
||||||
t.datetime "created_on", :null => false
|
t.datetime "created_on", :null => false
|
||||||
t.datetime "updated_on", :null => false
|
t.datetime "updated_on", :null => false
|
||||||
t.string "m_parent_id"
|
t.string "m_parent_id"
|
||||||
t.boolean "is_readed"
|
t.boolean "is_readed"
|
||||||
t.integer "m_reply_count"
|
t.integer "m_reply_count"
|
||||||
t.integer "m_reply_id"
|
t.integer "m_reply_id"
|
||||||
|
t.integer "is_comprehensive_evaluation"
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "member_roles", :force => true do |t|
|
create_table "member_roles", :force => true do |t|
|
||||||
|
|
Loading…
Reference in New Issue