You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
923 B
24 lines
923 B
class Weapps::HomesController < Weapps::BaseController
|
|
before_action :require_login
|
|
|
|
def show
|
|
# banner
|
|
@carousels = WeappSettings::Carousel.only_online
|
|
# 广告
|
|
@advert = WeappSettings::Advert.only_online.first
|
|
|
|
# 我的课堂
|
|
@category = params[:category] && ["manage", "study"].include?(params[:category]) ? params[:category] : (current_user.is_teacher? ? "manage" : "study")
|
|
@courses = case @category
|
|
when 'study' then
|
|
current_user.as_student_courses.started
|
|
when 'manage' then
|
|
current_user.manage_courses
|
|
end
|
|
@courses = @courses.not_deleted.not_excellent
|
|
@course_count = @courses.count
|
|
order_str = "course_members.sticky=1 desc, course_members.sticky_time desc, courses.created_at desc"
|
|
@courses = paginate(@courses.order(order_str).includes(:teacher, :school))
|
|
@user = current_user
|
|
end
|
|
end |