From 2912f320411ae9bcedc14368e02bca0b17f87c88 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Mon, 20 May 2019 17:37:30 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B6=85=E7=BA=A7=E7=AE=A1=E7=90=86=E5=91=98?= =?UTF-8?q?=E7=9A=84=E8=AF=BE=E5=A0=82=E5=88=97=E8=A1=A8=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20=E8=AF=BE=E5=A0=82=E5=AD=A6=E7=94=9F?= =?UTF-8?q?=E7=9A=84=E2=80=9C=E8=AF=84=E6=B5=8B=E6=AC=A1=E6=95=B0=E2=80=9D?= =?UTF-8?q?=E7=BB=9F=E8=AE=A1=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/course.rb | 9 +++++++++ app/views/managements/_classroom_classment_list.html.erb | 2 ++ 2 files changed, 11 insertions(+) diff --git a/app/models/course.rb b/app/models/course.rb index 843d846d..c6c6d3df 100644 --- a/app/models/course.rb +++ b/app/models/course.rb @@ -500,6 +500,15 @@ class Course < ActiveRecord::Base end end + # 课堂实训作业的评测次数 + def evaluate_count + course_user_ids = self.members.map(&:user_id) + shixun_ids = self.homework_commons.joins(:homework_commons_shixuns).where(homework_type: 4).pluck(:shixun_id) + return 0 if shixun_ids.blank? + Game.joins(:challenge).where(challenges: {shixun_id: shixun_ids}, games: {user_id: course_user_ids}).sum(:evaluate_count) + end + + #课程动态公共表记录 def act_as_course_activity self.course_acts << CourseActivity.new(:user_id => self.tea_id,:course_id => self.id) diff --git a/app/views/managements/_classroom_classment_list.html.erb b/app/views/managements/_classroom_classment_list.html.erb index 5051be80..25b13911 100644 --- a/app/views/managements/_classroom_classment_list.html.erb +++ b/app/views/managements/_classroom_classment_list.html.erb @@ -9,6 +9,7 @@