You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
educoder/app/views/ecs/course_targets/index.xlsx.axlsx

71 lines
2.6 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

course_targets = @course_targets.includes(
ec_course_achievement_methods: :ec_course_evaluation,
ec_graduation_subitems: :ec_graduation_requirement
)
ec_year = @_current_year
major = ec_year.ec_major_school.ec_major
wb = xlsx_package.workbook
wb.styles do |style|
title_style = style.add_style(sz: 16, height: 20, b: true)
ec_year_style = style.add_style(sz: 10, height: 14)
label_style = style.add_style(sz: 11, b: true, bg_color: '90EE90',
alignment: { horizontal: :center }, border: { style: :thin, color: '000000' })
content_style = style.add_style(sz: 11, height: 16, border: { style: :thin, color: '000000' })
name = "#{@_current_course.name}课程目标"
wb.add_worksheet(name: name) do |sheet|
sheet.add_row name, style: title_style
sheet.add_row []
sheet.add_row []
sheet.add_row ['专业代码', major.code], style: ec_year_style
sheet.add_row ['专业名称', major.name], style: ec_year_style
sheet.add_row ['学年', "#{ec_year.year}学年"], style: ec_year_style
sheet.add_row []
sheet.add_row []
index = 9
course_targets.each do |target|
sheet.add_row ['课程目标', "目标#{target.position}#{target.content}"], style: [label_style, content_style]
end
sheet.merge_cells("A#{index}:A#{index + course_targets.size}")
sheet.add_row []
sheet.add_row []
sheet.add_row %w(毕业要求 二级指标点 权重(∑=1) 课程目标), style: label_style
course_targets.each do |target|
target.ec_graduation_subitems.each do |item|
requirement = item.ec_graduation_requirement
data = [
"#{requirement.position}#{requirement.content}",
"#{requirement.position}-#{item.position}#{item.content}",
target.weight,
"目标#{target.position}"
]
sheet.add_row data, style: content_style
end
end
sheet.add_row []
sheet.add_row []
sheet.add_row %w(教学目标 评价方法 评价依据 达成标准(分)), style: label_style
course_targets.each do |target|
achievement_methods = []
names = []
target.ec_course_achievement_methods.each do |achievement|
names << achievement.ec_course_evaluation.name
achievement_methods << "#{achievement.ec_course_evaluation.name}#{achievement.percentage}%"
end
data = ["目标#{target.position}", achievement_methods.join('+'), names.join('+'), target.standard_grade]
sheet.add_row data, style: content_style
end
end
end