试卷列表的调整

dev_course
cxt 5 years ago
parent c92dd248fc
commit e3d21286f3

@ -60,7 +60,8 @@ class Exercise < ApplicationRecord
ex_users = exercise_users ex_users = exercise_users
group_ids = common_published_ids(user_id) group_ids = common_published_ids(user_id)
if group_ids.present? if group_ids.present?
ex_users = ex_users.where(user_id: course.students.where(course_group_id: group_ids).select(:user_id).pluck(:user_id)) ex_users = ex_users.joins("join course_members on exercise_users.user_id=course_members.user_id").
where(course_members: {course_group_id: group_ids})
end end
ex_users ex_users
end end
@ -69,8 +70,9 @@ class Exercise < ApplicationRecord
def common_published_ids(user_id) def common_published_ids(user_id)
current_user_groups = course.teacher_course_ids(user_id) current_user_groups = course.teacher_course_ids(user_id)
if unified_setting if unified_setting
un_group_ids = (course.none_group_count > 0) ? [0] : [] # un_group_ids = (course.none_group_count > 0) ? [0] : []
published_group_ids = (current_user_groups + un_group_ids).uniq #统一设置时为当前用户的分班id及未分班 # published_group_ids = (current_user_groups + un_group_ids).uniq #统一设置时为当前用户的分班id及未分班
published_group_ids = current_user_groups
else else
ex_group_setting = exercise_group_settings.select(:course_group_id).pluck("course_group_id").uniq ex_group_setting = exercise_group_settings.select(:course_group_id).pluck("course_group_id").uniq
common_all_ids = ex_group_setting & current_user_groups #当前用户有权限的已发布的分班id #非统一设置时为当前用户有权限的且已发布分班的id common_all_ids = ex_group_setting & current_user_groups #当前用户有权限的已发布的分班id #非统一设置时为当前用户有权限的且已发布分班的id

Loading…
Cancel
Save