From a165d895c3ec1739dd9e16b2bb504d909da4169e Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Wed, 8 Jan 2020 10:59:32 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9E=E8=AE=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/subjects/data_statistic_service.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/services/subjects/data_statistic_service.rb b/app/services/subjects/data_statistic_service.rb index 9311953ca..29696cf15 100644 --- a/app/services/subjects/data_statistic_service.rb +++ b/app/services/subjects/data_statistic_service.rb @@ -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