Merge branch 'develop' into dev_aliyun

courseware
cxt 5 years ago
commit 04129a8526

@ -7,13 +7,13 @@ class Admins::CoursesController < Admins::BaseController
courses = Admins::CourseQuery.call(params)
@ended_courses = courses.where(is_end: 1).size
@processed_courses = courses.where(is_end: 0).size
@courses = paginate courses.includes(:school, :students, :attachments, :homework_commons, teacher: :user_extension)
@courses = paginate courses.includes(:school, :students, :teacher_course_members, :informs, :course_videos, :attachments, :homework_commons, teacher: :user_extension)
respond_to do |format|
format.js
format.html
format.xlsx do
@courses = courses.includes(:school, :students, :attachments, :homework_commons, :course_acts, teacher: :user_extension)
@courses = courses.includes(:school, :students, :teacher_course_members, :informs, :course_videos, :attachments, :homework_commons, :course_activities, teacher: [user_extension: :department])
filename = "课堂列表_#{Time.current.strftime('%Y%m%d%H%M%S')}.xlsx"
render xlsx: 'index', filename: filename
end

@ -406,6 +406,15 @@ class Course < ApplicationRecord
homework_commons.select{|homework| homework.homework_type == type}.size
end
# 课堂作业数
def published_course_homework_count type
homework_commons.select{|homework| homework.homework_type == type && homework.publish_time.present? && homework.publish_time <= Time.now}.size
end
def student_works_count
StudentWork.joins(:homework_common).where(homework_commons: {course_id: id}).where("work_status > 0").size
end
private
#创建课程后,给该用户发送消息

@ -3,22 +3,28 @@ wb = xlsx_package.workbook
wb.styles do |s|
blue_cell = s.add_style :bg_color => "FAEBDC", :sz => 10,:height => 25,:b => true, :border => { :style => :thin, :color =>"000000" },:alignment => {wrap_text: true,:horizontal => :center,:vertical => :center}
wb.add_worksheet(name: "课堂列表") do |sheet|
sheet.add_row %w(ID 课堂名称 成员 资源 普通作业 分组作业 实训作业 试卷 评测次数 私有 状态 单位 创建者 创建时间 动态时间), :height => 25,:style => blue_cell
sheet.add_row %w(ID 课堂名称 老师 学生 资源 公告 视频 普通作业 分组作业 实训作业 实训作业已发布数 作品数 试卷 评测次数 私有 状态 单位 部门 创建者 创建时间 动态时间), :height => 25,:style => blue_cell
@courses.each do |course|
data = [
course.id,
course.name,
course.course_members_count,
course.teacher_course_members.size,
course.students.size,
get_attachment_count(course, 0),
course.course_homework_count(1),
course.course_homework_count(3),
course.course_homework_count(4),
course.informs.size,
course.course_videos.size,
course.course_homework_count("normal"),
course.course_homework_count("group"),
course.course_homework_count("practice"),
course.published_course_homework_count("practice"),
course.student_works_count,
course.exercises_count,
course.evaluate_count,
course.is_public == 1 ? "--" : "√",
course.is_end ? "已结束" : "正在进行",
course.school&.name,
course.teacher&.department_name,
course.teacher&.real_name,
course.created_at&.strftime('%Y-%m-%d %H:%M'),
course.max_activity_time ? course.max_activity_time&.strftime('%Y-%m-%d %H:%M') : "--"

@ -3,18 +3,22 @@
<tr>
<th width="4%">序号</th>
<th width="4%">ID</th>
<th width="10%" class="text-left">课堂名称</th>
<th width="5%">成员</th>
<th width="8%" class="text-left">课堂名称</th>
<th width="4%">老师</th>
<th width="4%">学生</th>
<th width="4%">资源</th>
<th width="4%">公告</th>
<th width="4%">视频</th>
<th width="4%">普通作业</th>
<th width="4%">分组作业</th>
<th width="4%">实训作业</th>
<th width="4%">作品数</th>
<th width="4%">试卷</th>
<th width="6%">评测次数</th>
<th width="4%">私有</th>
<th width="6%">状态</th>
<th width="10%">单位</th>
<th width="7%">创建者</th>
<th width="4%">状态</th>
<th width="8%">单位</th>
<th width="6%">创建者</th>
<th width="10%"><%= sort_tag('创建时间', name: 'created_at', path: admins_courses_path) %></th>
<th width="4%">首页</th>
<th width="5%">邮件通知</th>

@ -3,11 +3,15 @@
<td class="text-left">
<%= link_to(course.name, "/classrooms/#{course.id}", target: '_blank') %>
</td>
<td><%= course.course_members_count %></td>
<td><%= course.teacher_course_members.size %></td>
<td><%= course.students.size %></td>
<td><%= get_attachment_count(course, 0) %></td>
<td><%= course.informs.size %></td>
<td><%= course.course_videos.size %></td>
<td><%= course.course_homework_count("normal") %></td>
<td><%= course.course_homework_count("group") %></td>
<td><%= course.course_homework_count("practice") %></td>
<td><%= course.student_works_count %></td>
<td><%= course.exercises_count %></td>
<td><%= course.evaluate_count %></td>
<td><%= course.is_public == 1 ? "--" : "√" %></td>

Loading…
Cancel
Save