diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb index fb7214fce..2d2d83174 100644 --- a/app/helpers/courses_helper.rb +++ b/app/helpers/courses_helper.rb @@ -40,9 +40,14 @@ module CoursesHelper a_courses << c.id end a_courses << a_tags unless a_tags.length == 0 + ids = a_courses.flatten.uniq + ids_count = ids.length + limit = 5 - ids_count.to_i + sql = "SELECT distinct c.id FROM course_activities cs, courses c where cs.course_id = c.id and c.is_excellent =1 order by cs.updated_at desc;" + default_ecourse = Course.find_by_sql(sql).where("id is not in (?)", a_courses.ids) + arr_result = ids << default_ecourse # 过滤条件:精品课程、本身不在搜索范围 - e_courses = Course.where("is_excellent =? and id in (?)",1,a_courses.flatten.uniq).where("id !=?",current_course.id) - e_courses + e_courses = Course.where("is_excellent =? and id in (?)",1,).where("id !=?", arr_result, current_course.id) end # 判断精品课程是否可见,非课程成员无法查看私有课程