添加课程index界面
This commit is contained in:
parent
77006198a1
commit
e490f7979d
|
@ -70,81 +70,81 @@ class CoursesController < ApplicationController
|
|||
end
|
||||
|
||||
|
||||
def course12
|
||||
@project_type = params[:project_type]
|
||||
def index
|
||||
@course_type = params[:course_type]
|
||||
@school_id = params[:school_id]
|
||||
per_page_option = 10
|
||||
if @school_id == "0" or @school_id.nil?
|
||||
@projects_all = Project.active.visible.
|
||||
joins("LEFT JOIN #{ProjectStatus.table_name} ON #{Project.table_name}.id = #{ProjectStatus.table_name}.project_id").
|
||||
where("#{Project.table_name}.project_type = ? ", Project::ProjectType_course)
|
||||
@courses_all = Project.active.visible.
|
||||
joins("LEFT JOIN #{ProjectStatus.table_name} ON #{Project.table_name}.id = #{ProjectStatus.table_name}.course_id").
|
||||
where("#{Project.table_name}.course_type = ? ", Project::ProjectType_course)
|
||||
else
|
||||
@projects_all = Project.active.visible.
|
||||
joins("LEFT JOIN #{ProjectStatus.table_name} ON #{Project.table_name}.id = #{ProjectStatus.table_name}.project_id").
|
||||
@courses_all = Project.active.visible.
|
||||
joins("LEFT JOIN #{ProjectStatus.table_name} ON #{Project.table_name}.id = #{ProjectStatus.table_name}.course_id").
|
||||
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
|
||||
|
||||
@project_count = @projects_all.count
|
||||
@project_pages = Paginator.new @project_count, per_page_option, params['page']
|
||||
@course_count = @courses_all.count
|
||||
@course_pages = Paginator.new @course_count, per_page_option, params['page']
|
||||
|
||||
#gcm activity count
|
||||
|
||||
@project_activity_count=Hash.new
|
||||
@course_activity_count=Hash.new
|
||||
#count initialize
|
||||
@projects_all.each do |project|
|
||||
@project_activity_count[project.id]=0
|
||||
@courses_all.each do |course|
|
||||
@course_activity_count[course.id]=0
|
||||
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
|
||||
|
||||
|
||||
case params[:project_sort_type]
|
||||
case params[:course_sort_type]
|
||||
when '0'
|
||||
@projects = @projects_all.order("created_on desc")
|
||||
@courses = @courses_all.order("created_on desc")
|
||||
@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
|
||||
@project_activity_count=get_project_activity @projects,@project_activity_count
|
||||
@course_activity_count=get_course_activity @courses,@course_activity_count
|
||||
#gcmend
|
||||
|
||||
when '1'
|
||||
@projects = @projects_all.order("course_ac_para desc")
|
||||
@courses = @courses_all.order("course_ac_para desc")
|
||||
@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
|
||||
@project_activity_count=get_project_activity @projects,@project_activity_count
|
||||
@course_activity_count=get_course_activity @courses,@course_activity_count
|
||||
#gcmend
|
||||
|
||||
when '2'
|
||||
@projects = @projects_all.order("watchers_count desc")
|
||||
@courses = @courses_all.order("watchers_count desc")
|
||||
@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
|
||||
@project_activity_count=get_project_activity @projects,@project_activity_count
|
||||
@course_activity_count=get_course_activity @courses,@course_activity_count
|
||||
#gcmend
|
||||
|
||||
#gcm
|
||||
when '3'
|
||||
|
||||
#gcm
|
||||
@project_activity_count=get_project_activity @projects_all,@project_activity_count
|
||||
@course_activity_count=get_course_activity @courses_all,@course_activity_count
|
||||
#gcmend
|
||||
|
||||
@projects=handle_project @projects_all,@project_activity_count
|
||||
@courses=handle_course @courses_all,@course_activity_count
|
||||
@s_type = 3
|
||||
@projects = @projects[@project_pages.offset, @project_pages.per_page]
|
||||
@courses = @courses[@course_pages.offset, @course_pages.per_page]
|
||||
else
|
||||
@s_type = 0
|
||||
@projects = @projects_all.order("created_on desc")
|
||||
@projects = @projects.offset(@project_pages.offset).limit(@project_pages.per_page)
|
||||
@courses = @courses_all.order("created_on desc")
|
||||
@courses = @courses.offset(@course_pages.offset).limit(@course_pages.per_page)
|
||||
|
||||
#gcm
|
||||
@project_activity_count=get_project_activity @projects,@project_activity_count
|
||||
@course_activity_count=get_course_activity @courses,@course_activity_count
|
||||
#gcmend
|
||||
|
||||
end
|
||||
|
@ -155,21 +155,22 @@ class CoursesController < ApplicationController
|
|||
}
|
||||
format.api {
|
||||
# @offset, @limit = api_offset_and_limit
|
||||
# @project_count = Project.visible.count
|
||||
# @projects = Project.visible.offset(@offset).limit(@limit).order('lft').all
|
||||
# @course_count = Project.visible.count
|
||||
# @courses = Project.visible.offset(@offset).limit(@limit).order('lft').all
|
||||
}
|
||||
format.atom {
|
||||
projects = Project.visible.order('created_on DESC').limit(Setting.feeds_limit.to_i).all
|
||||
render_feed(projects, :title => "#{Setting.app_title}: #{l(:label_project_latest)}")
|
||||
courses = Project.visible.order('created_on DESC').limit(Setting.feeds_limit.to_i).all
|
||||
render_feed(courses, :title => "#{Setting.app_title}: #{l(:label_course_latest)}")
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def index
|
||||
def index1
|
||||
|
||||
per_page_option = 10
|
||||
|
||||
#当前所有的活动课程
|
||||
@courses_all = Course.active.visible.
|
||||
joins("LEFT JOIN #{CourseStatus.table_name} ON #{Course.table_name}.id = #{CourseStatus.table_name}.couse_id")
|
||||
|
||||
|
|
|
@ -1,19 +1,19 @@
|
|||
<% 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 %>
|
||||
|
||||
<div class="top-content">
|
||||
<%= form_tag(courses_search_path, :method => :get) do %>
|
||||
<table width="940px">
|
||||
<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 rowspan="2">
|
||||
<% 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 %>
|
||||
</td>
|
||||
<td rowspan="2" >
|
||||
<td rowspan="2">
|
||||
<div class="course-search" style="float: right">
|
||||
<%= text_field_tag 'name', params[:name], :size => 30 %>
|
||||
<%= hidden_field_tag 'course_type', params[:course_type] %>
|
||||
|
@ -22,42 +22,49 @@
|
|||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding-left: 8px"><a><%= link_to request.host()+"/courses", :controller => 'courses', :action => 'index', :course_type => 0 %> </a></td>
|
||||
<td ><%=link_to l(:field_homepage), home_path %> > <%=link_to l(:label_course_deposit), :controller => 'courses', :action => 'index', :course_type => 0 %></td>
|
||||
<td style="padding-left: 8px">
|
||||
<a><%= link_to request.host()+"/courses", :controller => 'courses', :action => 'index', :course_type => 0 %> </a>
|
||||
</td>
|
||||
<td><%= link_to l(:field_homepage), home_path %>
|
||||
> <%= link_to l(:label_course_all), :controller => 'courses', :action => 'index', :course_type => 0 %></td>
|
||||
</tr>
|
||||
</table>
|
||||
<% end %>
|
||||
</div>
|
||||
<%= sort_courses(@s_type) %>
|
||||
<div id="courses-index">
|
||||
<%= render_course_hierarchy(@courses)%>
|
||||
<% if @courses %>
|
||||
<%= render_course_hierarchy(@courses) %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<div class="pagination">
|
||||
<ul>
|
||||
<% if @course_pages %>
|
||||
<%= pagination_links_full @course_pages, @course_count %>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<% if User.current.logged? %>
|
||||
<p style="text-align:right;">
|
||||
<p style="text-align:right;">
|
||||
<span class="my-course"><%= l(:label_my_courses) %></span>
|
||||
</p>
|
||||
</p>
|
||||
<% end %>
|
||||
|
||||
<% 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 %>
|
||||
|
||||
<% content_for :sidebar do %>
|
||||
|
||||
<%= form_tag({}, :method => :get) do %>
|
||||
<h3><%= l(:label_course_plural) %></h3>
|
||||
<label for="closed"><%= check_box_tag 'closed', 1, params[:closed] %> <%= l(:label_show_closed_courses) %></label>
|
||||
<p>
|
||||
<%= form_tag({}, :method => :get) do %>
|
||||
<h3><%= l(:label_course_all) %></h3>
|
||||
<label for="closed"><%= check_box_tag 'closed', 1, params[:closed] %> <%= l(:label_show_closed_courses) %></label>
|
||||
<p>
|
||||
<%= submit_tag l(:button_apply), :class => 'button-small', :name => nil %>
|
||||
</p>
|
||||
<% end %>
|
||||
</p>
|
||||
<% 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'
|
||||
end
|
||||
end
|
||||
match '/courses/search', :controller => 'courses', :action => 'search', :via => [:get, :post]
|
||||
#match 'project/enterprise_course', :to => 'projects#enterprise_course'
|
||||
#match 'project/course_enterprise', :to => 'projects#course_enterprise'
|
||||
#match 'project/course', :to => 'projects#course', :as => 'course'
|
||||
|
|
|
@ -4,7 +4,7 @@ class StoredCourseProcedure < ActiveRecord::Migration
|
|||
# project中所有的课程导入至course
|
||||
# Project_status导入至course_status
|
||||
#
|
||||
Project.find_all.each do |project|
|
||||
Project.all.each do |project|
|
||||
if project.project_type == 1
|
||||
course = Course.find_by_extra(project.identifier)
|
||||
if course
|
||||
|
|
18
db/schema.rb
18
db/schema.rb
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# 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|
|
||||
t.integer "act_id", :null => false
|
||||
|
@ -220,6 +220,16 @@ ActiveRecord::Schema.define(:version => 20140522025721) do
|
|||
t.datetime "updated_on", :null => false
|
||||
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|
|
||||
t.integer "tea_id"
|
||||
t.string "name"
|
||||
|
@ -237,6 +247,11 @@ ActiveRecord::Schema.define(:version => 20140522025721) do
|
|||
t.string "endup_time"
|
||||
t.string "class_period"
|
||||
t.integer "school_id"
|
||||
t.text "description"
|
||||
t.integer "status", :default => 1
|
||||
t.integer "attachmenttype", :default => 2
|
||||
t.integer "lft"
|
||||
t.integer "rgt"
|
||||
end
|
||||
|
||||
create_table "custom_fields", :force => true do |t|
|
||||
|
@ -488,6 +503,7 @@ ActiveRecord::Schema.define(:version => 20140522025721) do
|
|||
t.boolean "is_readed"
|
||||
t.integer "m_reply_count"
|
||||
t.integer "m_reply_id"
|
||||
t.integer "is_comprehensive_evaluation"
|
||||
end
|
||||
|
||||
create_table "member_roles", :force => true do |t|
|
||||
|
|
Loading…
Reference in New Issue