dev_daiao
daiao 5 years ago
parent 3f0e5b95ec
commit a165d895c3

@ -3,7 +3,7 @@ class Subjects::DataStatisticService < ApplicationService
def initialize(subject, user)
@subject = subject
@user = user
@shixuns = subject.shixuns
@shixun_ids = subject.shixuns.pluck(:id)
end
# 学习总人数
@ -14,9 +14,11 @@ class Subjects::DataStatisticService < ApplicationService
# 课堂学习人数
def course_study_count
# 实训作业
sw_user_ids = StudentWork.where.not(myshixun_id: nil).pluck(:user_id)
sw_user_ids = StudentWork.where.not(myshixun_id: nil).joins(homework_common: :homework_commons_shixuns)
.where(homework_commons_shixuns: {shixun_id: @shixun_ids}).pluck("student_works.user_id")
# 试卷的实训题
esa_user_ids = ExerciseShixunAnswer.where()
esa_user_ids = ExerciseShixunAnswer.joins(exercise_shixun_challenge: :shixun)
.where(shixuns: {id: @shixun_ids}).pluck("exercise_shixun_answers.user_id")
end
end

Loading…
Cancel
Save