Include hidden exercises for other teachers of the same study group
This commit is contained in:
@ -38,7 +38,13 @@ class ExercisePolicy < AdminOrAuthorPolicy
|
||||
if @user.admin?
|
||||
@scope.all
|
||||
elsif @user.teacher?
|
||||
@scope.where('user_id = ? OR public = TRUE', @user.id)
|
||||
@scope.where(
|
||||
'user_id IN (SELECT user_id FROM study_group_memberships WHERE study_group_id IN (?))
|
||||
OR (user_id = ? AND user_type = ?)
|
||||
OR public = TRUE',
|
||||
@user.study_groups.pluck(:id),
|
||||
@user.id, @user.class.name
|
||||
)
|
||||
else
|
||||
@scope.none
|
||||
end
|
||||
|
Reference in New Issue
Block a user