Merge branches 'dev_aliyun' and 'develop' of https://bdgit.educoder.net/Hjqreturn/educoder into dev_aliyun

courseware
杨树明 5 years ago
commit fed5aaee67

@ -13,7 +13,9 @@ class Admins::CoursesController < Admins::BaseController
format.js
format.html
format.xlsx do
@courses = courses.not_deleted.includes(:school, :students, :teacher_course_members, :informs, :course_videos, :attachments, :homework_commons, :course_activities, teacher: [user_extension: :department])
@courses = courses.not_deleted.includes(:school, :students, :teacher_course_members, :informs, :course_videos,
:live_links, :attachments, :homework_commons,
teacher: [user_extension: :department])
filename = "课堂列表_#{Time.current.strftime('%Y%m%d%H%M%S')}.xlsx"
render xlsx: 'index', filename: filename
end

@ -3,9 +3,11 @@ 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|
course_board = course.course_board
topic_count = course_board.present? ? course_board.messages.size : 0
data = [
course.id,
course.name,
@ -15,6 +17,8 @@ wb.styles do |s|
get_attachment_count(course, 0),
course.informs.size,
course.course_videos.size,
course.course_videos.map{|cv| cv.watch_course_videos.map(&:total_duration).sum }.sum.round,
course.live_links.size,
course.course_homework_count("normal"),
course.course_homework_count("group"),
course.course_homework_count("practice"),
@ -22,13 +26,13 @@ wb.styles do |s|
course.student_works_count,
course.exercises_count,
course.evaluate_count,
topic_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') : "--"
]
sheet.add_row(data)
end

Loading…
Cancel
Save