diff --git a/app/controllers/managements_controller.rb b/app/controllers/managements_controller.rb
index 5ff3498e0..ebe258944 100644
--- a/app/controllers/managements_controller.rb
+++ b/app/controllers/managements_controller.rb
@@ -9,48 +9,71 @@ class ManagementsController < ApplicationController
# 专业列表
def profession
@syllabus=Syllabus.where("0=0")
- @menu_type=11
- @sub_type=1
- major_level_option=params[:major_level_option]
- discipline_category_option=params[:discipline_category_option]
- first_level_discipline_option=params[:first_level_discipline_option]
- if major_level_option!='0'
- @syllabus=@syllabus.where(:major_level=>major_level_option)
- else
- @syllabus=@syllabus
+ @menu_type = 12
+ @sub_type = 1
+ @sx_order = params[:sx_order].blank? ? "desc" : params[:sx_order]
+ major_level_option = params[:major_level] if params[:major_level]
+ discipline_category_option = params[:discipline_category_id] if params[:discipline_category_id]
+ first_level_discipline_option = params[:first_level_discipline_id] if params[:first_level_discipline_id]
+ if major_level_option && major_level_option != '0'
+ @syllabus = @syllabus.where(:major_level=>major_level_option)
end
-
- if discipline_category_option !=nil
+ if discipline_category_option && discipline_category_option != '0'
@syllabus=@syllabus.where(:discipline_category_id=>discipline_category_option)
end
-
- if first_level_discipline_option!=nil
+ if first_level_discipline_option && first_level_discipline_option != '0'
@syllabus=@syllabus.where(:first_level_discipline_id=>first_level_discipline_option)
end
+ @syllabus = @syllabus.order("created_at #{@sx_order}")
@syllabus_count = @syllabus.count
limit = 20
@is_remote = true
@syllabus_pages = Paginator.new @syllabus_count, limit, params['page'] || 1
@offset ||= @syllabus_pages.offset
@syllabus = paginateHelper @syllabus, limit
-
respond_to do |format|
format.js
format.html
end
-
end
# 实训适用课程
def applicable_course
- @courselist = CourseList.find_by_sql("SELECT id, name as name FROM `course_lists` where id in (SELECT id FROM `major_courses`);")
+ @menu_type = 12
+ @sub_type = 2
+ @courselist = CourseList.where("0=0")
+ search=params[:search]
+ if search.blank?
+ @courselist = @courselist
+ else
+ @courselist = @courselist.where("name like '%#{search}%'")
+ end
+ @courselist_count = @courselist.count
+ @limit = 4
+ @is_remote = true
+ @page = params['page'] ? params['page'].to_i : 1
+ @courselist_pages = Paginator.new @courselist_count, @limit, @page
+ @offset ||=@courselist_pages.offset
+ @courselist = paginateHelper @courselist, @limit
+ respond_to do |format|
+ format.js
+ format.html
+ end
+end
+ # 增加课程
+ def add_course
+ @courselist= CourseList.create(:name => params[:course])
+ respond_to do |format|
+ format.js
+ end
end
# 单位部门列表
def departments
@menu_type = 6
@sub_type = 2
+ @sx_order = params[:sx_order].blank? ? "desc" : params[:sx_order]
@department =Department.where("0=0")
search=params[:search]
if search.blank?
@@ -58,6 +81,7 @@ class ManagementsController < ApplicationController
else
@department = @department.where("name like '%#{search}%'")
end
+ @department = @department.reorder("created_at #{@sx_order}")
@department_count =@department.count
limit = 20
@is_remote = true
@@ -68,26 +92,27 @@ class ManagementsController < ApplicationController
format.js
format.html
end
-
end
+
# 单位列表
def departments_part
@menu_type = 6
@sub_type = 1
@schools = School.where("0=0")
+ @sx_order = params[:sx_order].blank? ? "desc" : params[:sx_order]
search=params[:search]
if search.blank?
@schools = @schools
else
@schools = @schools.where("name like '%#{search}%'")
end
+ @schools = @schools.reorder("created_at #{@sx_order}")
@schools_count = @schools.count
limit = 20
@is_remote = true
@schools_pages = Paginator.new @schools_count, limit, params['page'] || 1
@offset ||= @schools_pages.offset
@schools= paginateHelper @schools, limit
-
respond_to do |format|
format.js
format.html
@@ -100,11 +125,13 @@ class ManagementsController < ApplicationController
@sub_type = 3
search = params[:search]
@apply_status = ApplyAddDepartment.where("0=0")
+ @sx_order = params[:sx_order].blank? ? "desc" : params[:sx_order]
if search.blank?
@apply_status = @apply_status.where("0=0")
else
@apply_status= @apply_status.where("name like '%#{search}%'")
end
+ @apply_status = @apply_status.order("created_at #{@sx_order}")
@apply_status_count = @apply_status.count
limit = 20
@is_remote = true
@@ -122,19 +149,20 @@ class ManagementsController < ApplicationController
@menu_type = 10
@sub_type = 4
search = params[:search]
+ @sx_order = params[:sx_order].blank? ? "desc" : params[:sx_order]
@apply_status = ApplyAddSchools.where("0=0")
if search.blank?
@apply_status = @apply_status.where("0=0")
else
@apply_status= @apply_status.where("name like '%#{search}%'")
end
+ @apply_status = @apply_status.order("created_at #{@sx_order}")
@apply_status_count = @apply_status.count
limit = 20
@is_remote = true
@apply_status_pages = Paginator.new @apply_status_count, limit, params['page'] || 1
@offset ||= @apply_status_pages.offset
@apply_status = paginateHelper @apply_status, limit
-
respond_to do |format|
format.js
format.html
@@ -147,43 +175,35 @@ class ManagementsController < ApplicationController
@sub_type = 1
@syllabus = Syllabus.where("0=0")
@sx_order = params[:sx_order].blank? ? "desc" : params[:sx_order]
- unless params[:school_id] || params[:search] || params[:keyword] || params[:status]
- user_exs = UserExtensions.where(:user_id=> @syllabus.map(&:user_id))
- @schools = School.where(:id =>user_exs.map(&:school_id))
- end
-
- major_level_option = params[:major_level_option]
- discipline_category_option = params[:discipline_category_option]
- first_level_discipline_option = params[:first_level_discipline_option]
- syllabus_major_option = params[:syllabus_major_option]
+ major_level_option = params[:major_level] if params[:major_level]
+ discipline_category_option = params[:discipline_category_id] if params[:discipline_category_id]
+ first_level_discipline_option = params[:first_level_discipline_id] if params[:first_level_discipline_id]
+ syllabus_major_option = params[:major_id] if params[:major_id]
keyword = params[:keyword]
search = params[:search]
- if major_level_option!='0'
+
+ if major_level_option && major_level_option != '0'
@syllabus = @syllabus.where(:major_level=>major_level_option)
- else
- @syllabus = @syllabus
end
- if discipline_category_option !=nil
+ if discipline_category_option && discipline_category_option != '0'
@syllabus=@syllabus.where(:discipline_category_id=>discipline_category_option)
end
- if first_level_discipline_option!=nil
+ if first_level_discipline_option && first_level_discipline_option != '0'
@syllabus=@syllabus.where(:first_level_discipline_id=>first_level_discipline_option)
end
- if syllabus_major_option!=nil
+ if syllabus_major_option && syllabus_major_option != '0'
@syllabus=@syllabus.where(:major_id=>syllabus_major_option)
end
- if params[:school_id] && params[:school_id] != '0'
- @syllabus = Syllabus.includes(:user => {:user_extensions => []}).where("user_extensions.school_id = #{params[:school_id]}")
- else
- @syllabus = @syllabus.where("0=0")
+ if params[:school_id] && params[:school_id] != ''
+ @syllabus = @syllabus.includes(:user => {:user_extensions => []}).where("user_extensions.school_id = #{params[:school_id]}")
end
if search.blank?
- @syllabus = @syllabus.where("0=0")
+ @syllabus = @syllabus
else
if "u_name" == keyword
user_id = User.where("concat(lastname, firstname) like '%#{search}%'")
@@ -192,8 +212,9 @@ class ManagementsController < ApplicationController
@syllabus= @syllabus.where("title like '%#{search}%'")
end
end
- @syllabus = @syllabus.order("created_at #{@sx_order}")
- @syllabus_count = @syllabus.count
+
+ @syllabus = @syllabus.order("syllabuses.created_at #{@sx_order}")
+ @syllabus_count = @syllabus.count
limit = 20
@is_remote = true
@syllabus_pages = Paginator.new @syllabus_count, limit, params['page'] || 1
@@ -211,36 +232,40 @@ class ManagementsController < ApplicationController
@sub_type = 2
@sx_order = params[:sx_order].blank? ? "desc" : params[:sx_order]
@courses = Course.where("0=0")
- # @courses = @courses.select("courses.*,(SELECT MAX(updated_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS updatetime").order("updatetime desc")
@timing=Course.where(:is_end=>false).count
@end=Course.where(:is_end=>true).count
unless params[:school_id] || params[:search] || params[:keyword] || params[:status]
user_exs=UserExtensions.where(:school_id=> @courses.map(&:school_id))
@schools = School.where(:id =>user_exs.map(&:school_id))
end
- search = params[:search] # 搜索字
- keyword = params[:keyword].blank? ? "u_name" : params[:keyword] # 根据姓名/课程名搜索
+ @search = params[:search] # 搜索字
+ @keyword = params[:keyword].blank? ? "u_name" : params[:keyword] # 根据姓名/课程名搜索
status = params[:status].to_i
+
if params[:school_id] && params[:school_id] != '0'
- @courses =Course.joins("join users u on courses.tea_id = u.id").joins("join user_extensions ue on u.id = ue.user_id").where("ue.school_id = #{params[:school_id]}").order("created_at #{@sx_order}")
- else
- @courses = Course.where("0=0").order("created_at #{@sx_order}")
+ @school_id = params[:school_id]
+ @courses =Course.joins("join users u on courses.tea_id = u.id").joins("join user_extensions ue on u.id = ue.user_id").where("ue.school_id = #{params[:school_id]}")
end
+
+ if params[:homepage_show]
+ @courses = @courses.where(:homepage_show => params[:homepage_show].to_i)
+ end
+
if params[:status] && params[:status]!=''
- @courses =@courses.where(:is_end =>status).order("created_at #{@sx_order}")
+ @status = params[:status]
+ @courses =@courses.where(:is_end =>status)
end
- if "u_name" == keyword
- if search.blank?
- @courses = @courses.order("created_at #{@sx_order}")
+ if "u_name" == @keyword
+ if @search.blank?
+ @courses = @courses
else
- user_id = User.where("concat(lastname, firstname) like '%#{search}%'")
- @courses = @courses.joins("join users u on courses.tea_id = u.id").where("concat(u.lastname, u.firstname) like '%#{search}%'").order("created_at #{@sx_order}")
+ user_id = User.where("concat(lastname, firstname) like '%#{@search}%'")
+ @courses = @courses.joins("join users u on courses.tea_id = u.id").where("concat(u.lastname, u.firstname) like '%#{@search}%'")
end
else
- @courses= @courses.where("name like '%#{search}%'").order("created_at #{@sx_order}")
+ @courses= @courses.where("name like '%#{@search}%'")
end
- @courses = @courses.select("courses.*,(SELECT MAX(updated_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS updatetime").reorder("updatetime desc")
- @courses = @courses.order("created_at #{@sx_order}")
+ @courses = @courses.select("courses.*,(SELECT MAX(updated_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS updatetime").reorder("updatetime #{@sx_order}")
@courses_count = @courses.count
limit = 20
@is_remote = true
@@ -253,6 +278,14 @@ class ManagementsController < ApplicationController
end
end
+ # 班级首页显示
+ def course_homepage_show
+ if params[:course_id]
+ course = Course.find params[:course_id]
+ course.update_attributes(:homepage_show => !course.homepage_show)
+ end
+ end
+
# 课程实训
def class_shixuns
@menu_type = 4
@@ -275,13 +308,12 @@ class ManagementsController < ApplicationController
@c_shixuns = @c_shixuns
else
if "u_name" == keyword
- user_id = User.where("concat(lastname, firstname) like '%#{search}%'")
+ # user_id = User.where("concat(lastname, firstname) like '%#{search}%'")
@c_shixuns = @c_shixuns.includes(:user).where("concat(users.lastname, users.firstname) like '%#{search}%'")
else
@c_shixuns= @c_shixuns.where("name like '%#{search}%'")
end
end
- @c_shixuns = @c_shixuns.reorder("created_at desc")
unless params[:school_id] || params[:search] || params[:keyword] || params[:status]
user_exs = UserExtensions.where(:user_id => @c_shixuns.map(&:user_id))
@schools = School.where(:id => user_exs.map(&:school_id))
@@ -304,20 +336,19 @@ class ManagementsController < ApplicationController
@c_shixuns = Subject.where(:status => 2)
end
if search.blank?
- @c_shixuns = @c_shixuns
- else
- if "u_name" == keyword
+
+ elsif "u_name" == keyword
# 如果用户搜索为空,不用遍历user表,直接查找所有实训, 有搜索时才查找user
- user_id = User.where("concat(lastname, firstname) like '%#{search}%'")
+ user_id = User.where("concat(lastname, firstname) like '%#{search}%'")
@c_shixuns = @c_shixuns.includes(:user).where("concat(users.lastname, users.firstname) like '%#{search}%'")
else
@c_shixuns= @c_shixuns.where("name like '%#{search}%'")
end
- end
unless params[:school_id] || params[:search] || params[:keyword]
user_exs = UserExtensions.where(:user_id => @c_shixuns.map(&:user_id))
@schools = School.where(:id => user_exs.map(&:school_id))
end
+ @c_shixuns = @c_shixuns.order("created_at desc")
respond_to do |format|
format.js
format.html
@@ -412,6 +443,9 @@ class ManagementsController < ApplicationController
else
@shixuns = Shixun.where("name like '%#{search}%'").where(:status => 2).order("created_at #{@sx_order}")
end
+ if params[:homepage_show]
+ @shixuns = @shixuns.where(:homepage_show => params[:homepage_show].to_i)
+ end
@shixuns_count = @shixuns.count
limit = 20
@shixuns_pages = Paginator.new @shixuns_count, limit, params['page'] || 1
@@ -422,6 +456,13 @@ class ManagementsController < ApplicationController
format.html
end
end
+ # 实训首页显示
+ def shixun_homepage_show
+ if params[:shixun_id]
+ shixun = Shixun.find params[:shixun_id]
+ shixun.update_attributes(:homepage_show => !shixun.homepage_show)
+ end
+ end
# 已关闭的实训
def close_shixuns
@@ -682,7 +723,7 @@ class ManagementsController < ApplicationController
def shixun_authorization
@menu_type = 10
- @sub_type == 5
+ @sub_type == 5
@type = trial_authorization_status params[:type]
@authorizations = ApplyAction.where(:container_type => "ApplyShixun", :status => @type).order("created_at desc")
search = params[:search]
diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb
index eab591a15..7d7f897eb 100644
--- a/app/controllers/shixuns_controller.rb
+++ b/app/controllers/shixuns_controller.rb
@@ -402,7 +402,6 @@ class ShixunsController < ApplicationController
def new
@shixun = Shixun.new
-
respond_to do |format|
format.html{render :layout => 'base_edu'}
format.json
diff --git a/app/helpers/managements_helper.rb b/app/helpers/managements_helper.rb
index 811e2a78c..490fdab78 100644
--- a/app/helpers/managements_helper.rb
+++ b/app/helpers/managements_helper.rb
@@ -24,6 +24,10 @@ module ManagementsHelper
# params[:id]: course_list_id
def get_course_list_major id
- ShixunMajorCourse.where(:course_list_id => id)
+ Major.where(:id => MajorCourse.where(:course_list_id => id).map(&:major_id))
+ end
+
+ def course_list_count id
+ Major.where(:id => id).first.try(:name)
end
end
diff --git a/app/models/course.rb b/app/models/course.rb
index ccb4579a3..7383ace7e 100644
--- a/app/models/course.rb
+++ b/app/models/course.rb
@@ -24,7 +24,7 @@ class Course < ActiveRecord::Base
end
end
- attr_accessible :code, :extra, :name, :state, :tea_id, :time , :location, :state, :term, :password,:is_public,:description,:class_period, :open_student, :enterprise_name, :is_delete, :syllabus_id, :end_time, :end_term, :choose_group_allow, :is_end
+ attr_accessible :code, :extra, :name, :state, :tea_id, :time , :location, :state, :term, :password,:is_public,:description,:class_period, :open_student, :enterprise_name, :is_delete, :syllabus_id, :end_time, :end_term, :choose_group_allow, :is_end, :homepage_show
#belongs_to :project, :class_name => 'Course', :foreign_key => :extra, primary_key: :identifier
belongs_to :teacher, :class_name => 'User', :foreign_key => :tea_id, :dependent => :destroy # 定义一个方法teacher,该方法通过tea_id来调用User表
belongs_to :school, :class_name => 'School', :foreign_key => :school_id #定义一个方法school,该方法通过school_id来调用School表
@@ -105,7 +105,8 @@ class Course < ActiveRecord::Base
'end_term',
'os_allow',
'choose_group_allow',
- 'credit'
+ 'credit',
+ 'homepage_show'
acts_as_customizable
diff --git a/app/models/shixun.rb b/app/models/shixun.rb
index 28c40a2f3..482cf8ea4 100644
--- a/app/models/shixun.rb
+++ b/app/models/shixun.rb
@@ -9,7 +9,7 @@
#
class Shixun < ActiveRecord::Base
attr_accessible :description, :is_public, :name, :changeset_num, :status, :user_id, :gpid, :language, :identifier, :authentication,
- :myshixun_count, :propaedeutics, :trainee, :major_id
+ :myshixun_count, :propaedeutics, :trainee, :major_id, :homepage_show
has_many :users, :through => :shixun_members
has_many :shixun_members, :dependent => :destroy
diff --git a/app/views/layouts/_course_left_info.html.erb b/app/views/layouts/_course_left_info.html.erb
index daec34013..532e8d940 100644
--- a/app/views/layouts/_course_left_info.html.erb
+++ b/app/views/layouts/_course_left_info.html.erb
@@ -46,7 +46,7 @@
- 统计
+ 统计
\ No newline at end of file
diff --git a/app/views/layouts/base_management.html.erb b/app/views/layouts/base_management.html.erb
index db8f7b39b..e42bdcc82 100644
--- a/app/views/layouts/base_management.html.erb
+++ b/app/views/layouts/base_management.html.erb
@@ -36,17 +36,17 @@
<% when 6 %>
<%= @sub_type == 1 ? "单位列表" :"单位部门列表" %>
<% when 7 %>
- <%= @sub_type == 1 ? "用户列表" :"适用授权列表" %>
+ <%= @sub_type == 1 ? "用户列表" :"试用授权列表" %>
<% when 8 %>
消息
<% when 9 %>
留言
<% when 10 %>
- <%= @sub_type == 1 ? "身份认证":(@sub_type == 2? "适用授权":(@sub_type == 3?"部门审批":(@sub_type == 4?"单位审批":(@sub_type == 5?"项目实训发布":"课程实训发布"))))%>
+ <%= @sub_type == 1 ? "身份认证":(@sub_type == 2? "试用授权":(@sub_type == 3?"部门审批":(@sub_type == 4?"单位审批":(@sub_type == 5?"项目实训发布":"课程实训发布"))))%>
<% when 11 %>
工程认证+
<% when 12 %>
- 其他
+ <%= @sub_type == 1 ?"专业列表" : "实训适用课程列表" %>
<% end %>
@@ -97,7 +97,7 @@
工程认证+
-