|
|
@ -1164,69 +1164,65 @@ class ExercisesController < ApplicationController
|
|
|
|
@course_all_members = @course.students
|
|
|
|
@course_all_members = @course.students
|
|
|
|
@c_group_counts = @course.course_groups_count
|
|
|
|
@c_group_counts = @course.course_groups_count
|
|
|
|
question_types = @exercise.exercise_questions.pluck(:question_type).uniq
|
|
|
|
question_types = @exercise.exercise_questions.pluck(:question_type).uniq
|
|
|
|
@exercise_publish_count = get_user_permission_course(exercise_ids,2).count #判断是否有已发布的分班
|
|
|
|
@exercise_publish_count = get_user_permission_course(exercise_ids,Exercise::PUBLISHED).count #判断是否有已发布的分班
|
|
|
|
@exercise_unpublish_count = get_user_permission_course(exercise_ids,1).count #判断是否有未发布的分班
|
|
|
|
@exercise_unpublish_count = get_user_permission_course(exercise_ids,Exercise::UNPUBLISHED).count #判断是否有未发布的分班
|
|
|
|
|
|
|
|
|
|
|
|
if (question_types.size > 1) && question_types.include?(4) #是否包含主观题,或者是否大于1
|
|
|
|
if (question_types.size > 1) && question_types.include?(Exercise::SUBJECTIVE) #是否包含主观题,或者是否大于1
|
|
|
|
@subjective_type = 1
|
|
|
|
@subjective_type = 1
|
|
|
|
else
|
|
|
|
else
|
|
|
|
@subjective_type = 0
|
|
|
|
@subjective_type = 0
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#初始化值
|
|
|
|
|
|
|
|
@exercise_users_list = [] #答题用户列表
|
|
|
|
|
|
|
|
@exercise_course_groups = [] #当前用户有权限的班级
|
|
|
|
|
|
|
|
@exercise_unanswers = 0 # 未答用户数
|
|
|
|
|
|
|
|
@exercise_answers = 0 #已答用户数
|
|
|
|
|
|
|
|
@exercise_users_count = 0 #全部用户数
|
|
|
|
|
|
|
|
@teacher_review_count = 0 #已评数
|
|
|
|
|
|
|
|
@teacher_unreview_count = 0 #未评数
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#试卷的答题列表页的显示用户
|
|
|
|
if @user_course_identity < Course::STUDENT #当前为老师,而且老师只能查看自己班级的/课堂的试卷
|
|
|
|
if @user_course_identity < Course::STUDENT #当前为老师,而且老师只能查看自己班级的/课堂的试卷
|
|
|
|
@exercise_current_user_status = 0
|
|
|
|
@exercise_current_user_status = 0
|
|
|
|
if @exercise_status == 1
|
|
|
|
unless @exercise_status == 1
|
|
|
|
@exercise_users_list = []
|
|
|
|
|
|
|
|
@exercise_course_groups = []
|
|
|
|
|
|
|
|
@exercise_unanswers = 0
|
|
|
|
|
|
|
|
@exercise_answers = 0
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
ex_common_ids = @exercise.common_published_ids(current_user.id)
|
|
|
|
ex_common_ids = @exercise.common_published_ids(current_user.id)
|
|
|
|
@exercise_course_groups = @course.get_ex_published_course(ex_common_ids)
|
|
|
|
@exercise_course_groups = @course.get_ex_published_course(ex_common_ids)
|
|
|
|
@exercise_users_list = @exercise.all_exercise_users(current_user.id) #当前老师所在班级的全部学生
|
|
|
|
@exercise_users_list = @exercise.all_exercise_users(current_user.id) #当前老师所在班级的全部学生
|
|
|
|
get_exercise_answers(@exercise_users_list, @exercise_status)
|
|
|
|
get_exercise_answers(@exercise_users_list, @exercise_status)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
elsif @user_course_identity > Course::ASSISTANT_PROFESSOR #当前为学生或者有过答题的(提交/未提交)
|
|
|
|
else #当前为学生或者有过答题的
|
|
|
|
@ex_user_end_time = @exercise.get_exercise_end_time(current_user.id) #当前用户所看到的剩余时间
|
|
|
|
@ex_user_end_time = @exercise.get_exercise_end_time(current_user.id) #当前用户所看到的剩余时间
|
|
|
|
@exercise_all_users = @exercise.get_stu_exercise_users
|
|
|
|
@exercise_all_users = @exercise.get_stu_exercise_users
|
|
|
|
get_exercise_answers(@exercise_all_users, @exercise_status) # 未答和已答的
|
|
|
|
get_exercise_answers(@exercise_all_users, @exercise_status) # 未答和已答的
|
|
|
|
exercise_current_user = @exercise_all_users.exercise_commit_users(current_user.id) #当前用户是否开始做试卷(提交/未提交/没做)
|
|
|
|
exercise_current_user = @exercise_all_users.exercise_commit_users(current_user.id)
|
|
|
|
if exercise_current_user.present?
|
|
|
|
if exercise_current_user.exists? #表示为课堂学生或已回答的
|
|
|
|
@exercise_current_user_status = 1 #当前用户的状态,为学生
|
|
|
|
@exercise_current_user_status = 1
|
|
|
|
if @exercise.score_open && @exercise_status == 3 && exercise_current_user.present? #勾选了成绩公开且试卷已截止的
|
|
|
|
if @exercise.score_open && @exercise_status == 3 #勾选了成绩公开且试卷已截止的
|
|
|
|
all_user_ids = @exercise_all_users.pluck(:user_id)
|
|
|
|
all_user_ids = @exercise_all_users.pluck(:user_id)
|
|
|
|
all_user_ids.delete(current_user.id) #删除了当前用户的ID
|
|
|
|
all_user_ids.delete(current_user.id) #删除了当前用户的ID
|
|
|
|
@exercise_users_list = @exercise_all_users.exercise_commit_users(all_user_ids).distinct
|
|
|
|
@exercise_users_list = @exercise_all_users.exercise_commit_users(all_user_ids).distinct
|
|
|
|
@current_user_ex_answers = exercise_current_user #当前用户的回答
|
|
|
|
@current_user_ex_answers = exercise_current_user #当前用户的回答
|
|
|
|
else
|
|
|
|
else
|
|
|
|
@exercise_users_list = exercise_current_user.present? ? exercise_current_user.distinct : []
|
|
|
|
@exercise_users_list = exercise_current_user
|
|
|
|
end
|
|
|
|
end
|
|
|
|
else
|
|
|
|
else #表示为未回答的,或未非课堂成员的
|
|
|
|
@exercise_all_users = @exercise.get_stu_exercise_users
|
|
|
|
|
|
|
|
get_exercise_answers(@exercise_all_users, @exercise_status) # 未答和已答的
|
|
|
|
|
|
|
|
@exercise_current_user_status = 2 #当前用户非课堂成员
|
|
|
|
@exercise_current_user_status = 2 #当前用户非课堂成员
|
|
|
|
@exercise_users_list = []
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
if @exercise_users_list.present? && @exercise_users_list.count > 0
|
|
|
|
|
|
|
|
@exercise_users_count = @exercise_users_list.count #当前显示的全部成员数量
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
@exercise_users_count = 0
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
if @exercise_unanswers < 0
|
|
|
|
if @exercise_unanswers < 0
|
|
|
|
@exercise_unanswers = 0
|
|
|
|
@exercise_unanswers = 0
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
@teacher_review_count = 0
|
|
|
|
|
|
|
|
@teacher_unreview_count = 0
|
|
|
|
|
|
|
|
#筛选/分类,排序
|
|
|
|
#筛选/分类,排序
|
|
|
|
order = params[:order]
|
|
|
|
order = params[:order]
|
|
|
|
if @exercise_users_list.present? && @exercise_users_list.size > 0
|
|
|
|
if @exercise_users_list.exists? && @exercise_users_list.size > 0
|
|
|
|
|
|
|
|
@exercise_users_count = @exercise_users_list.size #当前显示的全部成员数量
|
|
|
|
teacher_reviews = @exercise_users_list.exercise_review
|
|
|
|
teacher_reviews = @exercise_users_list.exercise_review
|
|
|
|
teacher_unreviews = @exercise_users_list.exercise_unreview
|
|
|
|
teacher_unreviews = @exercise_users_list.exercise_unreview
|
|
|
|
@teacher_review_count = teacher_reviews.count #已评阅
|
|
|
|
@teacher_review_count = teacher_reviews.size #已评阅
|
|
|
|
@teacher_unreview_count = teacher_unreviews.count #未评阅
|
|
|
|
@teacher_unreview_count = teacher_unreviews.size #未评阅
|
|
|
|
|
|
|
|
|
|
|
|
#是否评阅
|
|
|
|
#是否评阅
|
|
|
|
if params[:review].present?
|
|
|
|
if params[:review].present?
|
|
|
@ -1284,7 +1280,7 @@ class ExercisesController < ApplicationController
|
|
|
|
if params[:format] == "xlsx"
|
|
|
|
if params[:format] == "xlsx"
|
|
|
|
if @user_course_identity > Course::ASSISTANT_PROFESSOR
|
|
|
|
if @user_course_identity > Course::ASSISTANT_PROFESSOR
|
|
|
|
tip_exception(403,"无权限操作")
|
|
|
|
tip_exception(403,"无权限操作")
|
|
|
|
elsif @exercise_status == 1
|
|
|
|
elsif @exercise_status == Exercise::UNPUBLISHED
|
|
|
|
normal_status(-1,"试卷未发布")
|
|
|
|
normal_status(-1,"试卷未发布")
|
|
|
|
elsif (@exercise_users_size == 0) || ( @export_ex_users&.exercise_user_committed.size == 0)
|
|
|
|
elsif (@exercise_users_size == 0) || ( @export_ex_users&.exercise_user_committed.size == 0)
|
|
|
|
normal_status(-1,"暂无用户提交")
|
|
|
|
normal_status(-1,"暂无用户提交")
|
|
|
@ -1530,30 +1526,22 @@ class ExercisesController < ApplicationController
|
|
|
|
def get_user_permission_course(exercise_ids,status)
|
|
|
|
def get_user_permission_course(exercise_ids,status)
|
|
|
|
exercise_status = status.to_i #传入的试卷发布状态
|
|
|
|
exercise_status = status.to_i #传入的试卷发布状态
|
|
|
|
unpublish_group = []
|
|
|
|
unpublish_group = []
|
|
|
|
# g_course_ids = @course.teacher_course_groups.get_user_groups(current_user.id).pluck(:course_group_id).reject(&:blank?).uniq #当前用户有权限的分班
|
|
|
|
course_groups = []
|
|
|
|
# #用户的班级,理论上用户的班级要大于等于试卷设置的班级
|
|
|
|
|
|
|
|
# if g_course_ids.blank? || g_course_ids.include?(0)
|
|
|
|
|
|
|
|
# user_groups_id = @course.course_groups.pluck(:id)
|
|
|
|
|
|
|
|
# else
|
|
|
|
|
|
|
|
# user_groups_id = g_course_ids
|
|
|
|
|
|
|
|
# end
|
|
|
|
|
|
|
|
user_groups_id = @course.charge_group_ids(current_user)
|
|
|
|
user_groups_id = @course.charge_group_ids(current_user)
|
|
|
|
exercises_all = Exercise.where(id:exercise_ids)
|
|
|
|
exercises_all = Exercise.includes(:exercise_group_settings).where(id:exercise_ids)
|
|
|
|
exercises_all.each do |exercise|
|
|
|
|
exercises_all.each do |exercise|
|
|
|
|
if exercise.present?
|
|
|
|
if exercise.present?
|
|
|
|
if exercise.unified_setting #统一设置只有两种情况,全部发布,全部截止
|
|
|
|
if exercise.unified_setting #统一设置只有两种情况,全部发布,全部截止
|
|
|
|
exercise_user_status = exercise.get_exercise_status(current_user) #当前用户的能看到的试卷
|
|
|
|
exercise_user_status = exercise.get_exercise_status(current_user) #当前用户的能看到的试卷
|
|
|
|
if (exercise_user_status == exercise_status) || exercise_status == 3 #未发布的情况
|
|
|
|
if (exercise_user_status == exercise_status) || exercise_status == Exercise::ENDED #未发布的情况
|
|
|
|
unpublish_group = unpublish_group + user_groups_id
|
|
|
|
unpublish_group = unpublish_group + user_groups_id
|
|
|
|
else
|
|
|
|
|
|
|
|
unpublish_group = []
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
else
|
|
|
|
else
|
|
|
|
ex_all_group_settings = exercise.exercise_group_settings
|
|
|
|
ex_all_group_settings = exercise.exercise_group_settings
|
|
|
|
ex_group_settings = ex_all_group_settings.exercise_group_published.pluck(:course_group_id).uniq #问卷设置的班级
|
|
|
|
ex_group_settings = ex_all_group_settings.exercise_group_published.pluck(:course_group_id).uniq #问卷设置的班级
|
|
|
|
if exercise_status == 1
|
|
|
|
if exercise_status == Exercise::UNPUBLISHED
|
|
|
|
unpublish_group = user_groups_id - ex_group_settings
|
|
|
|
unpublish_group = user_groups_id - ex_group_settings
|
|
|
|
elsif exercise_status == 3
|
|
|
|
elsif exercise_status == Exercise::ENDED
|
|
|
|
ex_ended_groups = ex_all_group_settings.exercise_group_ended.pluck(:course_group_id).uniq
|
|
|
|
ex_ended_groups = ex_all_group_settings.exercise_group_ended.pluck(:course_group_id).uniq
|
|
|
|
ex_and_user = user_groups_id & ex_group_settings #用户已设置的分班
|
|
|
|
ex_and_user = user_groups_id & ex_group_settings #用户已设置的分班
|
|
|
|
unpublish_group = unpublish_group + ex_and_user - ex_ended_groups #已发布的全部班级减去截止的全部班级
|
|
|
|
unpublish_group = unpublish_group + ex_and_user - ex_ended_groups #已发布的全部班级减去截止的全部班级
|
|
|
@ -1567,8 +1555,6 @@ class ExercisesController < ApplicationController
|
|
|
|
unpublish_group = unpublish_group.uniq
|
|
|
|
unpublish_group = unpublish_group.uniq
|
|
|
|
if unpublish_group.count > 0
|
|
|
|
if unpublish_group.count > 0
|
|
|
|
course_groups = CourseGroup.by_group_ids(unpublish_group)
|
|
|
|
course_groups = CourseGroup.by_group_ids(unpublish_group)
|
|
|
|
else
|
|
|
|
|
|
|
|
course_groups = []
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
course_groups
|
|
|
|
course_groups
|
|
|
|
end
|
|
|
|
end
|
|
|
|