|
|
|
@ -47,19 +47,19 @@ class CoursesController < ApplicationController
|
|
|
|
|
@order = params[:order].present? ? params[:order] : "all"
|
|
|
|
|
order_str = @order != "course_members_count" && @order != "created_at" ? "updated_at" : @order
|
|
|
|
|
|
|
|
|
|
if @order == "all"
|
|
|
|
|
# if @order == "all"
|
|
|
|
|
# @course = Course.where(is_delete: 0, is_hidden: 0).select("select c.name, c.id, s.name, u.login, ifnull(concat(u.lastname,u.firstname),
|
|
|
|
|
# u.login), s.name from courses c, users u, user_extensions ue, schools s where c.is_delete=0 and
|
|
|
|
|
# c.tea_id=u.id and u.id=ue.user_id and ue.school_id=s.id")
|
|
|
|
|
|
|
|
|
|
@courses = Course.where(is_delete: 0, is_hidden: 0)
|
|
|
|
|
.order("courses.id = 1309 desc, courses.created_at desc")
|
|
|
|
|
# @courses = Course.where(is_delete: 0, is_hidden: 0)
|
|
|
|
|
# .order("courses.id = 1309 desc, courses.created_at desc")
|
|
|
|
|
|
|
|
|
|
# @courses = Course.where(is_delete: 0, is_hidden: 0).select("courses.id, courses.tea_id, courses.name, courses.exercises_count, courses.polls_count,
|
|
|
|
|
# courses.is_public, courses.is_end, courses.visits, courses.course_members_count,courses.homework_commons_count,(SELECT MAX(created_at)
|
|
|
|
|
# FROM `course_activities` WHERE course_activities.course_id = courses.id) AS a")
|
|
|
|
|
# .order("courses.id = 1309 desc, a desc")
|
|
|
|
|
elsif @order == "mine"
|
|
|
|
|
if @order == "mine"
|
|
|
|
|
@courses = Course.joins(:course_members)
|
|
|
|
|
.where("is_delete = 0 AND is_hidden = 0 AND course_members.user_id = ?", @user.id)
|
|
|
|
|
.order("courses.id = 1309 DESC, courses.#{order_str} DESC")
|
|
|
|
@ -86,7 +86,7 @@ class CoursesController < ApplicationController
|
|
|
|
|
(course_members.role in(1,2,3) and CONCAT(users.lastname, users.firstname) like :keyword) or courses.name like :keyword
|
|
|
|
|
or schools.name like :keyword
|
|
|
|
|
}
|
|
|
|
|
@courses = @courses.joins(:school, course_members: [user: :user_extension])
|
|
|
|
|
@courses = @courses.joins(:school, course_members: :user)
|
|
|
|
|
.where("#{sql}", keyword: "%#{params[:search]}%").distinct
|
|
|
|
|
end
|
|
|
|
|
@courses_count = @courses.size
|
|
|
|
|