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 @@ 普通作业 实训作业 试卷 + 评测次数 私有 状态 创建者单位 @@ -28,6 +29,7 @@ <%= course.homework_commons.where(:homework_type => 1).count %> <%= course.homework_commons.where(:homework_type => 4).count %> <%= course.exercises.count %> + <%= course.evaluate_count %> <%= course.is_public.to_i == 1 ? '--' : '√' %> <%= course.is_end ? "已结束" : "正在进行" %> <%= course.teacher.try(:user_extensions).try(:school).try(:name).blank? ? "--" : course.teacher.try(:user_extensions).try(:school) %>