diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 48f644a14..46ac514b4 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -99,7 +99,7 @@ class CoursesController < ApplicationController limit = params[:limit] || 16 @courses = @courses.page(page).per(limit) - @courses = @courses.preload(:school, :none_hidden_course_modules, :teacher_users, teacher: :user_extension) + @courses = @courses.preload(:school, :none_hidden_course_modules, teacher: :user_extension) end def course_videos diff --git a/app/controllers/weapps/courses_controller.rb b/app/controllers/weapps/courses_controller.rb index 2a375a7fb..1dec62201 100644 --- a/app/controllers/weapps/courses_controller.rb +++ b/app/controllers/weapps/courses_controller.rb @@ -76,6 +76,7 @@ class Weapps::CoursesController < Weapps::BaseController def show @course = current_course @current_user = current_user + @teacher_users = @course.teacher_users.where.not(user_id: @course.tea_id).map(&:real_name)[0..2] end def shixun_homework_category diff --git a/app/controllers/weapps/homes_controller.rb b/app/controllers/weapps/homes_controller.rb index e53923fa8..3e94354a2 100644 --- a/app/controllers/weapps/homes_controller.rb +++ b/app/controllers/weapps/homes_controller.rb @@ -19,7 +19,7 @@ class Weapps::HomesController < Weapps::BaseController @courses = @courses.where(id: current_laboratory.all_courses) @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)) + @courses = paginate(@courses.order(order_str).includes(:teacher_users, :teacher, :school)) @user = current_user end end \ No newline at end of file diff --git a/app/views/courses/index.json.jbuilder b/app/views/courses/index.json.jbuilder index a8b70c435..f9bceebb8 100644 --- a/app/views/courses/index.json.jbuilder +++ b/app/views/courses/index.json.jbuilder @@ -13,6 +13,5 @@ json.courses @courses do |course| json.is_end course.is_end json.first_category_url module_url(course.none_hidden_course_modules.first, course) json.excellent course.excellent - json.teacher_users course.teacher_users.select{|u| u.id != course.tea_id }.map(&:real_name)[0..2] # 取前3名老师 end json.courses_count @courses_count diff --git a/app/views/weapps/courses/show.json.jbuilder b/app/views/weapps/courses/show.json.jbuilder index c22b24426..cf58315b4 100644 --- a/app/views/weapps/courses/show.json.jbuilder +++ b/app/views/weapps/courses/show.json.jbuilder @@ -1,4 +1,5 @@ json.(@course, :id, :name, :course_members_count, :credit, :invite_code_halt) json.teachers_count @course.teachers.count json.students_count @course.students.count -json.course_identity @current_user.course_identity(@course) \ No newline at end of file +json.course_identity @current_user.course_identity(@course) +json.teacher_users @teacher_users \ No newline at end of file diff --git a/app/views/weapps/homes/show.json.jbuilder b/app/views/weapps/homes/show.json.jbuilder index f307d64fe..5d0e35e05 100644 --- a/app/views/weapps/homes/show.json.jbuilder +++ b/app/views/weapps/homes/show.json.jbuilder @@ -26,5 +26,6 @@ json.courses @courses.each do |course| course_member = @category == "study" ? course.students.where(user_id: @user.id).first : course.teachers.where(user_id: @user.id).first json.sticky course_member.sticky json.course_identity current_user.course_identity(course) + json.teacher_users course.teacher_users.select{|u| u.id != course.tea_id }.map(&:real_name)[0..2] # 取前3名老师 end