超级管理员的课堂列表页面增加 课堂学生的“评测次数”统计显示

dev_ec
daiao 6 years ago
parent 8d44fea995
commit 2912f32041

@ -500,6 +500,15 @@ class Course < ActiveRecord::Base
end end
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 def act_as_course_activity
self.course_acts << CourseActivity.new(:user_id => self.tea_id,:course_id => self.id) self.course_acts << CourseActivity.new(:user_id => self.tea_id,:course_id => self.id)

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

Loading…
Cancel
Save