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 @@