将未命名课程去掉

This commit is contained in:
yuanke 2016-07-13 08:44:20 +08:00
parent 4a7fb0e0b5
commit f63df877db
1 changed files with 8 additions and 13 deletions

View File

@ -29,19 +29,13 @@ class SyllabusesService
end
#获取指定用户的课程大纲
def user_syllabus(user)
courses = CoursesService.new.user_courses_list(user)
other = Syllabus.new(title: '未命名课程',user_id: user.id)
courses.each do |c|
other.courses << c[:course] unless c[:course].syllabus
end
# user.syllabuses.each do |syllabus|
# syllabus.courses = syllabus.courses.not_deleted
# end
# courses = CoursesService.new.user_courses_list(user)
#
# user.syllabuses.to_a << other
# other = Syllabus.new(title: '未命名课程',user_id: user.id)
#
# courses.each do |c|
# other.courses << c[:course] unless c[:course].syllabus
# end
courses = user.courses.not_deleted
syllabus_ids = courses.empty? ? '(-1)' : "(" + courses.map{|course| !course.syllabus_id.nil? && course.syllabus_id}.join(",") + ")"
@ -51,8 +45,9 @@ class SyllabusesService
syllabus.courses = courses.where("syllabus_id = #{syllabus.id}").select("courses.*,(SELECT MAX(updated_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS updatetime").order("time desc")
end
syllabuses.to_a << other
# syllabuses.to_a << other
syllabuses.to_a
#管理权限 can_setting
syllabuses.each do |s|
s = judge_can_setting(s,user)