diff --git a/app/api/mobile/entities/course.rb b/app/api/mobile/entities/course.rb index 060f43614..88c8ba144 100644 --- a/app/api/mobile/entities/course.rb +++ b/app/api/mobile/entities/course.rb @@ -57,14 +57,21 @@ module Mobile expose :can_setting, if: lambda { |instance, options| options[:user] } do |instance, options| current_user = options[:user] can_setting = false - member = instance.members.where("user_id=#{current_user.id} and course_id=#{instance.id}")[0] + + if instance[:course] + course = instance[:course] + else + course = instance + end + + member = course.members.where("user_id=#{current_user.id} and course_id=#{course.id}")[0] roleName = member.roles[0].name if member if roleName && (roleName == "TeachingAsistant" || roleName == "Teacher" ) can_setting = true end - if instance.tea_id == current_user.id + if course.tea_id == current_user.id can_setting = true end can_setting